Skip to content

Commit

Permalink
add back in zig 0.11 and 0.12 support
Browse files Browse the repository at this point in the history
  • Loading branch information
booniepepper committed Jul 16, 2024
1 parent 9371905 commit 030dff3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

strategy:
matrix:
zig_version: [0.11.0, 0.12.0]
zig_version: [0.13.0, 0.12.0, 0.11.0]

runs-on: ubuntu-latest

Expand Down
9 changes: 7 additions & 2 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,13 @@ pub fn build(b: *Build) !void {
});

if (comptime @hasDecl(@TypeOf(cross_tar.*), "setCwd")) {
// Zig 0.12.0
cross_tar.setCwd(b.path("./zig-out/bin/"));
if (comptime @hasDecl(Build, "path")) {
// Zig 0.13.0
cross_tar.setCwd(b.path("./zig-out/bin/"));
} else {
// Zig 0.12.0
cross_tar.setCwd(.{ .path = "./zig-out/bin/" });
}
} else {
// Zig 0.11
cross_tar.cwd = "./zig-out/bin/";
Expand Down
9 changes: 8 additions & 1 deletion src/builtins.zig
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,14 @@ pub fn writef(dt: *DtMachine) !void {
const theCwdPath = try std.process.getCwdAlloc(dt.alloc);
var theCwd = try std.fs.openDirAbsolute(theCwdPath, .{});

try theCwd.writeFile(.{ .data = contents, .sub_path = filename });
const Dir = std.fs.Dir;
if (comptime @hasDecl(Dir, "WriteFileOptions") and @typeInfo(@TypeOf(Dir.writeFile)).Fn.params[1].type == Dir.WriteFileOptions) {
// Zig 0.13
try theCwd.writeFile(.{ .data = contents, .sub_path = filename });
} else {
// Zig 0.12, 0.11
try theCwd.writeFile(filename, contents);
}
theCwd.close();
}

Expand Down

0 comments on commit 030dff3

Please sign in to comment.