Skip to content

Commit 83924d7

Browse files
committed
std.Build.InstallFileStep: add missing step dependencies
in the creation function, which had to change from init() to create().
1 parent 7a97f4e commit 83924d7

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

lib/std/Build.zig

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

12311226
pub 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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const Step = std.Build.Step;
33
const FileSource = std.Build.FileSource;
44
const InstallDir = std.Build.InstallDir;
55
const InstallFileStep = @This();
6+
const assert = std.debug.assert;
67

78
pub const base_id = .install_file;
89

@@ -14,14 +15,16 @@ dest_rel_path: []const u8,
1415
/// package but is being installed by another.
1516
dest_builder: *std.Build,
1617

17-
pub fn init(
18+
pub 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

3843
fn make(step: *Step, prog_node: *std.Progress.Node) !void {

0 commit comments

Comments
 (0)