Skip to content

Commit 7e30c5f

Browse files
committed
Fix CI/CD build errors for Linux and macOS
- Fix Linux build: conditionally compile platform-specific plthook files - Linux now only compiles plthook_elf.c - macOS now only compiles plthook_osx.c - Fix macOS build: ensure .doorstop_version files are created for all targets - Add after_build to doorstop_x86_64 target - Enhanced doorstop_arm64 after_build to create version files and properly handle universal binary creation - Ensures compatibility with GitHub Actions workflow expectations
1 parent aa7a9c8 commit 7e30c5f

File tree

1 file changed

+39
-11
lines changed

1 file changed

+39
-11
lines changed

xmake.lua

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ target("doorstop")
2929

3030
if is_os("linux") or is_os("macosx") then
3131
add_files("src/nix/*.c")
32-
add_files("src/nix/plthook/*.c")
32+
-- Add platform-specific plthook files
33+
if is_os("linux") then
34+
add_files("src/nix/plthook/plthook_elf.c")
35+
elseif is_os("macosx") then
36+
add_files("src/nix/plthook/plthook_osx.c")
37+
end
3338
add_links("dl")
3439
if is_mode("debug") then
3540
set_symbols("debug")
@@ -83,12 +88,17 @@ target("doorstop")
8388
add_files("src/util/*.c")
8489
add_files("src/runtimes/*.c")
8590
add_files("src/nix/*.c")
86-
add_files("src/nix/plthook/*.c")
91+
add_files("src/nix/plthook/plthook_osx.c") -- macOS-specific
8792
add_links("dl")
8893
if is_mode("debug") then
8994
set_symbols("debug")
9095
set_optimize("none")
9196
end
97+
98+
after_build(function(target)
99+
io.writefile(path.join(target:targetdir(), ".doorstop_version"),
100+
info.version.major.."."..info.version.minor.."."..info.version.patch..info.version.release)
101+
end)
92102

93103
-- Build arm64 binary
94104
target("doorstop_arm64")
@@ -101,19 +111,37 @@ target("doorstop")
101111
add_files("src/util/*.c")
102112
add_files("src/runtimes/*.c")
103113
add_files("src/nix/*.c")
104-
add_files("src/nix/plthook/*.c")
114+
add_files("src/nix/plthook/plthook_osx.c") -- macOS-specific
105115
add_links("dl")
106116
if is_mode("debug") then
107117
set_symbols("debug")
108118
set_optimize("none")
109119
end
110120

111-
-- Combine the binaries into a Universal Binary
112-
after_build(function (target)
113-
os.execv("sleep", {"5"}) -- Give time for both builds to finish (workaround)
114-
local build_mode = is_mode("debug") and "debug" or "release"
115-
local targetdir = target:targetdir()
116-
os.mkdir(path.join(targetdir, "..", "..", "universal", build_mode))
117-
os.execv("lipo", {"-create", "-output", path.join(targetdir, "..", "..", "universal", build_mode, "libdoorstop.dylib"), path.join(targetdir, "..", "..", "x86_64", build_mode, "libdoorstop_x86_64.dylib"), path.join(targetdir, "libdoorstop_arm64.dylib")})
118-
end)
121+
122+
after_build(function(target)
123+
local build_mode = is_mode("debug") and "debug" or "release"
124+
local targetdir = target:targetdir()
125+
126+
-- Write version file for this target
127+
io.writefile(path.join(targetdir, ".doorstop_version"),
128+
info.version.major.."."..info.version.minor.."."..info.version.patch..info.version.release)
129+
130+
-- Give time for both builds to finish (workaround)
131+
os.execv("sleep", {"5"})
132+
133+
-- Create universal binary directory
134+
local universal_dir = path.join(targetdir, "..", "..", "universal", build_mode)
135+
os.mkdir(universal_dir)
136+
137+
-- Combine the binaries into a Universal Binary
138+
os.execv("lipo", {"-create", "-output",
139+
path.join(universal_dir, "libdoorstop.dylib"),
140+
path.join(targetdir, "..", "..", "x86_64", build_mode, "libdoorstop_x86_64.dylib"),
141+
path.join(targetdir, "libdoorstop_arm64.dylib")})
142+
143+
-- Copy version file to universal directory
144+
os.cp(path.join(targetdir, ".doorstop_version"),
145+
path.join(universal_dir, ".doorstop_version"))
146+
end)
119147
end

0 commit comments

Comments
 (0)