Remove dest_builder field from InstallDir/File

This is no longer needed after the installed headers refactoring.
This commit is contained in:
Carl Åstholm 2024-03-02 23:32:01 +01:00
parent 0b7123f41d
commit ff0bec60b7
2 changed files with 12 additions and 22 deletions

View File

@ -8,9 +8,6 @@ const InstallDirStep = @This();
step: Step,
options: Options,
/// 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 const base_id = .install_dir;
@ -55,7 +52,6 @@ pub fn create(owner: *std.Build, options: Options) *InstallDirStep {
.makeFn = make,
}),
.options = options.dupe(owner),
.dest_builder = owner,
};
options.source_dir.addStepDependencies(&self.step);
return self;
@ -63,15 +59,14 @@ pub fn create(owner: *std.Build, options: Options) *InstallDirStep {
fn make(step: *Step, prog_node: *std.Progress.Node) !void {
_ = prog_node;
const b = step.owner;
const self: *InstallDirStep = @fieldParentPtr("step", step);
const dest_builder = self.dest_builder;
const arena = dest_builder.allocator;
const dest_prefix = dest_builder.getInstallPath(self.options.install_dir, self.options.install_subdir);
const src_builder = self.step.owner;
const src_dir_path = self.options.source_dir.getPath2(src_builder, step);
var src_dir = src_builder.build_root.handle.openDir(src_dir_path, .{ .iterate = true }) catch |err| {
const arena = b.allocator;
const dest_prefix = b.getInstallPath(self.options.install_dir, self.options.install_subdir);
const src_dir_path = self.options.source_dir.getPath2(b, step);
var src_dir = b.build_root.handle.openDir(src_dir_path, .{ .iterate = true }) catch |err| {
return step.fail("unable to open source directory '{}{s}': {s}", .{
src_builder.build_root, src_dir_path, @errorName(err),
b.build_root, src_dir_path, @errorName(err),
});
};
defer src_dir.close();
@ -104,20 +99,20 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
.file => {
for (self.options.blank_extensions) |ext| {
if (mem.endsWith(u8, entry.path, ext)) {
try dest_builder.truncateFile(dest_path);
try b.truncateFile(dest_path);
continue :next_entry;
}
}
const prev_status = fs.Dir.updateFile(
src_builder.build_root.handle,
b.build_root.handle,
src_sub_path,
cwd,
dest_path,
.{},
) catch |err| {
return step.fail("unable to update file from '{}{s}' to '{s}': {s}", .{
src_builder.build_root, src_sub_path, dest_path, @errorName(err),
b.build_root, src_sub_path, dest_path, @errorName(err),
});
};
all_cached = all_cached and prev_status == .fresh;

View File

@ -11,9 +11,6 @@ step: Step,
source: LazyPath,
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,
@ -34,7 +31,6 @@ pub fn create(
.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;
@ -42,11 +38,10 @@ pub fn create(
fn make(step: *Step, prog_node: *std.Progress.Node) !void {
_ = prog_node;
const src_builder = step.owner;
const b = step.owner;
const self: *InstallFile = @fieldParentPtr("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 full_src_path = self.source.getPath2(b, step);
const full_dest_path = b.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}", .{