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
This commit is contained in:
Dylan 2024-05-29 10:11:46 -04:00 committed by GitHub
parent 797de0f9ad
commit 1c7407e113
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -198,13 +198,15 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
@panic("Pass '--sysroot \"$EMSDK/upstream/emscripten\"'"); @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"); if (comptime builtin.zig_version.minor > 12) {
defer b.allocator.free(cache_include); 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();
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!"); raylib.addIncludePath(b.path(cache_include));
dir.close(); } 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!");
raylib.addIncludePath(b.path(cache_include)); dir.close();
raylib.addIncludePath(.{ .path = cache_include });
}
}, },
else => { else => {
@panic("Unsupported OS"); @panic("Unsupported OS");