Skip to content

Commit a605bd9

Browse files
committed
zig build: add --fetch argument
closes #14280
1 parent b2fefc8 commit a605bd9

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/build_runner.zig

+1
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,7 @@ fn usage(builder: *std.Build, already_ran_build: bool, out_stream: anytype) !voi
997997
\\ -j<N> Limit concurrent jobs (default is to use all CPU cores)
998998
\\ --maxrss <bytes> Limit memory usage (default is to use available memory)
999999
\\ --skip-oom-steps Instead of failing, skip steps that would exceed --maxrss
1000+
\\ --fetch Exit after fetching dependency tree
10001001
\\
10011002
\\Project-Specific Options:
10021003
\\

src/main.zig

+6
Original file line numberDiff line numberDiff line change
@@ -4621,6 +4621,7 @@ pub const usage_build =
46214621
\\ --global-cache-dir [path] Override path to global Zig cache directory
46224622
\\ --zig-lib-dir [arg] Override path to Zig lib directory
46234623
\\ --build-runner [file] Override path to build runner
4624+
\\ --fetch Exit after fetching dependency tree
46244625
\\ -h, --help Print this help and exit
46254626
\\
46264627
;
@@ -4643,6 +4644,7 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
46434644
var child_argv = std.ArrayList([]const u8).init(arena);
46444645
var reference_trace: ?u32 = null;
46454646
var debug_compile_errors = false;
4647+
var fetch_only = false;
46464648

46474649
const argv_index_exe = child_argv.items.len;
46484650
_ = try child_argv.addOne();
@@ -4692,6 +4694,8 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
46924694
} else if (mem.eql(u8, arg, "-freference-trace")) {
46934695
try child_argv.append(arg);
46944696
reference_trace = 256;
4697+
} else if (mem.eql(u8, arg, "--fetch")) {
4698+
fetch_only = true;
46954699
} else if (mem.startsWith(u8, arg, "-freference-trace=")) {
46964700
try child_argv.append(arg);
46974701
const num = arg["-freference-trace=".len..];
@@ -4884,6 +4888,8 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
48844888
process.exit(1);
48854889
}
48864890

4891+
if (fetch_only) return cleanExit();
4892+
48874893
try job_queue.createDependenciesModule(&dependencies_zig_src);
48884894

48894895
const deps_mod = m: {

0 commit comments

Comments
 (0)