authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-05-20 18:07:51-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-05-25 18:54:36-07:00
log619f23b3c7a5276ab974478223ec41ce81c91b6c
treee4d5b01859781f8c95356bc38643bb160ccbb4fb
parent91a7ea4ff41fd21e7465ddfe68bace533ab8c77d

CLI: support both --fork=[path] and --fork [path]


3 files changed, 24 insertions(+), 15 deletions(-)

lib/compiler/Maker/ScannedConfig.zig+1-1
......@@ -343,7 +343,7 @@ pub fn printUsage(sc: *const ScannedConfig, graph: *Graph, w: *Writer) !void {
343343 \\ --fetch[=mode] Fetch dependency tree (optionally choose laziness) and exit
344344 \\ needed (Default) Lazy dependencies are fetched as needed
345345 \\ all Lazy dependencies are always fetched
346 \\ --fork=[path] Override one or more projects from dependency tree
346 \\ --fork=[path], --fork [path] Override one or more projects from dependency tree
347347 \\
348348 \\Advanced Options:
349349 \\ -freference-trace[=num] How many lines of reference trace should be shown per compile error
lib/compiler/Maker/Step.zig+3-3
......@@ -728,19 +728,19 @@ fn failWithCacheError(
728728 switch (err) {
729729 error.CacheCheckFailed => switch (man.diagnostic) {
730730 .none => unreachable,
731 .manifest_create, .manifest_read, .manifest_lock => |e| return s.fail(maker, "failed to check cache: {t} {t}", .{
731 .manifest_create, .manifest_read, .manifest_lock => |e| return s.fail(maker, "failed checking cache: {t} {t}", .{
732732 man.diagnostic, e,
733733 }),
734734 .file_open, .file_stat, .file_read, .file_hash => |op| {
735735 const pp = man.files.keys()[op.file_index].prefixed_path;
736736 const prefix = man.cache.prefixes()[pp.prefix].path orelse "";
737 return s.fail(maker, "failed to check cache: '{s}{c}{s}' {t} {t}", .{
737 return s.fail(maker, "failed checking cache: {s}{c}{s} {t} {t}", .{
738738 prefix, Dir.path.sep, pp.sub_path, man.diagnostic, op.err,
739739 });
740740 },
741741 },
742742 error.OutOfMemory, error.Canceled => |e| return e,
743 error.InvalidFormat => return s.fail(maker, "failed to check cache: invalid manifest file format", .{}),
743 error.InvalidFormat => return s.fail(maker, "failed checking cache: invalid manifest file format", .{}),
744744 }
745745}
746746
src/main.zig+20-11
......@@ -5082,17 +5082,12 @@ fn cmdBuild(
50825082 fetch_mode = std.meta.stringToEnum(Package.Fetch.JobQueue.Mode, sub_arg) orelse
50835083 fatal("expected [needed|all] after '--fetch=', found '{s}'", .{sub_arg});
50845084 } else if (mem.cutPrefix(u8, arg, "--fork=")) |sub_arg| {
5085 try forks.append(arena, .{
5086 .manifest_ast = undefined,
5087 .manifest = undefined,
5088 .error_bundle = undefined,
5089 .arena_allocator = undefined,
5090 .path = .{
5091 .root_dir = .cwd(),
5092 .sub_path = sub_arg,
5093 },
5094 .failed = false,
5095 });
5085 try forks.append(arena, .init(sub_arg));
5086 continue;
5087 } else if (mem.eql(u8, arg, "--fork")) {
5088 if (i + 1 >= args.len) fatal("expected argument after: {s}", .{arg});
5089 i += 1;
5090 try forks.append(arena, .init(args[i]));
50965091 continue;
50975092 } else if (mem.cutPrefix(u8, arg, "-freference-trace=")) |num| {
50985093 reference_trace = std.fmt.parseUnsigned(u32, num, 10) catch |err| {
......@@ -5874,6 +5869,20 @@ const Fork = struct {
58745869 failed: bool,
58755870 arena_allocator: std.heap.ArenaAllocator,
58765871
5872 fn init(cwd_relative_path: []const u8) Fork {
5873 return .{
5874 .manifest_ast = undefined,
5875 .manifest = undefined,
5876 .error_bundle = undefined,
5877 .arena_allocator = undefined,
5878 .path = .{
5879 .root_dir = .cwd(),
5880 .sub_path = cwd_relative_path,
5881 },
5882 .failed = false,
5883 };
5884 }
5885
58775886 fn load(io: Io, gpa: Allocator, fork: *Fork, color: Color) Io.Cancelable!void {
58785887 loadFallible(io, gpa, fork, color) catch |err| switch (err) {
58795888 error.Canceled => |e| return e,