std.Build: audit use of updateFile

* remove std.Build.updateFile. I noticed some people use it from
   build.zig (declare phase) when it is intended only for use in the
   make phase.
   - This also was incorrectly reporting errors with std.log.
 * std.Build.InstallArtifactStep
   - report better errors on failure
   - report whether the step was cached or not
 * std.Build.InstallDirStep: report better error on failure
 * std.Build.InstallFileStep: report better error on failure
This commit is contained in:
Andrew Kelley
2023-03-05 16:11:04 -07:00
parent 1e63573d35
commit a4c35a6245
5 changed files with 60 additions and 27 deletions

View File

@@ -42,5 +42,11 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
const dest_builder = self.dest_builder;
const full_src_path = self.source.getPath2(src_builder, step);
const full_dest_path = dest_builder.getInstallPath(self.dir, self.dest_rel_path);
try dest_builder.updateFile(full_src_path, full_dest_path);
const cwd = std.fs.cwd();
const prev = std.fs.Dir.updateFile(cwd, full_src_path, cwd, full_dest_path, .{}) catch |err| {
return step.fail("unable to update file from '{s}' to '{s}': {s}", .{
full_src_path, full_dest_path, @errorName(err),
});
};
step.result_cached = prev == .fresh;
}