From 401b23c930c93f158c7dc6a6a6032dbe185be768 Mon Sep 17 00:00:00 2001 From: torque Date: Mon, 15 Jan 2024 15:28:44 -0800 Subject: [PATCH] build: handle architecture include more gracefully The "openssl/opensslconf.h" header is copied from an architecture-specific source file, which means that specific path is not valid within the source tree. I previously hacked around this by copying the file within the source tree, but that had the major downside of invalidating various cache layers after the copy was performed. Since we install this header with the right name, a slightly better solution, hopefully, is to add the header install path as an include directory. In theory, this will not invalidate any caching and improve the build process slightly. --- build.zig | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/build.zig b/build.zig index d926b32..d8adca3 100644 --- a/build.zig +++ b/build.zig @@ -243,13 +243,6 @@ pub fn libresslBuild( else => @panic("unsupported target CPU arch"), }; - try b.build_root.handle.copyFile( - conf_header, - b.build_root.handle, - source_header_prefix ++ "openssl/opensslconf.h", - .{}, - ); - 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"); @@ -296,6 +289,13 @@ pub fn libresslBuild( else => @panic("unsupported target CPU arch"), } + // add the header install path to the include path so that compilation will pick + // up "openssl/opensslconf.h". This is added last to avoid interfering with the + // somewhat messy include handling that libressl does. + 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); // cmake builds libtls with libcrypto and libssl symbols jammed into it. However,