|
1 | | -local outDir = os.getenv("LDE_OUTPUT_DIR") |
2 | | -local sep = string.sub(package.config, 1, 1) |
| 1 | +local build = require("lde-build") |
| 2 | + |
3 | 3 | local isWindows = jit.os == "Windows" |
4 | 4 | local isMac = jit.os == "OSX" |
5 | | -local isAndroid = os.getenv("ANDROID_ROOT") ~= nil |
6 | | -local scriptDir = debug.getinfo(1, "S").source:sub(2):match("(.*[/\\])") |
7 | | -local src = scriptDir .. "vendor" .. sep .. "libgit2" |
8 | 5 | local libName = isWindows and "git2.dll" or (isMac and "libgit2.dylib" or "libgit2.so") |
9 | | -local outLib = outDir .. sep .. libName |
10 | 6 |
|
11 | | -if io.open(outLib, "rb") then return end |
| 7 | +local url = "https://github.com/libgit2/libgit2/archive/refs/tags/v1.8.5.tar.gz" |
| 8 | +local tarball = "libgit2-1.8.5.tar.gz" |
12 | 9 |
|
13 | | -local function exec(cmd) |
14 | | - local ret = os.execute(cmd) |
15 | | - assert(ret == 0 or ret == true, "command failed: " .. cmd) |
16 | | -end |
| 10 | +local content = build:fetch(url) |
| 11 | +build:write(tarball, content) |
| 12 | +build:extract(tarball, ".") |
| 13 | +build:move("libgit2-1.8.5", "libgit2") |
17 | 14 |
|
18 | | -local build = src .. sep .. "build" |
| 15 | +local srcDir = build.outDir .. "/libgit2" |
| 16 | +local buildDir = srcDir .. "/build" |
19 | 17 |
|
20 | 18 | ---@format disable-next |
21 | 19 | local gitMin = "-DBUILD_TESTS=OFF -DBUILD_CLI=OFF -DUSE_SSH=OFF -DUSE_GSSAPI=OFF -DUSE_NTLMCLIENT=OFF -DREGEX_BACKEND=builtin -DUSE_HTTP_PARSER=builtin -DUSE_BUNDLED_ZLIB=ON -DCMAKE_C_FLAGS=-g0" |
22 | 20 |
|
23 | | -local https, cmakeExtra |
| 21 | +local https |
24 | 22 | if isWindows then |
25 | 23 | https = "WinHTTP" |
26 | | - cmakeExtra = "" |
27 | 24 | elseif isMac then |
28 | 25 | https = "SecureTransport" |
29 | | - cmakeExtra = "" |
30 | 26 | else |
31 | 27 | https = "OpenSSL" |
32 | | - cmakeExtra = "" |
33 | 28 | end |
34 | 29 |
|
35 | | -exec('cmake -S "' .. src .. '" -B "' .. build .. '" -DBUILD_SHARED_LIBS=ON -DUSE_HTTPS=' .. https .. ' ' .. gitMin .. (cmakeExtra ~= "" and (' ' .. cmakeExtra) or "")) |
36 | | -exec('cmake --build "' .. build .. '" --config Release' .. (isWindows and "" or " -j$(nproc)")) |
| 30 | +build:sh('cmake -S "' .. |
| 31 | +srcDir .. '" -B "' .. buildDir .. '" -DBUILD_SHARED_LIBS=ON -DUSE_HTTPS=' .. https .. ' ' .. gitMin) |
| 32 | +build:sh('cmake --build "' .. buildDir .. '" --config Release' .. (isWindows and "" or " -j$(nproc)")) |
37 | 33 |
|
38 | 34 | if isWindows then |
39 | | - exec('copy "' .. build .. '\\Release\\git2.dll" "' .. outLib .. '"') |
| 35 | + build:copy("libgit2/build/Release/git2.dll", libName) |
40 | 36 | elseif isMac then |
41 | | - exec('cp "' .. build .. '/libgit2.dylib" "' .. outLib .. '"') |
42 | | - exec('strip -x "' .. outLib .. '"') |
| 37 | + build:copy("libgit2/build/libgit2.dylib", libName) |
| 38 | + build:sh('strip -x "' .. build.outDir .. '/' .. libName .. '"') |
43 | 39 | else |
44 | | - exec('cp "' .. build .. '/libgit2.so" "' .. outLib .. '"') |
45 | | - exec('strip --strip-unneeded --remove-section=.eh_frame --remove-section=.eh_frame_hdr "' .. outLib .. '"') |
| 40 | + build:copy("libgit2/build/libgit2.so", libName) |
| 41 | + build:sh('strip --strip-unneeded --remove-section=.eh_frame --remove-section=.eh_frame_hdr "' .. |
| 42 | + build.outDir .. '/' .. libName .. '"') |
46 | 43 | end |
0 commit comments