diff options
| author | Carl Åstholm <carl@astholm.se> | 2024-03-02 22:59:00 +0100 |
|---|---|---|
| committer | Carl Åstholm <carl@astholm.se> | 2024-04-07 15:32:44 +0200 |
| commit | 0b7123f41d66bdda4da29d59623299d47b29aefb (patch) | |
| tree | e909110b2a031944f20a41a0e44c17ccd37bb1c9 /lib/std/Build/Module.zig | |
| parent | 129de47a71b954b1118ce188f7032ad726491f53 (diff) | |
| download | zig-0b7123f41d66bdda4da29d59623299d47b29aefb.tar.gz zig-0b7123f41d66bdda4da29d59623299d47b29aefb.zip | |
std.Build: correct behavior of `Step.Compile.installHeader`
Previously, `Step.Compile.installHeader` and friends would incorrectly
modify the default `install` top-level step, when the intent was for
headers to get bundled with and installed alongside an artifact. This
change set implements the intended behavior.
This carries with it some breaking changes; `installHeader` and
`installConfigHeader` both have new signatures, and
`installHeadersDirectory` and `installHeadersDirectoryOptions` have been
merged into `installHeaders`.
Diffstat (limited to 'lib/std/Build/Module.zig')
| -rw-r--r-- | lib/std/Build/Module.zig | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/lib/std/Build/Module.zig b/lib/std/Build/Module.zig index 46c6a19578..b8b6560019 100644 --- a/lib/std/Build/Module.zig +++ b/lib/std/Build/Module.zig @@ -265,8 +265,8 @@ fn addShallowDependencies(m: *Module, dependee: *Module) void { for (dependee.link_objects.items) |link_object| switch (link_object) { .other_step => |compile| { addStepDependencies(m, dependee, &compile.step); - for (compile.installed_headers.items) |install_step| - addStepDependenciesOnly(m, install_step); + for (compile.installed_headers.items) |header| + addLazyPathDependenciesOnly(m, header.source.path()); }, .static_path, @@ -691,20 +691,19 @@ pub fn appendZigProcessFlags( }, .other_step => |other| { if (other.generated_h) |header| { - try zig_args.append("-isystem"); - try zig_args.append(std.fs.path.dirname(header.path.?).?); - } - if (other.installed_headers.items.len > 0) { - try zig_args.append("-I"); - try zig_args.append(b.pathJoin(&.{ - other.step.owner.install_prefix, "include", - })); + try zig_args.appendSlice(&.{ "-isystem", std.fs.path.dirname(header.getPath()).? }); } + for (other.installed_headers.items) |header| switch (header.source) { + .file => |lp| { + try zig_args.appendSlice(&.{ "-I", std.fs.path.dirname(lp.getPath2(b, asking_step)).? }); + }, + .directory => |dir| { + try zig_args.appendSlice(&.{ "-I", dir.path.getPath2(b, asking_step) }); + }, + }; }, .config_header_step => |config_header| { - const full_file_path = config_header.output_file.path.?; - const header_dir_path = full_file_path[0 .. full_file_path.len - config_header.include_path.len]; - try zig_args.appendSlice(&.{ "-I", header_dir_path }); + try zig_args.appendSlice(&.{ "-I", std.fs.path.dirname(config_header.output_file.getPath()).? }); }, } } @@ -752,9 +751,8 @@ fn linkLibraryOrObject(m: *Module, other: *Step.Compile) void { m.link_objects.append(allocator, .{ .other_step = other }) catch @panic("OOM"); m.include_dirs.append(allocator, .{ .other_step = other }) catch @panic("OOM"); - for (other.installed_headers.items) |install_step| { - addStepDependenciesOnly(m, install_step); - } + for (other.installed_headers.items) |header| + addLazyPathDependenciesOnly(m, header.source.path()); } fn requireKnownTarget(m: *Module) std.Target { |
