@@ -264,8 +264,20 @@ pub const HeaderInstallation = union(enum) {
dest_rel_path: []const u8,
pub fn dupe(self: File, b: *std.Build) File {
// 'path' lazy paths are relative to the build root of some step, inferred from the step
// in which they are used. This means that we can't dupe such paths, because they may
// come from dependencies with their own build roots and duping the paths as is might
// cause the build script to search for the file relative to the wrong root.
// As a temporary workaround, we convert build root-relative paths to absolute paths.
// If/when the build-root relative paths are updated to encode which build root they are
// relative to, this workaround should be removed.
const duped_source: LazyPath = switch (self.source) {
.path => |root_rel| .{ .cwd_relative = b.pathFromRoot(root_rel) },
else => self.source.dupe(b),
};
return .{
.source = self.source.dupe(b),
.source = duped_source,
.dest_rel_path = b.dupePath(self.dest_rel_path),
};
}
@@ -293,8 +305,20 @@ pub const HeaderInstallation = union(enum) {
};
pub fn dupe(self: Directory, b: *std.Build) Directory {
// 'path' lazy paths are relative to the build root of some step, inferred from the step
// in which they are used. This means that we can't dupe such paths, because they may
// come from dependencies with their own build roots and duping the paths as is might
// cause the build script to search for the file relative to the wrong root.
// As a temporary workaround, we convert build root-relative paths to absolute paths.
// If/when the build-root relative paths are updated to encode which build root they are
// relative to, this workaround should be removed.
const duped_source: LazyPath = switch (self.source) {
.path => |root_rel| .{ .cwd_relative = b.pathFromRoot(root_rel) },
else => self.source.dupe(b),
};
return .{
.source = self.source.dupe(b),
.source = duped_source,
.dest_rel_path = b.dupePath(self.dest_rel_path),
.options = self.options.dupe(b),
};
@@ -492,9 +516,8 @@ pub fn installConfigHeader(cs: *Compile, config_header: *Step.ConfigHeader) void
/// module's include search path.
pub fn installLibraryHeaders(cs: *Compile, lib: *Compile) void {
assert(lib.kind == .lib);
const b = cs.step.owner;
for (lib.installed_headers.items) |installation| {
const installation_copy = installation.dupe(b);
const installation_copy = installation.dupe(lib.step.owner);
cs.installed_headers.append(installation_copy) catch @panic("OOM");
cs.addHeaderInstallationToIncludeTree(installation_copy);
installation_copy.getSource().addStepDependencies(&cs.step);