From e36718165cdc29b777392a3a343d92ccd1c6acf3 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 30 Dec 2021 16:42:32 -0700 Subject: 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. --- src/Module.zig | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/Module.zig') diff --git a/src/Module.zig b/src/Module.zig index fa79783c6a..6742ddd486 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -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.* = .{ -- cgit v1.2.3