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 033ebb8551
commit 6bd4d91932
14 changed files with 75 additions and 17 deletions

View file

@ -18,10 +18,14 @@ pub fn testStep(b: *std.Build, optimize: std.builtin.OptimizeMode, target: std.z
return main_tests.run();
}
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.?;
}
fn sdkPath(comptime suffix: []const u8) []const u8 {