Compare commits
3 Commits
9f74aeb1d2
...
zig-3.8.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
62af702f8d
|
|||
|
353111f2c2
|
|||
|
e95f71abab
|
46
build.zig
46
build.zig
@@ -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);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user