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();...@@ -8,9 +8,6 @@ const InstallDirStep = @This();
88
9step: Step,9step: Step,
10options: Options,10options: 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
15pub const base_id = .install_dir;12pub const base_id = .install_dir;
1613
...@@ -55,7 +52,6 @@ pub fn create(owner: *std.Build, options: Options) *InstallDirStep {...@@ -55,7 +52,6 @@ pub fn create(owner: *std.Build, options: Options) *InstallDirStep {
55 .makeFn = make,52 .makeFn = make,
56 }),53 }),
57 .options = options.dupe(owner),54 .options = options.dupe(owner),
58 .dest_builder = owner,
59 };55 };
60 options.source_dir.addStepDependencies(&self.step);56 options.source_dir.addStepDependencies(&self.step);
61 return self;57 return self;
...@@ -63,15 +59,14 @@ pub fn create(owner: *std.Build, options: Options) *InstallDirStep {...@@ -63,15 +59,14 @@ pub fn create(owner: *std.Build, options: Options) *InstallDirStep {
6359
64fn make(step: *Step, prog_node: *std.Progress.Node) !void {60fn make(step: *Step, prog_node: *std.Progress.Node) !void {
65 _ = prog_node;61 _ = prog_node;
62 const b = step.owner;
66 const self: *InstallDirStep = @fieldParentPtr("step", step);63 const self: *InstallDirStep = @fieldParentPtr("step", step);
67 const dest_builder = self.dest_builder;64 const arena = b.allocator;
68 const arena = dest_builder.allocator;65 const dest_prefix = b.getInstallPath(self.options.install_dir, self.options.install_subdir);
69 const dest_prefix = dest_builder.getInstallPath(self.options.install_dir, self.options.install_subdir);66 const src_dir_path = self.options.source_dir.getPath2(b, step);
70 const src_builder = self.step.owner;67 var src_dir = b.build_root.handle.openDir(src_dir_path, .{ .iterate = true }) catch |err| {
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| {
73 return step.fail("unable to open source directory '{}{s}': {s}", .{68 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),
75 });70 });
76 };71 };
77 defer src_dir.close();72 defer src_dir.close();
...@@ -104,20 +99,20 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -104,20 +99,20 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
104 .file => {99 .file => {
105 for (self.options.blank_extensions) |ext| {100 for (self.options.blank_extensions) |ext| {
106 if (mem.endsWith(u8, entry.path, ext)) {101 if (mem.endsWith(u8, entry.path, ext)) {
107 try dest_builder.truncateFile(dest_path);102 try b.truncateFile(dest_path);
108 continue :next_entry;103 continue :next_entry;
109 }104 }
110 }105 }
111106
112 const prev_status = fs.Dir.updateFile(107 const prev_status = fs.Dir.updateFile(
113 src_builder.build_root.handle,108 b.build_root.handle,
114 src_sub_path,109 src_sub_path,
115 cwd,110 cwd,
116 dest_path,111 dest_path,
117 .{},112 .{},
118 ) catch |err| {113 ) catch |err| {
119 return step.fail("unable to update file from '{}{s}' to '{s}': {s}", .{114 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),
121 });116 });
122 };117 };
123 all_cached = all_cached and prev_status == .fresh;118 all_cached = all_cached and prev_status == .fresh;
lib/std/Build/Step/InstallFile.zig+3-8
...@@ -11,9 +11,6 @@ step: Step,...@@ -11,9 +11,6 @@ step: Step,
11source: LazyPath,11source: LazyPath,
12dir: InstallDir,12dir: InstallDir,
13dest_rel_path: []const u8,13dest_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
18pub fn create(15pub fn create(
19 owner: *std.Build,16 owner: *std.Build,
...@@ -34,7 +31,6 @@ pub fn create(...@@ -34,7 +31,6 @@ pub fn create(
34 .source = source.dupe(owner),31 .source = source.dupe(owner),
35 .dir = dir.dupe(owner),32 .dir = dir.dupe(owner),
36 .dest_rel_path = owner.dupePath(dest_rel_path),33 .dest_rel_path = owner.dupePath(dest_rel_path),
37 .dest_builder = owner,
38 };34 };
39 source.addStepDependencies(&self.step);35 source.addStepDependencies(&self.step);
40 return self;36 return self;
...@@ -42,11 +38,10 @@ pub fn create(...@@ -42,11 +38,10 @@ pub fn create(
4238
43fn make(step: *Step, prog_node: *std.Progress.Node) !void {39fn make(step: *Step, prog_node: *std.Progress.Node) !void {
44 _ = prog_node;40 _ = prog_node;
45 const src_builder = step.owner;41 const b = step.owner;
46 const self: *InstallFile = @fieldParentPtr("step", step);42 const self: *InstallFile = @fieldParentPtr("step", step);
47 const dest_builder = self.dest_builder;43 const full_src_path = self.source.getPath2(b, step);
48 const full_src_path = self.source.getPath2(src_builder, step);44 const full_dest_path = b.getInstallPath(self.dir, self.dest_rel_path);
49 const full_dest_path = dest_builder.getInstallPath(self.dir, self.dest_rel_path);
50 const cwd = std.fs.cwd();45 const cwd = std.fs.cwd();
51 const prev = std.fs.Dir.updateFile(cwd, full_src_path, cwd, full_dest_path, .{}) catch |err| {46 const prev = std.fs.Dir.updateFile(cwd, full_src_path, cwd, full_dest_path, .{}) catch |err| {
52 return step.fail("unable to update file from '{s}' to '{s}': {s}", .{47 return step.fail("unable to update file from '{s}' to '{s}': {s}", .{