authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-09 22:03:36-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-15 10:48:14-07:00
logf829f848ddc390e6f14e8da3eee452bd7ead5a3a
treee42f5c4f5ba1738cbf8bcc7e730c8744bf68a001
parent2c491d734ee82947b2a77c08c1c5328e7a5fe771

std.Build.InstallFileStep: add missing step dependencies

in the creation function, which had to change from init() to create().

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

lib/std/Build.zig+2-9
...@@ -1220,12 +1220,7 @@ pub fn addInstallFileWithDir(...@@ -1220,12 +1220,7 @@ pub fn addInstallFileWithDir(
1220 install_dir: InstallDir,1220 install_dir: InstallDir,
1221 dest_rel_path: []const u8,1221 dest_rel_path: []const u8,
1222) *InstallFileStep {1222) *InstallFileStep {
1223 if (dest_rel_path.len == 0) {1223 return InstallFileStep.create(self, source.dupe(self), install_dir, dest_rel_path);
1224 panic("dest_rel_path must be non-empty", .{});
1225 }
1226 const install_step = self.allocator.create(InstallFileStep) catch @panic("OOM");
1227 install_step.* = InstallFileStep.init(self, source.dupe(self), install_dir, dest_rel_path);
1228 return install_step;
1229}1224}
12301225
1231pub fn addInstallDirectory(self: *Build, options: InstallDirectoryOptions) *InstallDirStep {1226pub fn addInstallDirectory(self: *Build, options: InstallDirectoryOptions) *InstallDirStep {
...@@ -1685,9 +1680,7 @@ pub const InstallDir = union(enum) {...@@ -1685,9 +1680,7 @@ pub const InstallDir = union(enum) {
1685 /// Duplicates the install directory including the path if set to custom.1680 /// Duplicates the install directory including the path if set to custom.
1686 pub fn dupe(self: InstallDir, builder: *Build) InstallDir {1681 pub fn dupe(self: InstallDir, builder: *Build) InstallDir {
1687 if (self == .custom) {1682 if (self == .custom) {
1688 // Written with this temporary to avoid RLS problems1683 return .{ .custom = builder.dupe(self.custom) };
1689 const duped_path = builder.dupe(self.custom);
1690 return .{ .custom = duped_path };
1691 } else {1684 } else {
1692 return self;1685 return self;
1693 }1686 }
lib/std/Build/InstallFileStep.zig+8-3
...@@ -3,6 +3,7 @@ const Step = std.Build.Step;...@@ -3,6 +3,7 @@ const Step = std.Build.Step;
3const FileSource = std.Build.FileSource;3const FileSource = std.Build.FileSource;
4const InstallDir = std.Build.InstallDir;4const InstallDir = std.Build.InstallDir;
5const InstallFileStep = @This();5const InstallFileStep = @This();
6const assert = std.debug.assert;
67
7pub const base_id = .install_file;8pub const base_id = .install_file;
89
...@@ -14,14 +15,16 @@ dest_rel_path: []const u8,...@@ -14,14 +15,16 @@ dest_rel_path: []const u8,
14/// package but is being installed by another.15/// package but is being installed by another.
15dest_builder: *std.Build,16dest_builder: *std.Build,
1617
17pub fn init(18pub fn create(
18 owner: *std.Build,19 owner: *std.Build,
19 source: FileSource,20 source: FileSource,
20 dir: InstallDir,21 dir: InstallDir,
21 dest_rel_path: []const u8,22 dest_rel_path: []const u8,
22) InstallFileStep {23) *InstallFileStep {
24 assert(dest_rel_path.len != 0);
23 owner.pushInstalledFile(dir, dest_rel_path);25 owner.pushInstalledFile(dir, dest_rel_path);
24 return InstallFileStep{26 const self = owner.allocator.create(InstallFileStep) catch @panic("OOM");
27 self.* = .{
25 .step = Step.init(.{28 .step = Step.init(.{
26 .id = base_id,29 .id = base_id,
27 .name = owner.fmt("install {s} to {s}", .{ source.getDisplayName(), dest_rel_path }),30 .name = owner.fmt("install {s} to {s}", .{ source.getDisplayName(), dest_rel_path }),
...@@ -33,6 +36,8 @@ pub fn init(...@@ -33,6 +36,8 @@ pub fn init(
33 .dest_rel_path = owner.dupePath(dest_rel_path),36 .dest_rel_path = owner.dupePath(dest_rel_path),
34 .dest_builder = owner,37 .dest_builder = owner,
35 };38 };
39 source.addStepDependencies(&self.step);
40 return self;
36}41}
3742
38fn make(step: *Step, prog_node: *std.Progress.Node) !void {43fn make(step: *Step, prog_node: *std.Progress.Node) !void {