-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.lua
More file actions
43 lines (37 loc) · 1.36 KB
/
build.lua
File metadata and controls
43 lines (37 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
local outDir = os.getenv("LDE_OUTPUT_DIR")
local sep = string.sub(package.config, 1, 1)
local isWindows = jit.os == "Windows"
local isMac = jit.os == "OSX"
local scriptDir = debug.getinfo(1, "S").source:sub(2):match("(.*[/\\])")
local src = scriptDir .. "vendor" .. sep .. "libgit2"
local libName = isWindows and "git2.dll" or (isMac and "libgit2.dylib" or "libgit2.so")
local outLib = outDir .. sep .. libName
if io.open(outLib, "rb") then return end
local function exec(cmd)
local ret = os.execute(cmd)
assert(ret == 0 or ret == true, "command failed: " .. cmd)
end
local build = src .. sep .. "build"
local https = isWindows and "WinHTTP" or "OpenSSL"
local cmakeExtra = ""
if isMac then
local f = io.popen("brew --prefix openssl")
if f then
local prefix = f:read("*l"); f:close()
if prefix and prefix ~= "" then
cmakeExtra = ' -DOPENSSL_ROOT_DIR="' .. prefix .. '"'
end
end
end
exec('cmake -S "' ..
src ..
'" -B "' ..
build .. '" -DBUILD_SHARED_LIBS=ON -DBUILD_TESTS=OFF -DBUILD_CLI=OFF -DUSE_SSH=OFF -DUSE_HTTPS=' .. https .. cmakeExtra)
exec('cmake --build "' .. build .. '" --config Release' .. (isWindows and "" or " -j$(nproc)"))
if isWindows then
exec('copy "' .. build .. '\\Release\\git2.dll" "' .. outLib .. '"')
elseif isMac then
exec('cp "' .. build .. '/libgit2.dylib" "' .. outLib .. '"')
else
exec('cp "' .. build .. '/libgit2.so" "' .. outLib .. '"')
end