build: link LibreSSL for SSL support

I don't have a single clue in heck if this actually works, but it at
least does compile. At some point I will probably add a test or two to
find out how broken this is.
This commit is contained in:
torque 2023-08-31 23:50:18 -07:00
parent 741af6f976
commit 29966dc838
Signed by: torque
SSH Key Fingerprint: SHA256:nCrXefBNo6EbjNSQhv0nXmEg/VuNq3sMF5b8zETw3Tk
2 changed files with 17 additions and 2 deletions

View File

@ -1,5 +1,10 @@
.{
.name = "nats-client",
.version = "0.0.1",
.dependencies = .{},
.dependencies = .{
.libressl = .{
.url = "https://github.com/epicyclic-dev/LibreSSL-portable/archive/cedfc5580d2e665d66d8f357469e472bc12a099b.tar.gz",
.hash = "12204315709cc148a4c51661aa76db76bbe5192fbc762336f405c9069e95c5abf1ec",
},
},
}

View File

@ -30,6 +30,11 @@ pub fn nats_c_lib(
// lib.addIncludePath(.{ .path = nats_src_prefix ++ "stan" });
// lib.addCSourceFiles(&streaming_sources, &cflags);
const ssl_dep = b.dependency("libressl", .{
.target = options.target,
.optimize = options.optimize,
});
const tinfo = lib.target_info.target;
switch (tinfo.os.tag) {
.windows => {
@ -48,18 +53,23 @@ pub fn nats_c_lib(
lib.addCSourceFiles(&unix_sources, &cflags);
lib.defineCMacro("_GNU_SOURCE", null);
lib.defineCMacro("LINUX", null);
// may need to link pthread and rt. Not sure if those are inluded with linkLibC
// may need to link pthread and rt. Not sure if those are included with linkLibC
lib.linkSystemLibrary("pthread");
lib.linkSystemLibrary("rt");
},
}
lib.defineCMacro("NATS_HAS_TLS", null);
lib.defineCMacro("NATS_USE_OPENSSL_1_1", null);
lib.defineCMacro("NATS_FORCE_HOST_VERIFICATION", null);
lib.defineCMacro("_REENTRANT", null);
inline for (install_headers) |header| {
lib.installHeader(nats_src_prefix ++ header, "nats/" ++ header);
}
lib.linkLibrary(ssl_dep.artifact("ssl"));
b.installArtifact(lib);
return lib;