Skip to content

Commit

Permalink
Merge pull request #33 from ubermanu/master
Browse files Browse the repository at this point in the history
feat: compat with 0.13.0-dev.267
  • Loading branch information
tiehuis authored Jul 3, 2024
2 parents 8251813 + 9f5ea61 commit 7bc0fd7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

- uses: goto-bus-stop/setup-zig@v2
with:
version: 0.11.0 # most recent stable
version: 0.12.0 # most recent stable

- name: Check formatting
run: zig fmt --check .
Expand All @@ -32,7 +32,7 @@ jobs:

strategy:
matrix:
zig-version: ['0.11.0']
zig-version: ['0.11.0', '0.12.0']
os: [ubuntu-latest]
allow-fail: [false]
include:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
zig-cache
zig-out
.zig-*
23 changes: 15 additions & 8 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ pub fn build(b: *std.Build) void {
} else {
// Zig 0.12-dev.2159
_ = b.addModule("regex", .{
.root_source_file = .{ .path = "src/regex.zig" },
.root_source_file = path(b, "src/regex.zig"),
});
}

// library tests
const library_tests = b.addTest(.{
.root_source_file = .{ .path = "src/all_test.zig" },
.root_source_file = path(b, "src/all_test.zig"),
.target = target,
.optimize = optimize,
});
Expand All @@ -30,7 +30,7 @@ pub fn build(b: *std.Build) void {
// C library
const staticLib = b.addStaticLibrary(.{
.name = "regex",
.root_source_file = .{ .path = "src/c_regex.zig" },
.root_source_file = path(b, "src/c_regex.zig"),
.target = target,
.optimize = optimize,
});
Expand All @@ -40,7 +40,7 @@ pub fn build(b: *std.Build) void {

const sharedLib = b.addSharedLibrary(.{
.name = "regex",
.root_source_file = .{ .path = "src/c_regex.zig" },
.root_source_file = path(b, "src/c_regex.zig"),
.target = target,
.optimize = optimize,
});
Expand All @@ -55,12 +55,10 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
});
c_example.addCSourceFile(.{
.file = .{
.path = "example/example.c",
},
.file = path(b, "example/example.c"),
.flags = &.{"-Wall"},
});
c_example.addIncludePath(.{ .path = "include" });
c_example.addIncludePath(path(b, "include"));
c_example.linkLibC();
c_example.linkLibrary(staticLib);

Expand All @@ -70,3 +68,12 @@ pub fn build(b: *std.Build) void {

b.default_step.dependOn(test_step);
}

fn path(b: *std.Build, sub_path: []const u8) std.Build.LazyPath {
if (@hasDecl(std.Build, "path")) {
// Zig 0.13-dev.267
return b.path(sub_path);
} else {
return .{ .path = sub_path };
}
}

0 comments on commit 7bc0fd7

Please sign in to comment.