From 26399b5249cbc8774e50856fed6d2336e396cb69 Mon Sep 17 00:00:00 2001 From: antlilja Date: Tue, 1 Dec 2020 16:47:47 +0100 Subject: Added global-cache argument to build system + removed extra args. * Field global_cache_root was added to Builder struct along with mandatory argument for build_runner.zig. Logic for using the custom global cache was also added. * The arguments --cache-dir and --global-cache-dir are no longer passed directly through to build_runner.zig and are instead only passed through the mandatory cache_root and global_cache_root arguments. --- src/main.zig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main.zig b/src/main.zig index af342e523f..396bbe02c0 100644 --- a/src/main.zig +++ b/src/main.zig @@ -2260,6 +2260,9 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v const argv_index_cache_dir = child_argv.items.len; _ = try child_argv.addOne(); + const argv_index_global_cache_dir = child_argv.items.len; + _ = try child_argv.addOne(); + { var i: usize = 0; while (i < args.len) : (i += 1) { @@ -2280,13 +2283,11 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v if (i + 1 >= args.len) fatal("expected argument after '{}'", .{arg}); i += 1; override_local_cache_dir = args[i]; - try child_argv.appendSlice(&[_][]const u8{ arg, args[i] }); continue; } else if (mem.eql(u8, arg, "--global-cache-dir")) { if (i + 1 >= args.len) fatal("expected argument after '{}'", .{arg}); i += 1; override_global_cache_dir = args[i]; - try child_argv.appendSlice(&[_][]const u8{ arg, args[i] }); continue; } } @@ -2371,6 +2372,8 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v }; defer global_cache_directory.handle.close(); + child_argv.items[argv_index_global_cache_dir] = global_cache_directory.path orelse cwd_path; + var local_cache_directory: Compilation.Directory = l: { if (override_local_cache_dir) |local_cache_dir_path| { break :l .{ -- cgit v1.2.3