mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
std.Build: make cache_root and global_cache_root relative to cwd
This makes it so that when there is a tree of std.Build objects, only one zig-cache is used (the top-level application) instead of polluting package directories with zig-cache folders.
This commit is contained in:
parent
d97042ad2e
commit
3f8f63b132
3 changed files with 5 additions and 6 deletions
|
|
@ -49,12 +49,12 @@ pub fn main() !void {
|
|||
};
|
||||
|
||||
const local_cache_directory: std.Build.Cache.Directory = .{
|
||||
.path = try std.fs.path.relative(allocator, build_root, cache_root),
|
||||
.path = cache_root,
|
||||
.handle = try std.fs.cwd().makeOpenPath(cache_root, .{}),
|
||||
};
|
||||
|
||||
const global_cache_directory: std.Build.Cache.Directory = .{
|
||||
.path = try std.fs.path.relative(allocator, build_root, global_cache_root),
|
||||
.path = global_cache_root,
|
||||
.handle = try std.fs.cwd().makeOpenPath(global_cache_root, .{}),
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1644,7 +1644,6 @@ pub const GeneratedFile = struct {
|
|||
};
|
||||
|
||||
/// A file source is a reference to an existing or future file.
|
||||
///
|
||||
pub const FileSource = union(enum) {
|
||||
/// A plain file path, relative to build root or absolute.
|
||||
path: []const u8,
|
||||
|
|
|
|||
|
|
@ -1350,10 +1350,10 @@ fn make(step: *Step) !void {
|
|||
}
|
||||
|
||||
try zig_args.append("--cache-dir");
|
||||
try zig_args.append(builder.pathFromRoot(builder.cache_root.path orelse "."));
|
||||
try zig_args.append(builder.cache_root.path orelse ".");
|
||||
|
||||
try zig_args.append("--global-cache-dir");
|
||||
try zig_args.append(builder.pathFromRoot(builder.global_cache_root.path orelse "."));
|
||||
try zig_args.append(builder.global_cache_root.path orelse ".");
|
||||
|
||||
try zig_args.append("--name");
|
||||
try zig_args.append(self.name);
|
||||
|
|
@ -1786,7 +1786,7 @@ fn make(step: *Step) !void {
|
|||
|
||||
const resolved_args_file = try mem.concat(builder.allocator, u8, &.{
|
||||
"@",
|
||||
builder.pathFromRoot(try builder.cache_root.join(builder.allocator, &.{args_file})),
|
||||
try builder.cache_root.join(builder.allocator, &.{args_file}),
|
||||
});
|
||||
|
||||
zig_args.shrinkRetainingCapacity(2);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue