init
This builds a very basic version of the nats.c client (no TLS, no streaming/jetstream/whatever, since those bring in complex dependencies and I do not need them at the moment). Right now it contains a simple test program that demonstrates the functionality (cool!), but the plan is for the nats.zig to bind the API into a nicer, zig-like shape and re-export it. Then this becomes a package. The current function could become a test, though it's a bit complex for a unit test (and requires connecting to an externally-running NATS server in order to work).
This commit is contained in:
46
build.zig
Normal file
46
build.zig
Normal file
@@ -0,0 +1,46 @@
|
||||
const std = @import("std");
|
||||
const nats_build = @import("./nats-c.build.zig");
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
// const nats = b.addModule("nats", .{
|
||||
// .source_file = .{ .path = "source/nats.zig" },
|
||||
// });
|
||||
|
||||
const nats = b.addExecutable(.{
|
||||
.name = "nats_test",
|
||||
.root_source_file = .{ .path = "src/nats.zig" },
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
const tinfo = nats.target_info.target;
|
||||
|
||||
const nats_c = nats_build.nats_c_lib(
|
||||
b,
|
||||
.{ .name = "nats-c", .target = target, .optimize = optimize },
|
||||
);
|
||||
switch (tinfo.os.tag) {
|
||||
.windows => {
|
||||
if (tinfo.abi != .msvc) {
|
||||
nats_c.addCSourceFiles(&.{"src/win-crosshack.c"}, &.{"-fno-sanitize=undefined"});
|
||||
}
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
|
||||
nats.linkLibrary(nats_c);
|
||||
b.installArtifact(nats);
|
||||
|
||||
const main_tests = b.addTest(.{
|
||||
.root_source_file = .{ .path = "src/nats.zig" },
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
const run_main_tests = b.addRunArtifact(main_tests);
|
||||
const test_step = b.step("test", "Run tests");
|
||||
test_step.dependOn(&run_main_tests.step);
|
||||
}
|
Reference in New Issue
Block a user