Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,22 @@ pub fn build(b: *std.Build) void {
const cache_include = std.fs.path.join(b.allocator, &.{ b.sysroot.?, "cache", "sysroot", "include" }) catch @panic("Out of memory");
defer b.allocator.free(cache_include);

// TODO: Remove compatibility shim when Zig 0.16.0 is the minimum required version.
const open_dir_opts: std.fs.Dir.OpenOptions = if (@hasField(std.fs.Dir.OpenOptions, "follow_symlinks"))
.{ .access_sub_paths = true, .follow_symlinks = false }
else
.{ .access_sub_paths = true, .no_follow = true };
var dir = std.fs.openDirAbsolute(cache_include, open_dir_opts) catch @panic("No emscripten cache. Generate it!");
dir.close();
// TODO: Remove compatibility shim when minimum Zig version is 0.16.0.
if (@hasDecl(std.Io, "Dir")) {
// Zig 0.16.0-dev
var dir = std.Io.Dir.openDirAbsolute(mod.owner.graph.io, cache_include, .{
.access_sub_paths = true,
.follow_symlinks = false,
}) catch @panic("No emscripten cache. Generate it!");
dir.close(mod.owner.graph.io);
} else if (@hasDecl(std.fs, "Dir")) {
// Zig 0.15.x
var dir = std.fs.openDirAbsolute(cache_include, .{
.access_sub_paths = true,
.no_follow = true,
}) catch @panic("No emscripten cache. Generate it!");
dir.close();
} else @compileError("Fix `openDirAbsolute` compatibility shim");

mod.addIncludePath(.{ .cwd_relative = cache_include });
},
Expand Down