Skip to content

Commit 5f19274

Browse files
nurpaxnatecraddock
authored andcommitted
Support both zig-0.14 and zig-0.15-dev in main
Conditionalize on zig version to make ziglua build with both zig-0.14 and later 0.15-dev versions. This way those who like to keep using zig-0.14 can still pick up new updates to ziglua. This also adds a CI configuration to add protection for both versions. for #153
1 parent ac76219 commit 5f19274

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

.github/workflows/tests.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ jobs:
1111
strategy:
1212
matrix:
1313
os: [ubuntu-latest, macos-latest, windows-latest]
14+
zig: ["0.14.0", "0.15.0-dev.375+8f8f37fb0"]
15+
1416
runs-on: ${{matrix.os}}
1517

1618
steps:
@@ -20,7 +22,7 @@ jobs:
2022
- name: Setup Zig
2123
uses: mlugg/setup-zig@v1
2224
with:
23-
version: 0.15.0-dev.375+8f8f37fb0
25+
version: ${{ matrix.zig }}
2426

2527
- name: Run tests
2628
run: make test

src/lib.zig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,12 @@ pub const Lua = opaque {
613613
} else if (nsize == 0) {
614614
return null;
615615
} else {
616+
const builtin = @import("builtin"); // FIXME: remove when zig-0.15 is released and 0.14 can be dropped
616617
// ptr is null, allocate a new block of memory
617-
const new_ptr = allocator_ptr.alignedAlloc(u8, .fromByteUnits(alignment), nsize) catch return null;
618+
const new_ptr = (if (builtin.zig_version.major == 0 and builtin.zig_version.minor < 15)
619+
allocator_ptr.alignedAlloc(u8, alignment, nsize)
620+
else
621+
allocator_ptr.alignedAlloc(u8, .fromByteUnits(alignment), nsize)) catch return null;
618622
return new_ptr.ptr;
619623
}
620624
}

0 commit comments

Comments
 (0)