Skip to content

Commit

Permalink
Merge pull request #4 from allyourcodebase/fix-cross-compile-on-macos
Browse files Browse the repository at this point in the history
Detect the target os tag when setting is_macos and is_windows
  • Loading branch information
Ultra-Code authored Dec 5, 2024
2 parents 6acec0f + 6e1906d commit 22c1b92
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ jobs:
- name: Run `build`
run: zig build ${{ matrix.build-options }} -Doptimize=${{ matrix.optimize }} --summary all

# Test allyourcodebase/lmdb#3
- name: Run `build tools`
run: zig build tools -Dtarget=x86_64-macos-none --summary all
run: zig build tools -Dtarget=x86_64-windows-gnu --summary all

test:
strategy:
fail-fast: false
Expand Down
9 changes: 5 additions & 4 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ pub fn build(b: *Build) void {
const strip = b.option(bool, "strip", "Strip debug information") orelse false;
const lto = b.option(bool, "lto", "Enable link time optimization") orelse false;

// writing WritingLibFiles isn't implemented on windows
// and zld the only linker supported on macos
const is_macos = builtin.os.tag == .macos;
const is_windows = builtin.os.tag == .windows;
const is_macos = builtin.os.tag == .macos or target.result.os.tag == .macos;
const is_windows = builtin.os.tag == .windows or target.result.os.tag == .windows;

// writing WritingLibFiles in zld isn't implemented on windows
// and zld is the only linker suppored on macos
const use_lld = if (is_macos) false else if (is_windows) true else switch (optimize) {
.Debug => false,
else => true,
Expand Down

0 comments on commit 22c1b92

Please sign in to comment.