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(
12201220 install_dir: InstallDir,
12211221 dest_rel_path: []const u8,
12221222) *InstallFileStep {
1223 if (dest_rel_path.len == 0) {
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;
1223 return InstallFileStep.create(self, source.dupe(self), install_dir, dest_rel_path);
12291224}
12301225
12311226pub fn addInstallDirectory(self: *Build, options: InstallDirectoryOptions) *InstallDirStep {
......@@ -1685,9 +1680,7 @@ pub const InstallDir = union(enum) {
16851680 /// Duplicates the install directory including the path if set to custom.
16861681 pub fn dupe(self: InstallDir, builder: *Build) InstallDir {
16871682 if (self == .custom) {
1688 // Written with this temporary to avoid RLS problems
1689 const duped_path = builder.dupe(self.custom);
1690 return .{ .custom = duped_path };
1683 return .{ .custom = builder.dupe(self.custom) };
16911684 } else {
16921685 return self;
16931686 }
lib/std/Build/InstallFileStep.zig+8-3
......@@ -3,6 +3,7 @@ const Step = std.Build.Step;
33const FileSource = std.Build.FileSource;
44const InstallDir = std.Build.InstallDir;
55const InstallFileStep = @This();
6const assert = std.debug.assert;
67
78pub const base_id = .install_file;
89
......@@ -14,14 +15,16 @@ dest_rel_path: []const u8,
1415/// package but is being installed by another.
1516dest_builder: *std.Build,
1617
17pub fn init(
18pub fn create(
1819 owner: *std.Build,
1920 source: FileSource,
2021 dir: InstallDir,
2122 dest_rel_path: []const u8,
22) InstallFileStep {
23) *InstallFileStep {
24 assert(dest_rel_path.len != 0);
2325 owner.pushInstalledFile(dir, dest_rel_path);
24 return InstallFileStep{
26 const self = owner.allocator.create(InstallFileStep) catch @panic("OOM");
27 self.* = .{
2528 .step = Step.init(.{
2629 .id = base_id,
2730 .name = owner.fmt("install {s} to {s}", .{ source.getDisplayName(), dest_rel_path }),
......@@ -33,6 +36,8 @@ pub fn init(
3336 .dest_rel_path = owner.dupePath(dest_rel_path),
3437 .dest_builder = owner,
3538 };
39 source.addStepDependencies(&self.step);
40 return self;
3641}
3742
3843fn make(step: *Step, prog_node: *std.Progress.Node) !void {