3 Commits

Author SHA1 Message Date
62af702f8d 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.
2024-06-18 20:36:36 -07:00
353111f2c2 build: update for zig-0.13.0 release
Deprecated LazyPath fields were removed. This would have been the
correct non-lazy (irony intended?) way of updating for zig 0.12 as
well, and indeed this build works with zig-0.12.1.
2024-06-17 23:15:58 -07:00
e95f71abab build: update for zig-0.12.0 release
Minor fixes for the header installation.
2024-05-12 23:42:48 -07:00

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,
@@ -58,12 +64,9 @@ const LibreSslLibs = struct {
} }
if (std.mem.endsWith(u8, child.basename, ".h")) { if (std.mem.endsWith(u8, child.basename, ".h")) {
const full = try std.mem.concat(b.allocator, u8, &.{ base, child.path }); const full = b.pathJoin(&.{ base, child.path });
defer b.allocator.free(full); const path = b.path(full);
self.installHeader(path, child.path);
self.libcrypto.installHeader(full, child.path);
self.libssl.installHeader(full, child.path);
self.libtls.installHeader(full, child.path);
} }
} }
} }
@@ -229,18 +232,16 @@ pub fn libresslBuild(
else => @panic("unsupported target OS"), else => @panic("unsupported target OS"),
} }
const conf_header = switch (tinfo.cpu.arch) { const conf_header = b.path(switch (tinfo.cpu.arch) {
.aarch64, .aarch64_be, .aarch64_32 => source_header_prefix ++ "arch/aarch64/opensslconf.h", .aarch64, .aarch64_be, .aarch64_32 => source_header_prefix ++ "arch/aarch64/opensslconf.h",
.x86 => source_header_prefix ++ "arch/i386/opensslconf.h", .x86 => source_header_prefix ++ "arch/i386/opensslconf.h",
.riscv64 => source_header_prefix ++ "arch/riscv64/opensslconf.h", .riscv64 => source_header_prefix ++ "arch/riscv64/opensslconf.h",
.x86_64 => source_header_prefix ++ "arch/amd64/opensslconf.h", .x86_64 => source_header_prefix ++ "arch/amd64/opensslconf.h",
else => @panic("unsupported target CPU arch"), else => @panic("unsupported target CPU arch"),
}; });
libressl_libs.libcrypto.installHeader(conf_header, "openssl/opensslconf.h"); libressl_libs.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,
@@ -253,15 +254,15 @@ pub fn libresslBuild(
); );
for (libcrypto_include_paths) |path| { for (libcrypto_include_paths) |path| {
libressl_libs.libcrypto.addIncludePath(.{ .path = path }); libressl_libs.libcrypto.addIncludePath(b.path(path));
} }
for (libssl_include_paths) |path| { for (libssl_include_paths) |path| {
libressl_libs.libssl.addIncludePath(.{ .path = path }); libressl_libs.libssl.addIncludePath(b.path(path));
} }
for (libtls_include_paths) |path| { for (libtls_include_paths) |path| {
libressl_libs.libtls.addIncludePath(.{ .path = path }); libressl_libs.libtls.addIncludePath(b.path(path));
} }
switch (tinfo.cpu.arch) { switch (tinfo.cpu.arch) {
@@ -269,27 +270,24 @@ pub fn libresslBuild(
.aarch64_be, .aarch64_be,
.aarch64_32, .aarch64_32,
=> libressl_libs.libcrypto.addIncludePath( => libressl_libs.libcrypto.addIncludePath(
.{ .path = libcrypto_src_prefix ++ "bn/arch/aarch64" }, b.path(libcrypto_src_prefix ++ "bn/arch/aarch64"),
), ),
.x86 => libressl_libs.libcrypto.addIncludePath( .x86 => libressl_libs.libcrypto.addIncludePath(
.{ .path = libcrypto_src_prefix ++ "bn/arch/i386" }, b.path(libcrypto_src_prefix ++ "bn/arch/i386"),
), ),
.riscv64 => libressl_libs.libcrypto.addIncludePath( .riscv64 => libressl_libs.libcrypto.addIncludePath(
.{ .path = libcrypto_src_prefix ++ "bn/arch/riscv64" }, b.path(libcrypto_src_prefix ++ "bn/arch/riscv64"),
), ),
.x86_64 => libressl_libs.libcrypto.addIncludePath( .x86_64 => libressl_libs.libcrypto.addIncludePath(
.{ .path = libcrypto_src_prefix ++ "bn/arch/amd64" }, b.path(libcrypto_src_prefix ++ "bn/arch/amd64"),
), ),
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(.{ .path = b.getInstallPath(.header, "") });
libressl_libs.libssl.addIncludePath(.{ .path = b.getInstallPath(.header, "") });
libressl_libs.libtls.addIncludePath(.{ .path = b.getInstallPath(.header, "") });
libressl_libs.libssl.linkLibrary(libressl_libs.libcrypto); libressl_libs.libssl.linkLibrary(libressl_libs.libcrypto);