std.build.WriteFileStep: fix regression in this branch

This branch makes WriteFileStep use the same hashing algorithm as our
cache system, reducing the divergence between zig build and the cache
system.
This commit is contained in:
Andrew Kelley 2023-01-07 19:07:24 -07:00
parent 01e34c1cd9
commit c53a556a61
2 changed files with 3 additions and 5 deletions

View File

@ -135,7 +135,6 @@ fn make(step: *Step) !void {
self.output_dir = try std.fs.path.join(gpa, &[_][]const u8{
self.builder.cache_root, "o", &hash_basename,
});
var dir = std.fs.cwd().makeOpenPath(self.output_dir, .{}) catch |err| {
std.debug.print("unable to make path {s}: {s}\n", .{ self.output_dir, @errorName(err) });
return err;

View File

@ -82,16 +82,15 @@ fn make(step: *Step) !void {
}
var digest: [16]u8 = undefined;
hash.final(&digest);
var hash_basename: [64]u8 = undefined;
var hash_basename: [digest.len * 2]u8 = undefined;
_ = std.fmt.bufPrint(
&hash_basename,
"{s}",
.{std.fmt.fmtSliceHexLower(&digest)},
) catch unreachable;
self.output_dir = try fs.path.join(self.builder.allocator, &[_][]const u8{
self.builder.cache_root,
"o",
&hash_basename,
self.builder.cache_root, "o", &hash_basename,
});
var dir = fs.cwd().makeOpenPath(self.output_dir, .{}) catch |err| {
std.debug.print("unable to make path {s}: {s}\n", .{ self.output_dir, @errorName(err) });