build: add libsodium support
Some checks are pending
CI / build (macos-latest, 0.13.0) (push) Waiting to run
CI / build (true, ubuntu-latest, master) (push) Waiting to run
CI / build (ubuntu-latest, 0.12.1) (push) Waiting to run
CI / build (ubuntu-latest, 0.13.0) (push) Waiting to run
CI / build (windows-latest, 0.13.0) (push) Waiting to run
Some checks are pending
CI / build (macos-latest, 0.13.0) (push) Waiting to run
CI / build (true, ubuntu-latest, master) (push) Waiting to run
CI / build (ubuntu-latest, 0.12.1) (push) Waiting to run
CI / build (ubuntu-latest, 0.13.0) (push) Waiting to run
CI / build (windows-latest, 0.13.0) (push) Waiting to run
This commit is contained in:
parent
7bd3a8ef51
commit
169fae7f02
16
build.zig
16
build.zig
@ -4,6 +4,7 @@ pub fn build(b: *std.Build) void {
|
|||||||
const target = b.standardTargetOptions(.{});
|
const target = b.standardTargetOptions(.{});
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
|
|
||||||
|
const enable_libsodium = b.option(bool, "enable-libsodium", "Build with libsodium for higher-performance signing (default: true)") orelse true;
|
||||||
const enable_tls = b.option(bool, "enable-tls", "Build TLS support (default: true)") orelse true;
|
const enable_tls = b.option(bool, "enable-tls", "Build TLS support (default: true)") orelse true;
|
||||||
const tls_verify = b.option(bool, "force-host-verify", "Force hostname verification for TLS connections (default: true)") orelse true;
|
const tls_verify = b.option(bool, "force-host-verify", "Force hostname verification for TLS connections (default: true)") orelse true;
|
||||||
const enable_streaming = b.option(bool, "enable-streaming", "Build with streaming support (default: true)") orelse true;
|
const enable_streaming = b.option(bool, "enable-streaming", "Build with streaming support (default: true)") orelse true;
|
||||||
@ -17,6 +18,15 @@ pub fn build(b: *std.Build) void {
|
|||||||
"protobuf_c",
|
"protobuf_c",
|
||||||
.{ .target = target, .optimize = optimize },
|
.{ .target = target, .optimize = optimize },
|
||||||
) else null;
|
) else null;
|
||||||
|
const libsodium_dep = if (enable_libsodium) b.lazyDependency(
|
||||||
|
"libsodium",
|
||||||
|
.{
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
|
.static = true,
|
||||||
|
.shared = false,
|
||||||
|
},
|
||||||
|
) else null;
|
||||||
|
|
||||||
const lib = b.addStaticLibrary(.{
|
const lib = b.addStaticLibrary(.{
|
||||||
.name = "nats",
|
.name = "nats",
|
||||||
@ -100,6 +110,12 @@ pub fn build(b: *std.Build) void {
|
|||||||
lib.linkLibrary(dep.artifact("protobuf_c"));
|
lib.linkLibrary(dep.artifact("protobuf_c"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (libsodium_dep) |dep| {
|
||||||
|
lib.defineCMacro("NATS_USE_LIBSODIUM", null);
|
||||||
|
// yep
|
||||||
|
lib.linkLibrary(dep.artifact(if (tinfo.isMinGW()) "libsodium-static" else "sodium"));
|
||||||
|
}
|
||||||
|
|
||||||
b.installArtifact(lib);
|
b.installArtifact(lib);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,11 @@
|
|||||||
.hash = "1220f454bf9412333c5d21b8c21b323fc7e4e37b02341bf2fa49f110b8bc5d97c972",
|
.hash = "1220f454bf9412333c5d21b8c21b323fc7e4e37b02341bf2fa49f110b8bc5d97c972",
|
||||||
.lazy = true,
|
.lazy = true,
|
||||||
},
|
},
|
||||||
|
.libsodium = .{
|
||||||
|
.url = "git+https://github.com/jedisct1/libsodium.git?ref=1.0.20-RELEASE#9511c982fb1d046470a8b42aa36556cdb7da15de",
|
||||||
|
.hash = "1220d265dc673167ffe4a3cefe2840893d2910cfd773cfb1893ff768d5f1351d2a1f",
|
||||||
|
.lazy = true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
.paths = .{
|
.paths = .{
|
||||||
"build.zig",
|
"build.zig",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user