build: rename std.Build.*Step to std.Build.Step.*
Follow-up actions from #14647 Fixes #14947
This commit is contained in:
committed by
Veikka Tuominen
parent
855493bb8b
commit
13eb7251d3
57
lib/std/Build/Step/InstallFile.zig
Normal file
57
lib/std/Build/Step/InstallFile.zig
Normal file
@@ -0,0 +1,57 @@
|
||||
const std = @import("std");
|
||||
const Step = std.Build.Step;
|
||||
const FileSource = std.Build.FileSource;
|
||||
const InstallDir = std.Build.InstallDir;
|
||||
const InstallFileStep = @This();
|
||||
const assert = std.debug.assert;
|
||||
|
||||
pub const base_id = .install_file;
|
||||
|
||||
step: Step,
|
||||
source: FileSource,
|
||||
dir: InstallDir,
|
||||
dest_rel_path: []const u8,
|
||||
/// This is used by the build system when a file being installed comes from one
|
||||
/// package but is being installed by another.
|
||||
dest_builder: *std.Build,
|
||||
|
||||
pub fn create(
|
||||
owner: *std.Build,
|
||||
source: FileSource,
|
||||
dir: InstallDir,
|
||||
dest_rel_path: []const u8,
|
||||
) *InstallFileStep {
|
||||
assert(dest_rel_path.len != 0);
|
||||
owner.pushInstalledFile(dir, dest_rel_path);
|
||||
const self = owner.allocator.create(InstallFileStep) catch @panic("OOM");
|
||||
self.* = .{
|
||||
.step = Step.init(.{
|
||||
.id = base_id,
|
||||
.name = owner.fmt("install {s} to {s}", .{ source.getDisplayName(), dest_rel_path }),
|
||||
.owner = owner,
|
||||
.makeFn = make,
|
||||
}),
|
||||
.source = source.dupe(owner),
|
||||
.dir = dir.dupe(owner),
|
||||
.dest_rel_path = owner.dupePath(dest_rel_path),
|
||||
.dest_builder = owner,
|
||||
};
|
||||
source.addStepDependencies(&self.step);
|
||||
return self;
|
||||
}
|
||||
|
||||
fn make(step: *Step, prog_node: *std.Progress.Node) !void {
|
||||
_ = prog_node;
|
||||
const src_builder = step.owner;
|
||||
const self = @fieldParentPtr(InstallFileStep, "step", step);
|
||||
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);
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user