Skip to content
This repository was archived by the owner on May 24, 2026. It is now read-only.

Commit 96eb05d

Browse files
committed
Trying to get static build on mac working
1 parent 064dea3 commit 96eb05d

2 files changed

Lines changed: 39 additions & 9 deletions

File tree

.github/workflows/build.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,43 @@ jobs:
123123

124124
- name: Install dependencies
125125
run: |
126-
brew install meson vala bison glib libxml2
126+
brew install meson vala bison glib libxml2 zlib libffi cmake
127127
echo "$(brew --prefix bison)/bin" >> $GITHUB_PATH
128128
129+
- name: Build static libxml2
130+
run: |
131+
brew fetch --force libxml2
132+
TARBALL=$(brew --cache libxml2)
133+
TMPDIR=$(mktemp -d)
134+
tar xf "$TARBALL" -C "$TMPDIR"
135+
cd "$TMPDIR"/libxml2-*
136+
cmake -B build \
137+
-DBUILD_SHARED_LIBS=OFF \
138+
-DLIBXML2_WITH_PYTHON=OFF \
139+
-DLIBXML2_WITH_ICU=OFF \
140+
-DLIBXML2_WITH_LZMA=OFF \
141+
-DZLIB_ROOT=$(brew --prefix zlib)
142+
cmake --build build
143+
cp build/libxml2.a "$(brew --prefix libxml2)/lib/"
144+
129145
- name: Build
130146
run: |
147+
export PKG_CONFIG_PATH="$(brew --prefix libxml2)/lib/pkgconfig:$(brew --prefix zlib)/lib/pkgconfig:$(brew --prefix libffi)/lib/pkgconfig:$PKG_CONFIG_PATH"
148+
export LDFLAGS="-L$(brew --prefix zlib)/lib -L$(brew --prefix libffi)/lib -L$(brew --prefix libxml2)/lib"
149+
export CPPFLAGS="-I$(brew --prefix libxml2)/include"
131150
meson setup builddir --default-library=static --prefer-static
132151
meson compile -C builddir
133152
134153
- name: Verify
135154
run: |
136155
file builddir/wixl
156+
otool -L builddir/wixl
157+
ls -lh builddir/wixl
137158
builddir/wixl --version
159+
if otool -L builddir/wixl | grep -E '\.(dylib|so)' | grep -v '/usr/lib/\|/System/Library/'; then
160+
echo "ERROR: Found non-system dynamic dependencies!"
161+
exit 1
162+
fi
138163
139164
- name: Rename binary
140165
run: cp builddir/wixl wixl-macos-${{ matrix.arch }}

meson.build

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,10 @@ libmsi_dep = declare_dependency(
250250
dependencies: libmsi_deps,
251251
)
252252

253-
# --- libeconf (static, built from source — needed on Linux for libblkid) ---
253+
# --- Platform-specific dependencies and link args ---
254254
platform_link_deps = []
255+
platform_extra_deps = []
256+
255257
if host_machine.system() == 'linux'
256258
libeconf = static_library('econf',
257259
'libeconf/lib/econf_error.c',
@@ -266,17 +268,20 @@ if host_machine.system() == 'linux'
266268
include_directories: include_directories('libeconf/include', 'libeconf/lib'),
267269
)
268270
platform_link_deps = [libeconf]
269-
endif
270-
271-
# --- Platform-specific link args ---
272-
if host_machine.system() == 'windows'
271+
platform_link_args = ['-static']
272+
elif host_machine.system() == 'darwin'
273+
platform_link_args = [
274+
'-framework', 'CoreFoundation',
275+
'-framework', 'Foundation',
276+
'-framework', 'AppKit',
277+
'-framework', 'Carbon',
278+
]
279+
elif host_machine.system() == 'windows'
273280
platform_link_args = [
274281
'-lws2_32', '-lole32', '-lshell32', '-lshlwapi',
275282
'-ladvapi32', '-luserenv', '-liphlpapi', '-ldnsapi',
276283
'-lbcrypt',
277284
]
278-
elif host_machine.system() == 'linux'
279-
platform_link_args = ['-static']
280285
else
281286
platform_link_args = []
282287
endif
@@ -320,7 +325,7 @@ wixl = executable('wixl',
320325
c_args: ['-include', meson.project_build_root() / 'config.h'],
321326
include_directories: [inc_dirs, gcab_inc_dirs],
322327
link_with: [libcommon] + platform_link_deps,
323-
dependencies: [libmsi_dep, libgcab_dep, glib, gio, libxml],
328+
dependencies: [libmsi_dep, libgcab_dep, glib, gio, libxml] + platform_extra_deps,
324329
link_args: platform_link_args,
325330
install: true,
326331
)

0 commit comments

Comments
 (0)