Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect the target os tag when setting is_macos and is_windows #4

Merged
merged 3 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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