| ... | @@ -264,8 +264,20 @@ pub const HeaderInstallation = union(enum) { | ... | @@ -264,8 +264,20 @@ pub const HeaderInstallation = union(enum) { |
| 264 | dest_rel_path: []const u8, | 264 | dest_rel_path: []const u8, |
| 265 | | 265 | |
| 266 | pub fn dupe(self: File, b: *std.Build) File { | 266 | pub fn dupe(self: File, b: *std.Build) File { |
| | 267 | // 'path' lazy paths are relative to the build root of some step, inferred from the step |
| | 268 | // in which they are used. This means that we can't dupe such paths, because they may |
| | 269 | // come from dependencies with their own build roots and duping the paths as is might |
| | 270 | // cause the build script to search for the file relative to the wrong root. |
| | 271 | // As a temporary workaround, we convert build root-relative paths to absolute paths. |
| | 272 | // If/when the build-root relative paths are updated to encode which build root they are |
| | 273 | // relative to, this workaround should be removed. |
| | 274 | const duped_source: LazyPath = switch (self.source) { |
| | 275 | .path => |root_rel| .{ .cwd_relative = b.pathFromRoot(root_rel) }, |
| | 276 | else => self.source.dupe(b), |
| | 277 | }; |
| | 278 | |
| 267 | return .{ | 279 | return .{ |
| 268 | .source = self.source.dupe(b), | 280 | .source = duped_source, |
| 269 | .dest_rel_path = b.dupePath(self.dest_rel_path), | 281 | .dest_rel_path = b.dupePath(self.dest_rel_path), |
| 270 | }; | 282 | }; |
| 271 | } | 283 | } |
| ... | @@ -293,8 +305,20 @@ pub const HeaderInstallation = union(enum) { | ... | @@ -293,8 +305,20 @@ pub const HeaderInstallation = union(enum) { |
| 293 | }; | 305 | }; |
| 294 | | 306 | |
| 295 | pub fn dupe(self: Directory, b: *std.Build) Directory { | 307 | pub fn dupe(self: Directory, b: *std.Build) Directory { |
| | 308 | // 'path' lazy paths are relative to the build root of some step, inferred from the step |
| | 309 | // in which they are used. This means that we can't dupe such paths, because they may |
| | 310 | // come from dependencies with their own build roots and duping the paths as is might |
| | 311 | // cause the build script to search for the file relative to the wrong root. |
| | 312 | // As a temporary workaround, we convert build root-relative paths to absolute paths. |
| | 313 | // If/when the build-root relative paths are updated to encode which build root they are |
| | 314 | // relative to, this workaround should be removed. |
| | 315 | const duped_source: LazyPath = switch (self.source) { |
| | 316 | .path => |root_rel| .{ .cwd_relative = b.pathFromRoot(root_rel) }, |
| | 317 | else => self.source.dupe(b), |
| | 318 | }; |
| | 319 | |
| 296 | return .{ | 320 | return .{ |
| 297 | .source = self.source.dupe(b), | 321 | .source = duped_source, |
| 298 | .dest_rel_path = b.dupePath(self.dest_rel_path), | 322 | .dest_rel_path = b.dupePath(self.dest_rel_path), |
| 299 | .options = self.options.dupe(b), | 323 | .options = self.options.dupe(b), |
| 300 | }; | 324 | }; |
| ... | @@ -492,9 +516,8 @@ pub fn installConfigHeader(cs: *Compile, config_header: *Step.ConfigHeader) void | ... | @@ -492,9 +516,8 @@ pub fn installConfigHeader(cs: *Compile, config_header: *Step.ConfigHeader) void |
| 492 | /// module's include search path. | 516 | /// module's include search path. |
| 493 | pub fn installLibraryHeaders(cs: *Compile, lib: *Compile) void { | 517 | pub fn installLibraryHeaders(cs: *Compile, lib: *Compile) void { |
| 494 | assert(lib.kind == .lib); | 518 | assert(lib.kind == .lib); |
| 495 | const b = cs.step.owner; | | |
| 496 | for (lib.installed_headers.items) |installation| { | 519 | for (lib.installed_headers.items) |installation| { |
| 497 | const installation_copy = installation.dupe(b); | 520 | const installation_copy = installation.dupe(lib.step.owner); |
| 498 | cs.installed_headers.append(installation_copy) catch @panic("OOM"); | 521 | cs.installed_headers.append(installation_copy) catch @panic("OOM"); |
| 499 | cs.addHeaderInstallationToIncludeTree(installation_copy); | 522 | cs.addHeaderInstallationToIncludeTree(installation_copy); |
| 500 | installation_copy.getSource().addStepDependencies(&cs.step); | 523 | installation_copy.getSource().addStepDependencies(&cs.step); |