From e47081806d246ebd3be9b57278643a897b3e366a Mon Sep 17 00:00:00 2001 From: Ultra-Code Date: Thu, 5 Dec 2024 13:35:47 +0000 Subject: [PATCH] CI: separate tools job from the build job fix `error: 'resolv.h' file not found` --- .github/workflows/ci.yml | 26 ++++++++++++++++++++++---- build.zig | 13 +++++++------ 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 45e2d60..65e32a9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,13 +36,31 @@ jobs: - name: Run `build` run: zig build ${{ matrix.build-options }} -Doptimize=${{ matrix.optimize }} --summary all - # Test allyourcodebase/lmdb#3 + # CI test for allyourcodebase/lmdb#3 + tools: + strategy: + fail-fast: false + matrix: + zig-version: ["master", "0.13.0"] + os: [ubuntu-latest] + + runs-on: ${{ matrix.os }} + + steps: + - name: Check out repository + uses: actions/checkout@v4 + with: + submodules: false + + - name: Set up Zig + uses: mlugg/setup-zig@v1 + with: + version: ${{ matrix.zig-version }} + use-cache: false + - name: Run `build tools on macos` run: zig build tools -Dtarget=x86_64-macos-none --summary all - - name: Run `build tools on windows` - run: zig build tools -Dtarget=x86_64-windows-gnu --summary all - test: strategy: fail-fast: false diff --git a/build.zig b/build.zig index b2aa97e..19decda 100644 --- a/build.zig +++ b/build.zig @@ -20,11 +20,12 @@ 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; - 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; - + const is_macos = builtin.os.tag == .macos; + const need_resolve_h = is_macos or target.result.os.tag == .macos; + const is_windows = builtin.os.tag == .windows; + // writing WritingLibFiles in zld isn't implemented on windows - // and zld is the only linker suppored on macos + // and zld is the only linker supported on macos const use_lld = if (is_macos) false else if (is_windows) true else switch (optimize) { .Debug => false, else => true, @@ -66,7 +67,7 @@ pub fn build(b: *Build) void { }); liblmdb.addIncludePath(lmdb_upstream.path(lmdb_root)); liblmdb.root_module.addCMacro("_XOPEN_SOURCE", "600"); - if (is_macos) { + if (need_resolve_h) { liblmdb.root_module.addCMacro("_DARWIN_C_SOURCE", ""); } @@ -112,7 +113,7 @@ pub fn build(b: *Build) void { }); tool.addIncludePath(lmdb_upstream.path(lmdb_root)); tool.root_module.addCMacro("_XOPEN_SOURCE", "600"); - if (is_macos) { + if (need_resolve_h) { tool.root_module.addCMacro("_DARWIN_C_SOURCE", ""); } tool.linkLibrary(liblmdb);