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`.
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user