@@ -67,13 +67,22 @@ pub fn build(b: *std.Build) void {
6767 const cache_include = std .fs .path .join (b .allocator , &.{ b .sysroot .? , "cache" , "sysroot" , "include" }) catch @panic ("Out of memory" );
6868 defer b .allocator .free (cache_include );
6969
70- // TODO: Remove compatibility shim when Zig 0.16.0 is the minimum required version.
71- const open_dir_opts : std.fs.Dir.OpenOptions = if (@hasField (std .fs .Dir .OpenOptions , "follow_symlinks" ))
72- .{ .access_sub_paths = true , .follow_symlinks = false }
73- else
74- .{ .access_sub_paths = true , .no_follow = true };
75- var dir = std .fs .openDirAbsolute (cache_include , open_dir_opts ) catch @panic ("No emscripten cache. Generate it!" );
76- dir .close ();
70+ // TODO: Remove compatibility shim when minimum Zig version is 0.16.0.
71+ if (@hasDecl (std .Io , "Dir" )) {
72+ // Zig 0.16.0-dev
73+ var dir = std .Io .Dir .openDirAbsolute (mod .owner .graph .io , cache_include , .{
74+ .access_sub_paths = true ,
75+ .follow_symlinks = false ,
76+ }) catch @panic ("No emscripten cache. Generate it!" );
77+ dir .close (mod .owner .graph .io );
78+ } else if (@hasDecl (std .fs , "Dir" )) {
79+ // Zig 0.15.x
80+ var dir = std .fs .openDirAbsolute (cache_include , .{
81+ .access_sub_paths = true ,
82+ .no_follow = true ,
83+ }) catch @panic ("No emscripten cache. Generate it!" );
84+ dir .close ();
85+ } else @compileError ("Fix `openDirAbsolute` compatibility shim" );
7786
7887 mod .addIncludePath (.{ .cwd_relative = cache_include });
7988 },
0 commit comments