mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
Merge b934e4c937 into 53e615b920
This commit is contained in:
commit
4031538718
4 changed files with 29 additions and 16 deletions
|
|
@ -2306,6 +2306,9 @@ pub const LazyPath = union(enum) {
|
|||
|
||||
/// Applied after `up`.
|
||||
sub_path: []const u8 = "",
|
||||
|
||||
/// If set, the file is hashed only on this suffix, not the full absolute path
|
||||
content_hash_name: ?[]const u8 = null,
|
||||
},
|
||||
|
||||
/// An absolute path or a path relative to the current working directory of
|
||||
|
|
@ -2495,7 +2498,9 @@ pub const LazyPath = union(enum) {
|
|||
}
|
||||
}
|
||||
|
||||
return file_path.join(src_builder.allocator, gen.sub_path) catch @panic("OOM");
|
||||
var item = file_path.join(src_builder.allocator, gen.sub_path) catch @panic("OOM");
|
||||
item.content_hash_name = gen.content_hash_name;
|
||||
return item;
|
||||
},
|
||||
.dependency => |dep| return .{
|
||||
.root_dir = dep.dependency.builder.build_root,
|
||||
|
|
@ -2535,6 +2540,7 @@ pub const LazyPath = union(enum) {
|
|||
.file = gen.file,
|
||||
.up = gen.up,
|
||||
.sub_path = dupePathInner(allocator, gen.sub_path),
|
||||
.content_hash_name = if (gen.content_hash_name) |name| Build.dupeInner(allocator, name) else null,
|
||||
} },
|
||||
.dependency => |dep| .{ .dependency = .{
|
||||
.dependency = dep.dependency,
|
||||
|
|
|
|||
|
|
@ -402,7 +402,7 @@ pub const Manifest = struct {
|
|||
});
|
||||
errdefer gpa.free(resolved_path);
|
||||
const prefixed_path = try m.cache.findPrefixResolved(resolved_path);
|
||||
return addFileInner(m, prefixed_path, handle, max_file_size);
|
||||
return addFileInner(m, prefixed_path, handle, max_file_size, path.content_hash_name);
|
||||
}
|
||||
|
||||
/// Deprecated; use `addFilePath`.
|
||||
|
|
@ -414,10 +414,10 @@ pub const Manifest = struct {
|
|||
const prefixed_path = try self.cache.findPrefix(file_path);
|
||||
errdefer gpa.free(prefixed_path.sub_path);
|
||||
|
||||
return addFileInner(self, prefixed_path, null, max_file_size);
|
||||
return addFileInner(self, prefixed_path, null, max_file_size, null);
|
||||
}
|
||||
|
||||
fn addFileInner(self: *Manifest, prefixed_path: PrefixedPath, handle: ?fs.File, max_file_size: ?usize) usize {
|
||||
fn addFileInner(self: *Manifest, prefixed_path: PrefixedPath, handle: ?fs.File, max_file_size: ?usize, content_hash_name: ?[]const u8) usize {
|
||||
const gop = self.files.getOrPutAssumeCapacityAdapted(prefixed_path, FilesAdapter{});
|
||||
if (gop.found_existing) {
|
||||
self.cache.gpa.free(prefixed_path.sub_path);
|
||||
|
|
@ -434,8 +434,13 @@ pub const Manifest = struct {
|
|||
.handle = handle,
|
||||
};
|
||||
|
||||
if (content_hash_name) |name| {
|
||||
self.hash.add(@as(u8, '?'));
|
||||
self.hash.addBytes(name);
|
||||
} else {
|
||||
self.hash.add(prefixed_path.prefix);
|
||||
self.hash.addBytes(prefixed_path.sub_path);
|
||||
}
|
||||
|
||||
return gop.index;
|
||||
}
|
||||
|
|
@ -713,15 +718,13 @@ pub const Manifest = struct {
|
|||
|
||||
if (file_path.len == 0) return error.InvalidFormat;
|
||||
|
||||
const cache_hash_file = f: {
|
||||
const prefixed_path: PrefixedPath = .{
|
||||
.prefix = prefix,
|
||||
.sub_path = file_path, // expires with file_contents
|
||||
};
|
||||
const cache_hash_file = f: {
|
||||
if (idx < input_file_count) {
|
||||
const file = &self.files.keys()[idx];
|
||||
if (!file.prefixed_path.eql(prefixed_path))
|
||||
return error.InvalidFormat;
|
||||
|
||||
file.stat = .{
|
||||
.size = stat_size,
|
||||
|
|
@ -777,11 +780,13 @@ pub const Manifest = struct {
|
|||
} };
|
||||
return error.CacheCheckFailed;
|
||||
};
|
||||
|
||||
const name_match = pp.eql(prefixed_path);
|
||||
const size_match = actual_stat.size == cache_hash_file.stat.size;
|
||||
const mtime_match = actual_stat.mtime.nanoseconds == cache_hash_file.stat.mtime.nanoseconds;
|
||||
const inode_match = actual_stat.inode == cache_hash_file.stat.inode;
|
||||
|
||||
if (!size_match or !mtime_match or !inode_match) {
|
||||
if (!name_match or !size_match or !mtime_match or !inode_match) {
|
||||
cache_hash_file.stat = .{
|
||||
.size = actual_stat.size,
|
||||
.mtime = actual_stat.mtime,
|
||||
|
|
|
|||
|
|
@ -11,11 +11,13 @@ root_dir: Cache.Directory,
|
|||
/// The path, relative to the root dir, that this `Path` represents.
|
||||
/// Empty string means the root_dir is the path.
|
||||
sub_path: []const u8 = "",
|
||||
content_hash_name: ?[]const u8 = null,
|
||||
|
||||
pub fn clone(p: Path, arena: Allocator) Allocator.Error!Path {
|
||||
return .{
|
||||
.root_dir = try p.root_dir.clone(arena),
|
||||
.sub_path = try arena.dupe(u8, p.sub_path),
|
||||
.content_hash_name = if (p.content_hash_name) |name| try arena.dupe(u8, name) else null,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -315,7 +315,7 @@ pub fn addPrefixedOutputFileArg(
|
|||
run.setName(b.fmt("{s} ({s})", .{ run.step.name, basename }));
|
||||
}
|
||||
|
||||
return .{ .generated = .{ .file = &output.generated_file } };
|
||||
return .{ .generated = .{ .file = &output.generated_file, .content_hash_name = output.basename } };
|
||||
}
|
||||
|
||||
/// Appends an input file to the command line arguments.
|
||||
|
|
@ -908,8 +908,8 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
|
|||
man.hash.addBytes(bytes);
|
||||
},
|
||||
.lazy_path => |lazy_path| {
|
||||
const file_path = lazy_path.getPath2(b, step);
|
||||
_ = try man.addFile(file_path, null);
|
||||
const file_path = lazy_path.getPath3(b, step);
|
||||
_ = try man.addFilePath(file_path, null);
|
||||
},
|
||||
.none => {},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue