std.Build: start using the cache system with RunStep

* Use std.Build.Cache.Directory instead of a string for storing the
   cache roots and build roots.
 * Set up a std.Build.Cache in build_runner.zig and use it in
   std.Build.RunStep for avoiding redundant work.
This commit is contained in:
Andrew Kelley
2023-02-09 10:01:01 -07:00
parent 0666322614
commit d97042ad2e
9 changed files with 198 additions and 117 deletions

View File

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