all: cache module() returns to avoid duplicate modules

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2023-03-15 21:20:28 -07:00
parent eea7f245e1
commit 1ad2210ab9

View file

@ -69,10 +69,14 @@ pub const Options = struct {
install_libs: bool = false,
};
var _module: ?*std.build.Module = null;
pub fn module(b: *std.Build) *std.build.Module {
return b.createModule(.{
if (_module) |m| return m;
_module = b.createModule(.{
.source_file = .{ .path = sdkPath("/src/main.zig") },
});
return _module.?;
}
pub const LinkError = error{FailedToLinkGPU} || BuildError;