authorgravatar for carl@astholm.seCarl Åstholm <carl@astholm.se> 2024-03-02 23:32:01+01:00
committergravatar for carl@astholm.seCarl Åstholm <carl@astholm.se> 2024-04-07 15:34:46+02:00
logff0bec60b73a4698cda39588ec98ef06b0ecb50e
tree360b1c1dad183b3b48e029b8b101bafa08179e6e
parent0b7123f41d66bdda4da29d59623299d47b29aefb

Remove `dest_builder` field from `InstallDir/File`

This is no longer needed after the installed headers refactoring.

2 files changed, 12 insertions(+), 22 deletions(-)

lib/std/Build/Step/InstallDir.zig+9-14
......@@ -8,9 +8,6 @@ const InstallDirStep = @This();
88
99step: Step,
1010options: Options,
11/// This is used by the build system when a file being installed comes from one
12/// package but is being installed by another.
13dest_builder: *std.Build,
1411
1512pub const base_id = .install_dir;
1613
......@@ -55,7 +52,6 @@ pub fn create(owner: *std.Build, options: Options) *InstallDirStep {
5552 .makeFn = make,
5653 }),
5754 .options = options.dupe(owner),
58 .dest_builder = owner,
5955 };
6056 options.source_dir.addStepDependencies(&self.step);
6157 return self;
......@@ -63,15 +59,14 @@ pub fn create(owner: *std.Build, options: Options) *InstallDirStep {
6359
6460fn make(step: *Step, prog_node: *std.Progress.Node) !void {
6561 _ = prog_node;
62 const b = step.owner;
6663 const self: *InstallDirStep = @fieldParentPtr("step", step);
67 const dest_builder = self.dest_builder;
68 const arena = dest_builder.allocator;
69 const dest_prefix = dest_builder.getInstallPath(self.options.install_dir, self.options.install_subdir);
70 const src_builder = self.step.owner;
71 const src_dir_path = self.options.source_dir.getPath2(src_builder, step);
72 var src_dir = src_builder.build_root.handle.openDir(src_dir_path, .{ .iterate = true }) catch |err| {
64 const arena = b.allocator;
65 const dest_prefix = b.getInstallPath(self.options.install_dir, self.options.install_subdir);
66 const src_dir_path = self.options.source_dir.getPath2(b, step);
67 var src_dir = b.build_root.handle.openDir(src_dir_path, .{ .iterate = true }) catch |err| {
7368 return step.fail("unable to open source directory '{}{s}': {s}", .{
74 src_builder.build_root, src_dir_path, @errorName(err),
69 b.build_root, src_dir_path, @errorName(err),
7570 });
7671 };
7772 defer src_dir.close();
......@@ -104,20 +99,20 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
10499 .file => {
105100 for (self.options.blank_extensions) |ext| {
106101 if (mem.endsWith(u8, entry.path, ext)) {
107 try dest_builder.truncateFile(dest_path);
102 try b.truncateFile(dest_path);
108103 continue :next_entry;
109104 }
110105 }
111106
112107 const prev_status = fs.Dir.updateFile(
113 src_builder.build_root.handle,
108 b.build_root.handle,
114109 src_sub_path,
115110 cwd,
116111 dest_path,
117112 .{},
118113 ) catch |err| {
119114 return step.fail("unable to update file from '{}{s}' to '{s}': {s}", .{
120 src_builder.build_root, src_sub_path, dest_path, @errorName(err),
115 b.build_root, src_sub_path, dest_path, @errorName(err),
121116 });
122117 };
123118 all_cached = all_cached and prev_status == .fresh;
lib/std/Build/Step/InstallFile.zig+3-8
......@@ -11,9 +11,6 @@ step: Step,
1111source: LazyPath,
1212dir: InstallDir,
1313dest_rel_path: []const u8,
14/// This is used by the build system when a file being installed comes from one
15/// package but is being installed by another.
16dest_builder: *std.Build,
1714
1815pub fn create(
1916 owner: *std.Build,
......@@ -34,7 +31,6 @@ pub fn create(
3431 .source = source.dupe(owner),
3532 .dir = dir.dupe(owner),
3633 .dest_rel_path = owner.dupePath(dest_rel_path),
37 .dest_builder = owner,
3834 };
3935 source.addStepDependencies(&self.step);
4036 return self;
......@@ -42,11 +38,10 @@ pub fn create(
4238
4339fn make(step: *Step, prog_node: *std.Progress.Node) !void {
4440 _ = prog_node;
45 const src_builder = step.owner;
41 const b = step.owner;
4642 const self: *InstallFile = @fieldParentPtr("step", step);
47 const dest_builder = self.dest_builder;
48 const full_src_path = self.source.getPath2(src_builder, step);
49 const full_dest_path = dest_builder.getInstallPath(self.dir, self.dest_rel_path);
43 const full_src_path = self.source.getPath2(b, step);
44 const full_dest_path = b.getInstallPath(self.dir, self.dest_rel_path);
5045 const cwd = std.fs.cwd();
5146 const prev = std.fs.Dir.updateFile(cwd, full_src_path, cwd, full_dest_path, .{}) catch |err| {
5247 return step.fail("unable to update file from '{s}' to '{s}': {s}", .{