zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 5586a1f4eef7103398c595aed451157a07d15e27 (tree)
parent 98cc059622cd5cad3eef1bbc851437358d259033
Author: Jan200101 <sentrycraft123@gmail.com>
Date:   Sat, 18 Apr 2026 20:58:45 +0200

zig fetch: add option to overwrite the package directory

Diffstat:
Msrc/main.zig | 8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/main.zig b/src/main.zig @@ -7032,6 +7032,7 @@ const usage_fetch = \\Options: \\ -h, --help Print this help and exit \\ --global-cache-dir [path] Override path to global Zig cache directory + \\ --pkg-dir [path] Override path to package directory \\ --debug-hash Print verbose hash information to stdout \\ --save Add the fetched package to build.zig.zon \\ --save=[name] Add the fetched package to build.zig.zon as name @@ -7052,6 +7053,7 @@ fn cmdFetch( const color: Color = .auto; var opt_path_or_url: ?[]const u8 = null; var override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map); + var override_pkg_dir: ?[]const u8 = null; var debug_hash: bool = false; var save: union(enum) { no, @@ -7071,6 +7073,10 @@ fn cmdFetch( if (i + 1 >= args.len) fatal("expected argument after '{s}'", .{arg}); i += 1; override_global_cache_dir = args[i]; + } else if (mem.eql(u8, arg, "--pkg-dir")) { + if (i + 1 >= args.len) fatal("expected argument after '{s}'", .{arg}); + i += 1; + override_pkg_dir = args[i]; } else if (mem.eql(u8, arg, "--debug-hash")) { debug_hash = true; } else if (mem.eql(u8, arg, "--save")) { @@ -7132,7 +7138,7 @@ fn cmdFetch( .local_cache = local_cache_path, .root_pkg_path = .{ .root_dir = build_root.directory, - .sub_path = "zig-pkg", + .sub_path = override_pkg_dir orelse "zig-pkg", }, .recursive = false, .read_only = false,