Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/Package.zig
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ pub const build_zig_basename = "build.zig";

pub fn fetchAndAddDependencies(
pkg: *Package,
root_pkg: *Package,
arena: Allocator,
thread_pool: *ThreadPool,
http_client: *std.http.Client,
Expand Down Expand Up @@ -295,7 +296,8 @@ pub fn fetchAndAddDependencies(
all_modules,
);

try pkg.fetchAndAddDependencies(
try sub_pkg.fetchAndAddDependencies(
root_pkg,
arena,
thread_pool,
http_client,
Expand All @@ -309,7 +311,8 @@ pub fn fetchAndAddDependencies(
all_modules,
);

try add(pkg, gpa, fqn, sub_pkg);
try pkg.add(gpa, name, sub_pkg);
try root_pkg.add(gpa, fqn, sub_pkg);

try dependencies_source.writer().print(" pub const {s} = @import(\"{}\");\n", .{
std.zig.fmtId(fqn), std.zig.fmtEscapes(fqn),
Expand Down
12 changes: 6 additions & 6 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4228,6 +4228,10 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
.root_src_path = "build_runner.zig",
};

var build_pkg: Package = .{
.root_src_directory = build_directory,
.root_src_path = build_zig_basename,
};
if (!build_options.omit_pkg_fetching_code) {
var http_client: std.http.Client = .{ .allocator = gpa };
defer http_client.deinit();
Expand All @@ -4249,7 +4253,8 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi

// Here we borrow main package's table and will replace it with a fresh
// one after this process completes.
main_pkg.fetchAndAddDependencies(
build_pkg.fetchAndAddDependencies(
&main_pkg,
arena,
&thread_pool,
&http_client,
Expand Down Expand Up @@ -4280,11 +4285,6 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
mem.swap(Package.Table, &main_pkg.table, &deps_pkg.table);
try main_pkg.add(gpa, "@dependencies", deps_pkg);
}

var build_pkg: Package = .{
.root_src_directory = build_directory,
.root_src_path = build_zig_basename,
};
try main_pkg.add(gpa, "@build", &build_pkg);

const comp = Compilation.create(gpa, .{
Expand Down