Compare commits
3 Commits
9679f074d2
...
zig-build
| Author | SHA1 | Date | |
|---|---|---|---|
|
0e1bc3a222
|
|||
|
bb0e7bc98c
|
|||
|
a2e9a8301d
|
46
build.zig
46
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,
|
||||
@@ -58,12 +64,9 @@ const LibreSslLibs = struct {
|
||||
}
|
||||
|
||||
if (std.mem.endsWith(u8, child.basename, ".h")) {
|
||||
const full = try std.mem.concat(b.allocator, u8, &.{ base, child.path });
|
||||
defer b.allocator.free(full);
|
||||
|
||||
self.libcrypto.installHeader(full, child.path);
|
||||
self.libssl.installHeader(full, child.path);
|
||||
self.libtls.installHeader(full, child.path);
|
||||
const full = b.pathJoin(&.{ base, child.path });
|
||||
const path = b.path(full);
|
||||
self.installHeader(path, child.path);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -229,18 +232,16 @@ pub fn libresslBuild(
|
||||
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",
|
||||
.x86 => source_header_prefix ++ "arch/i386/opensslconf.h",
|
||||
.riscv64 => source_header_prefix ++ "arch/riscv64/opensslconf.h",
|
||||
.x86_64 => source_header_prefix ++ "arch/amd64/opensslconf.h",
|
||||
|
||||
else => @panic("unsupported target CPU arch"),
|
||||
};
|
||||
});
|
||||
|
||||
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,
|
||||
@@ -253,15 +254,15 @@ pub fn libresslBuild(
|
||||
);
|
||||
|
||||
for (libcrypto_include_paths) |path| {
|
||||
libressl_libs.libcrypto.addIncludePath(.{ .path = path });
|
||||
libressl_libs.libcrypto.addIncludePath(b.path(path));
|
||||
}
|
||||
|
||||
for (libssl_include_paths) |path| {
|
||||
libressl_libs.libssl.addIncludePath(.{ .path = path });
|
||||
libressl_libs.libssl.addIncludePath(b.path(path));
|
||||
}
|
||||
|
||||
for (libtls_include_paths) |path| {
|
||||
libressl_libs.libtls.addIncludePath(.{ .path = path });
|
||||
libressl_libs.libtls.addIncludePath(b.path(path));
|
||||
}
|
||||
|
||||
switch (tinfo.cpu.arch) {
|
||||
@@ -269,27 +270,24 @@ pub fn libresslBuild(
|
||||
.aarch64_be,
|
||||
.aarch64_32,
|
||||
=> libressl_libs.libcrypto.addIncludePath(
|
||||
.{ .path = libcrypto_src_prefix ++ "bn/arch/aarch64" },
|
||||
b.path(libcrypto_src_prefix ++ "bn/arch/aarch64"),
|
||||
),
|
||||
.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(
|
||||
.{ .path = libcrypto_src_prefix ++ "bn/arch/riscv64" },
|
||||
b.path(libcrypto_src_prefix ++ "bn/arch/riscv64"),
|
||||
),
|
||||
.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"),
|
||||
}
|
||||
|
||||
// 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, "") });
|
||||
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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user