| ... | @@ -381,8 +381,25 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module { | ... | @@ -381,8 +381,25 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module { |
| 381 | | 381 | |
| 382 | const new_file = try arena.create(File); | 382 | const new_file = try arena.create(File); |
| 383 | | 383 | |
| 384 | const digest = Cache.HashHelper.oneShot(generated_builtin_source); | 384 | const bin_digest, const hex_digest = digest: { |
| 385 | const builtin_sub_path = try arena.dupe(u8, "b" ++ std.fs.path.sep_str ++ digest); | 385 | var hasher: Cache.Hasher = Cache.hasher_init; |
| | 386 | hasher.update(generated_builtin_source); |
| | 387 | |
| | 388 | var bin_digest: Cache.BinDigest = undefined; |
| | 389 | hasher.final(&bin_digest); |
| | 390 | |
| | 391 | var hex_digest: Cache.HexDigest = undefined; |
| | 392 | _ = std.fmt.bufPrint( |
| | 393 | &hex_digest, |
| | 394 | "{s}", |
| | 395 | .{std.fmt.fmtSliceHexLower(&bin_digest)}, |
| | 396 | ) catch unreachable; |
| | 397 | |
| | 398 | break :digest .{ bin_digest, hex_digest }; |
| | 399 | }; |
| | 400 | |
| | 401 | const builtin_sub_path = try arena.dupe(u8, "b" ++ std.fs.path.sep_str ++ hex_digest); |
| | 402 | |
| 386 | new.* = .{ | 403 | new.* = .{ |
| 387 | .root = .{ | 404 | .root = .{ |
| 388 | .root_dir = options.global_cache_directory, | 405 | .root_dir = options.global_cache_directory, |
| ... | @@ -429,6 +446,9 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module { | ... | @@ -429,6 +446,9 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module { |
| 429 | .status = .never_loaded, | 446 | .status = .never_loaded, |
| 430 | .mod = new, | 447 | .mod = new, |
| 431 | .root_decl = .none, | 448 | .root_decl = .none, |
| | 449 | // We might as well use this digest for the File `path digest`, since there's a |
| | 450 | // one-to-one correspondence here between distinct paths and distinct contents. |
| | 451 | .path_digest = bin_digest, |
| 432 | }; | 452 | }; |
| 433 | break :b new; | 453 | break :b new; |
| 434 | }; | 454 | }; |