-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.lua
More file actions
44 lines (36 loc) · 1.54 KB
/
build.lua
File metadata and controls
44 lines (36 loc) · 1.54 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
44
local build = require("lde-build")
local isWindows = jit.os == "Windows"
local isMac = jit.os == "OSX"
local libName = isWindows and "git2.dll" or (isMac and "libgit2.dylib" or "libgit2.so")
local commit = "1888a166e43420b2a5f93f104f2a99ec049b073c"
local url = "https://github.com/libgit2/libgit2/archive/" .. commit .. ".tar.gz"
local tarball = "libgit2-" .. commit .. ".tar.gz"
local content = build:fetch(url)
build:write(tarball, content)
build:extract(tarball, ".")
build:move("libgit2-" .. commit, "libgit2")
local srcDir = build.outDir .. "/libgit2"
local buildDir = srcDir .. "/build"
---@format disable-next
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"
local https
if isWindows then
https = "WinHTTP"
elseif isMac then
https = "SecureTransport"
else
https = "OpenSSL"
end
build:sh('cmake -S "' ..
srcDir .. '" -B "' .. buildDir .. '" -DBUILD_SHARED_LIBS=ON -DUSE_HTTPS=' .. https .. ' ' .. gitMin)
build:sh('cmake --build "' .. buildDir .. '" --config Release' .. (isWindows and "" or " -j$(nproc)"))
if isWindows then
build:copy("libgit2/build/Release/git2.dll", libName)
elseif isMac then
build:copy("libgit2/build/libgit2.dylib", libName)
build:sh('strip -x "' .. build.outDir .. '/' .. libName .. '"')
else
build:copy("libgit2/build/libgit2.so", libName)
build:sh('strip --strip-unneeded --remove-section=.eh_frame --remove-section=.eh_frame_hdr "' ..
build.outDir .. '/' .. libName .. '"')
end