Skip to content

Commit

Permalink
CI: separate tools job from the build job
Browse files Browse the repository at this point in the history
fix `error: 'resolv.h' file not found`
  • Loading branch information
Ultra-Code committed Dec 5, 2024
1 parent 9a30f84 commit e470818
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
26 changes: 22 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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", "");
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit e470818

Please sign in to comment.