diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index 05e9394..f4d9f80 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -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 diff --git a/build.zig b/build.zig index a265025..b090d66 100644 --- a/build.zig +++ b/build.zig @@ -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/"; diff --git a/src/builtins.zig b/src/builtins.zig index 0f841c7..1f4a401 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -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(); }