Skip to content

Commit

Permalink
zig build: add --fetch argument
Browse files Browse the repository at this point in the history
closes #14280
  • Loading branch information
andrewrk committed Oct 8, 2023
1 parent b2fefc8 commit a605bd9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/build_runner.zig
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,7 @@ fn usage(builder: *std.Build, already_ran_build: bool, out_stream: anytype) !voi
\\ -j<N> Limit concurrent jobs (default is to use all CPU cores)
\\ --maxrss <bytes> Limit memory usage (default is to use available memory)
\\ --skip-oom-steps Instead of failing, skip steps that would exceed --maxrss
\\ --fetch Exit after fetching dependency tree
\\
\\Project-Specific Options:
\\
Expand Down
6 changes: 6 additions & 0 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4621,6 +4621,7 @@ pub const usage_build =
\\ --global-cache-dir [path] Override path to global Zig cache directory
\\ --zig-lib-dir [arg] Override path to Zig lib directory
\\ --build-runner [file] Override path to build runner
\\ --fetch Exit after fetching dependency tree
\\ -h, --help Print this help and exit
\\
;
Expand All @@ -4643,6 +4644,7 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
var child_argv = std.ArrayList([]const u8).init(arena);
var reference_trace: ?u32 = null;
var debug_compile_errors = false;
var fetch_only = false;

const argv_index_exe = child_argv.items.len;
_ = try child_argv.addOne();
Expand Down Expand Up @@ -4692,6 +4694,8 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
} else if (mem.eql(u8, arg, "-freference-trace")) {
try child_argv.append(arg);
reference_trace = 256;
} else if (mem.eql(u8, arg, "--fetch")) {
fetch_only = true;
} else if (mem.startsWith(u8, arg, "-freference-trace=")) {
try child_argv.append(arg);
const num = arg["-freference-trace=".len..];
Expand Down Expand Up @@ -4884,6 +4888,8 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
process.exit(1);
}

if (fetch_only) return cleanExit();

try job_queue.createDependenciesModule(&dependencies_zig_src);

const deps_mod = m: {
Expand Down

0 comments on commit a605bd9

Please sign in to comment.