aboutsummaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-03-01 12:11:17 -0700
committerAndrew Kelley <andrew@ziglang.org>2023-03-01 20:01:23 -0500
commitdb8217f9a080f7c645a6448640a9af65f3944818 (patch)
tree66469871a26ea98bfbb0fcaf8ccb133150292014 /src/main.zig
parent874d3a17ae0f270b3e3f0ece7839d483d749107d (diff)
downloadzig-db8217f9a080f7c645a6448640a9af65f3944818.tar.gz
zig-db8217f9a080f7c645a6448640a9af65f3944818.zip
packages: avoid creating multiple modules with same build.zig
When there is a diamond dependency, reuse a *Module instead of creating a redundant one using the same build.zig file. Otherwise, the compile error "file exists in multiple modules" would occur.
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig
index dedcaabfa2..fb02628c61 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -4244,6 +4244,9 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
var build_roots_source = std.ArrayList(u8).init(gpa);
defer build_roots_source.deinit();
+ var all_modules: Package.AllModules = .{};
+ defer all_modules.deinit(gpa);
+
// Here we borrow main package's table and will replace it with a fresh
// one after this process completes.
main_pkg.fetchAndAddDependencies(
@@ -4257,6 +4260,7 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
&build_roots_source,
"",
color,
+ &all_modules,
) catch |err| switch (err) {
error.PackageFetchFailed => process.exit(1),
else => |e| return e,