Skip to content
Merged
Changes from 2 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
29 changes: 22 additions & 7 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,28 @@ 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();
if (@hasDecl(std.Io, "Dir")) {
// v0.16 -> Dir moved to std.Io
const open_dir_opts: std.Io.Dir.OpenOptions = .{
.access_sub_paths = true,
.follow_symlinks = false,
};

var dir = std.Io.Dir.openDirAbsolute(mod.owner.graph.io, cache_include, open_dir_opts) catch @panic("No emscripten cache. Generate it!");

dir.close(mod.owner.graph.io);
} else if (@hasDecl(std.fs, "Dir")) {
// <=0.15.2 -> Dir on std.fs
// 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 };

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shim is no longer necessary.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed


var dir = std.fs.openDirAbsolute(cache_include, open_dir_opts) catch @panic("No emscripten cache. Generate it!");

dir.close();
}

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