authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-02-02 20:42:18-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-02-02 20:43:01-07:00
log3dad7312b2c0f84c557b1cf01cfbbbaa04ffc79c
tree74ac15acd638c8bd9eef482fba9c3e64dc0797d9
parent18091b440676737829cb4da154f9dd595449374b

CLI: use dummy http client when bootstrapping

Prevents unnecessary depedency on networking when bootstrapping zig.

1 files changed, 11 insertions(+), 1 deletions(-)

src/main.zig+11-1
......@@ -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.