From 1c7407e1139bc34de044327ebe8b9dc66f60cfc3 Mon Sep 17 00:00:00 2001 From: Dylan Date: Wed, 29 May 2024 10:11:46 -0400 Subject: [PATCH] Fix for issue #4010 Split the code for Zig's master branch and >= 0.12.0 due to changes in https://github.com/ziglang/zig/pull/19623 --- src/build.zig | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/build.zig b/src/build.zig index d172b3c2a..fb46b86fd 100644 --- a/src/build.zig +++ b/src/build.zig @@ -198,13 +198,15 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std. @panic("Pass '--sysroot \"$EMSDK/upstream/emscripten\"'"); } - 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); - - var dir = std.fs.openDirAbsolute(cache_include, std.fs.Dir.OpenDirOptions{ .access_sub_paths = true, .no_follow = true }) catch @panic("No emscripten cache. Generate it!"); - dir.close(); - - raylib.addIncludePath(b.path(cache_include)); + if (comptime builtin.zig_version.minor > 12) { + var dir = std.fs.cwd().openDir(cache_include, std.fs.Dir.OpenDirOptions{ .access_sub_paths = true, .no_follow = true }) catch @panic("No emscripten cache. Generate it!"); + dir.close(); + raylib.addIncludePath(b.path(cache_include)); + } else { + var dir = std.fs.openDirAbsolute(cache_include, std.fs.Dir.OpenDirOptions{ .access_sub_paths = true, .no_follow = true }) catch @panic("No emscripten cache. Generate it!"); + dir.close(); + raylib.addIncludePath(.{ .path = cache_include }); + } }, else => { @panic("Unsupported OS");