diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-12-30 16:42:32 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-01-02 13:16:17 -0700 |
| commit | e36718165cdc29b777392a3a343d92ccd1c6acf3 (patch) | |
| tree | c174fc245cbc9170730a0cbe57a5f24f3565f7b6 /src/Module.zig | |
| parent | 67e31807df73ad2da992293fcdf1f6ea7ca67d2a (diff) | |
| download | zig-e36718165cdc29b777392a3a343d92ccd1c6acf3.tar.gz zig-e36718165cdc29b777392a3a343d92ccd1c6acf3.zip | |
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.
Diffstat (limited to 'src/Module.zig')
| -rw-r--r-- | src/Module.zig | 23 |
1 files changed, 23 insertions, 0 deletions
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.* = .{ |
