build: out-kludge the installed header include kludge

This is a, erm, beautiful(?) mess. I feel like there probably ought to
be a better way to handle this use case, but the way that the includes
are handled in this specific codebase are extremely weird (how many
times have you actually seen #include_next get used?). It may be worth
making this a more natural path to take, though.
This commit is contained in:
torque 2024-06-18 20:36:36 -07:00
parent bb0e7bc98c
commit 0e1bc3a222
Signed by: torque
SSH Key Fingerprint: SHA256:nCrXefBNo6EbjNSQhv0nXmEg/VuNq3sMF5b8zETw3Tk

View File

@ -39,6 +39,12 @@ const LibreSslLibs = struct {
b.installArtifact(self.libtls); b.installArtifact(self.libtls);
} }
pub fn installHeader(self: LibreSslLibs, source: std.Build.LazyPath, dest: []const u8) void {
self.libcrypto.installHeader(source, dest);
self.libssl.installHeader(source, dest);
self.libtls.installHeader(source, dest);
}
pub fn header_search( pub fn header_search(
self: LibreSslLibs, self: LibreSslLibs,
b: *std.Build, b: *std.Build,
@ -59,11 +65,8 @@ const LibreSslLibs = struct {
if (std.mem.endsWith(u8, child.basename, ".h")) { if (std.mem.endsWith(u8, child.basename, ".h")) {
const full = b.pathJoin(&.{ base, child.path }); const full = b.pathJoin(&.{ base, child.path });
const path = b.path(full); const path = b.path(full);
self.libcrypto.installHeader(path, child.path); self.installHeader(path, child.path);
self.libssl.installHeader(path, child.path);
self.libtls.installHeader(path, child.path);
} }
} }
} }
@ -238,14 +241,7 @@ pub fn libresslBuild(
else => @panic("unsupported target CPU arch"), else => @panic("unsupported target CPU arch"),
}); });
const install_conf = b.addInstallHeaderFile(conf_header, "openssl/opensslconf.h"); libressl_libs.installHeader(conf_header, "openssl/opensslconf.h");
libressl_libs.libcrypto.step.dependOn(&install_conf.step);
libressl_libs.libssl.step.dependOn(&install_conf.step);
libressl_libs.libtls.step.dependOn(&install_conf.step);
libressl_libs.libcrypto.installHeader(conf_header, "openssl/opensslconf.h");
libressl_libs.libssl.installHeader(conf_header, "openssl/opensslconf.h");
libressl_libs.libtls.installHeader(conf_header, "openssl/opensslconf.h");
try libressl_libs.header_search( try libressl_libs.header_search(
b, b,
@ -289,12 +285,9 @@ pub fn libresslBuild(
else => @panic("unsupported target CPU arch"), else => @panic("unsupported target CPU arch"),
} }
// add the header install path to the include path so that compilation will pick const inctree = libressl_libs.libcrypto.getEmittedIncludeTree();
// up "openssl/opensslconf.h". This is added last to avoid interfering with the libressl_libs.libcrypto.step.dependOn(&libressl_libs.libcrypto.installed_headers_include_tree.?.step);
// somewhat messy include handling that libressl does. libressl_libs.libcrypto.addIncludePath(inctree);
libressl_libs.libcrypto.addIncludePath(.{ .cwd_relative = b.getInstallPath(.header, "") });
libressl_libs.libssl.addIncludePath(.{ .cwd_relative = b.getInstallPath(.header, "") });
libressl_libs.libtls.addIncludePath(.{ .cwd_relative = b.getInstallPath(.header, "") });
libressl_libs.libssl.linkLibrary(libressl_libs.libcrypto); libressl_libs.libssl.linkLibrary(libressl_libs.libcrypto);