diff --git a/build.zig b/build.zig index a422778..413b1b1 100644 --- a/build.zig +++ b/build.zig @@ -39,6 +39,12 @@ const LibreSslLibs = struct { 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( self: LibreSslLibs, b: *std.Build, @@ -59,11 +65,8 @@ const LibreSslLibs = struct { if (std.mem.endsWith(u8, child.basename, ".h")) { const full = b.pathJoin(&.{ base, child.path }); - const path = b.path(full); - self.libcrypto.installHeader(path, child.path); - self.libssl.installHeader(path, child.path); - self.libtls.installHeader(path, child.path); + self.installHeader(path, child.path); } } } @@ -238,14 +241,7 @@ pub fn libresslBuild( else => @panic("unsupported target CPU arch"), }); - const install_conf = b.addInstallHeaderFile(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"); + libressl_libs.installHeader(conf_header, "openssl/opensslconf.h"); try libressl_libs.header_search( b, @@ -289,12 +285,9 @@ 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(.{ .cwd_relative = b.getInstallPath(.header, "") }); - libressl_libs.libssl.addIncludePath(.{ .cwd_relative = b.getInstallPath(.header, "") }); - libressl_libs.libtls.addIncludePath(.{ .cwd_relative = b.getInstallPath(.header, "") }); + const inctree = libressl_libs.libcrypto.getEmittedIncludeTree(); + libressl_libs.libcrypto.step.dependOn(&libressl_libs.libcrypto.installed_headers_include_tree.?.step); + libressl_libs.libcrypto.addIncludePath(inctree); libressl_libs.libssl.linkLibrary(libressl_libs.libcrypto);