authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-10-07 23:36:32-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-10-08 16:54:31-07:00
loga605bd9887a8a4220e177e42259809e0680d4221
treed2853b357b1711d323f2e69a356e88e9039badaf
parentb2fefc847341beb690e4cf49e2857fbacc16d329

zig build: add `--fetch` argument

closes #14280

2 files changed, 7 insertions(+), 0 deletions(-)

lib/build_runner.zig+1
...@@ -997,6 +997,7 @@ fn usage(builder: *std.Build, already_ran_build: bool, out_stream: anytype) !voi...@@ -997,6 +997,7 @@ fn usage(builder: *std.Build, already_ran_build: bool, out_stream: anytype) !voi
997 \\ -j<N> Limit concurrent jobs (default is to use all CPU cores)997 \\ -j<N> Limit concurrent jobs (default is to use all CPU cores)
998 \\ --maxrss <bytes> Limit memory usage (default is to use available memory)998 \\ --maxrss <bytes> Limit memory usage (default is to use available memory)
999 \\ --skip-oom-steps Instead of failing, skip steps that would exceed --maxrss999 \\ --skip-oom-steps Instead of failing, skip steps that would exceed --maxrss
1000 \\ --fetch Exit after fetching dependency tree
1000 \\1001 \\
1001 \\Project-Specific Options:1002 \\Project-Specific Options:
1002 \\1003 \\
src/main.zig+6
...@@ -4621,6 +4621,7 @@ pub const usage_build =...@@ -4621,6 +4621,7 @@ pub const usage_build =
4621 \\ --global-cache-dir [path] Override path to global Zig cache directory4621 \\ --global-cache-dir [path] Override path to global Zig cache directory
4622 \\ --zig-lib-dir [arg] Override path to Zig lib directory4622 \\ --zig-lib-dir [arg] Override path to Zig lib directory
4623 \\ --build-runner [file] Override path to build runner4623 \\ --build-runner [file] Override path to build runner
4624 \\ --fetch Exit after fetching dependency tree
4624 \\ -h, --help Print this help and exit4625 \\ -h, --help Print this help and exit
4625 \\4626 \\
4626;4627;
...@@ -4643,6 +4644,7 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi...@@ -4643,6 +4644,7 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
4643 var child_argv = std.ArrayList([]const u8).init(arena);4644 var child_argv = std.ArrayList([]const u8).init(arena);
4644 var reference_trace: ?u32 = null;4645 var reference_trace: ?u32 = null;
4645 var debug_compile_errors = false;4646 var debug_compile_errors = false;
4647 var fetch_only = false;
46464648
4647 const argv_index_exe = child_argv.items.len;4649 const argv_index_exe = child_argv.items.len;
4648 _ = try child_argv.addOne();4650 _ = try child_argv.addOne();
...@@ -4692,6 +4694,8 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi...@@ -4692,6 +4694,8 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
4692 } else if (mem.eql(u8, arg, "-freference-trace")) {4694 } else if (mem.eql(u8, arg, "-freference-trace")) {
4693 try child_argv.append(arg);4695 try child_argv.append(arg);
4694 reference_trace = 256;4696 reference_trace = 256;
4697 } else if (mem.eql(u8, arg, "--fetch")) {
4698 fetch_only = true;
4695 } else if (mem.startsWith(u8, arg, "-freference-trace=")) {4699 } else if (mem.startsWith(u8, arg, "-freference-trace=")) {
4696 try child_argv.append(arg);4700 try child_argv.append(arg);
4697 const num = arg["-freference-trace=".len..];4701 const num = arg["-freference-trace=".len..];
...@@ -4884,6 +4888,8 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi...@@ -4884,6 +4888,8 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
4884 process.exit(1);4888 process.exit(1);
4885 }4889 }
48864890
4891 if (fetch_only) return cleanExit();
4892
4887 try job_queue.createDependenciesModule(&dependencies_zig_src);4893 try job_queue.createDependenciesModule(&dependencies_zig_src);
48884894
4889 const deps_mod = m: {4895 const deps_mod = m: {