stage2: add @import and @embedFile to CacheHash

when using `CacheMode.whole`. Also, I verified that `addDepFilePost` is
in fact including the original C source file in addition to the files it
depends on.
This commit is contained in:
Andrew Kelley
2021-12-30 16:42:32 -07:00
parent 67e31807df
commit e36718165c
2 changed files with 77 additions and 3 deletions

View File

@@ -3380,6 +3380,19 @@ pub fn semaFile(mod: *Module, file: *File) SemaError!void {
error.OutOfMemory => return error.OutOfMemory,
error.AnalysisFail => {},
}
if (mod.comp.whole_cache_manifest) |man| {
assert(file.source_loaded);
const resolved_path = try file.pkg.root_src_directory.join(gpa, &.{
file.sub_file_path,
});
errdefer gpa.free(resolved_path);
try man.addFilePostContents(resolved_path, file.source, .{
.size = file.stat_size,
.inode = file.stat_inode,
.mtime = file.stat_mtime,
});
}
} else {
new_decl.analysis = .file_failure;
}
@@ -3836,6 +3849,16 @@ pub fn embedFile(mod: *Module, cur_file: *File, rel_file_path: []const u8) !*Emb
resolved_root_path, resolved_path, sub_file_path, rel_file_path,
});
if (mod.comp.whole_cache_manifest) |man| {
const copied_resolved_path = try gpa.dupe(u8, resolved_path);
errdefer gpa.free(copied_resolved_path);
try man.addFilePostContents(copied_resolved_path, bytes, .{
.size = stat.size,
.inode = stat.inode,
.mtime = stat.mtime,
});
}
keep_resolved_path = true; // It's now owned by embed_table.
gop.value_ptr.* = new_file;
new_file.* = .{