aboutsummaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authorEric Joldasov <bratishkaerik@landless-city.net>2024-05-15 18:48:29 +0500
committerAlex Rønne Petersen <alex@alexrp.com>2025-03-26 19:00:33 +0100
commit27c1f2b3a04960d9e8701f420560cc53e8e5f1dd (patch)
tree26c93802f5ede792cb5c1111e8b270a777b5d9d2 /src/main.zig
parentb4b1daf0012c3007b762df31028fa35f5f68bd09 (diff)
downloadzig-27c1f2b3a04960d9e8701f420560cc53e8e5f1dd.tar.gz
zig-27c1f2b3a04960d9e8701f420560cc53e8e5f1dd.zip
zig build: allow to choose "lazy mode" for fetching process
`--fetch` flag now has additional optional parameter, which specifies how lazy dependencies should be fetched: * `needed` — lazy dependencies are fetched only if they are required for current build configuration to work. Default and works same as old `--fetch` flag. * `all` — lazy dependencies are always fetched. If `--system` flag is used after that, it's guaranteed that **any** build configuration will not require additional download of dependencies during build. Helpful for distro packagers and CI systems: https://www.github.com/ziglang/zig/issues/14597#issuecomment-1426827495 If none is passed, behaviour is same as if `needed` was passed. Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig
index 865ce78b47..2687546e41 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -4843,6 +4843,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
var verbose_cimport = false;
var verbose_llvm_cpu_features = false;
var fetch_only = false;
+ var fetch_mode: Package.Fetch.JobQueue.Mode = .needed;
var system_pkg_dir_path: ?[]const u8 = null;
var debug_target: ?[]const u8 = null;
@@ -4924,6 +4925,13 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
reference_trace = 256;
} else if (mem.eql(u8, arg, "--fetch")) {
fetch_only = true;
+ } else if (mem.startsWith(u8, arg, "--fetch=")) {
+ fetch_only = true;
+ const sub_arg = arg["--fetch=".len..];
+ fetch_mode = std.meta.stringToEnum(Package.Fetch.JobQueue.Mode, sub_arg) orelse
+ fatal("expected [needed|all] after '--fetch=', found '{s}'", .{
+ sub_arg,
+ });
} else if (mem.eql(u8, arg, "--system")) {
if (i + 1 >= args.len) fatal("expected argument after '{s}'", .{arg});
i += 1;
@@ -5208,6 +5216,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
.debug_hash = false,
.work_around_btrfs_bug = work_around_btrfs_bug,
.unlazy_set = unlazy_set,
+ .mode = fetch_mode,
};
defer job_queue.deinit();
@@ -7130,6 +7139,7 @@ fn cmdFetch(
.read_only = false,
.debug_hash = debug_hash,
.work_around_btrfs_bug = work_around_btrfs_bug,
+ .mode = .all,
};
defer job_queue.deinit();