feat: download per-platform libraries

This commit is contained in:
əlemi 2024-09-10 16:07:08 +02:00
parent 14f5e52e99
commit 485f2f941f
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -1,25 +1,25 @@
local plugin_dir = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":p:h") -- got this from https://lazy.folke.io/developers#building local plugin_dir = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":p:h") -- got this from https://lazy.folke.io/developers#building
-- -- TODO not the best loader but a simple example? urls dont work -- TODO not the best loader but a simple example? urls dont work
-- local host_os = vim.loop.os_uname().sysname local os_uname = vim.loop.os_uname()
-- local ext = nil
-- if host_os == "Windows" then ext = ".dll" local arch = os_uname.machine
-- elseif host_os == "Mac" then ext = ".dylib"
-- else ext = ".so" local platform = string.lower(os_uname.sysname)
-- end if platform == "mac" then platform = "darwin" end
--
-- local shasum = nil local ext = os_uname.sysname
-- if os_uname.sysname == "Windows" then ext = ".dll"
elseif os_uname.sysname == "Mac" then ext = ".dylib"
else ext = ".so"
end
-- -- TODO compare checksum before redownloading
-- if vim.fn.filereadable(path .. 'native' .. ext) == 1 then -- if vim.fn.filereadable(path .. 'native' .. ext) == 1 then
-- shasum = vim.fn.system("sha256sum " .. path .. 'native' .. ext) -- shasum = vim.fn.system("sha256sum " .. path .. 'native' .. ext)
-- end -- end
--
-- local last_sum = vim.fn.system("curl -s https://codemp.alemi.dev/lib/lua/latest/sum") local native_path = plugin_dir .. "/lua/codemp/native." .. ext
-- local download_url_native = string.format("https://code.mp/releases/lua/codemp-lua-%s-%s.%s", arch, platform, ext)
-- if last_sum ~= shasum then
-- vim.fn.system("curl -o " .. path .. 'native' .. ext .. "https://codemp.alemi.dev/lib/lua/latest")
-- end
local native_path = plugin_dir .. "/lua/codemp/native.so" -- TODO get extension based on platform
local download_url_native = "https://code.mp/releases/lua/codemp_native-linux.so" -- TODO get url based on platform
print("downloading codemp native lua extension...") print("downloading codemp native lua extension...")
vim.system({"curl", "-s", "-o", native_path, download_url_native }):wait() -- TODO can we run this asynchronously? vim.system({"curl", "-s", "-o", native_path, download_url_native }):wait() -- TODO can we run this asynchronously?