Skip to content

Commit 3dad731

Browse files
committed
CLI: use dummy http client when bootstrapping
Prevents unnecessary depedency on networking when bootstrapping zig.
1 parent 18091b4 commit 3dad731

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/main.zig

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5379,7 +5379,16 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
53795379
try thread_pool.init(.{ .allocator = gpa });
53805380
defer thread_pool.deinit();
53815381

5382-
var http_client: std.http.Client = .{ .allocator = gpa };
5382+
// Dummy http client that is not actually used when only_core_functionality is enabled.
5383+
// Prevents bootstrap from depending on a bunch of unnecessary stuff.
5384+
const HttpClient = if (build_options.only_core_functionality) struct {
5385+
allocator: Allocator,
5386+
fn deinit(self: *@This()) void {
5387+
_ = self;
5388+
}
5389+
} else std.http.Client;
5390+
5391+
var http_client: HttpClient = .{ .allocator = gpa };
53835392
defer http_client.deinit();
53845393

53855394
var unlazy_set: Package.Fetch.JobQueue.UnlazySet = .{};
@@ -5656,6 +5665,7 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
56565665
if (code == 2) process.exit(2);
56575666

56585667
if (code == 3) {
5668+
if (build_options.only_core_functionality) process.exit(3);
56595669
// Indicates the configure phase failed due to missing lazy
56605670
// dependencies and stdout contains the hashes of the ones
56615671
// that are missing.

0 commit comments

Comments
 (0)