all: update for zig-0.13
This is mainly updates to the build system, but there were a couple of stdlib changes for the tests. The build system does include handling more properly now as well, I think. It has fewer hacks, at least.
This commit is contained in:
parent
ff3782ce27
commit
74bbe30d0a
11
build.zig
11
build.zig
@ -9,19 +9,19 @@ pub fn build(b: *std.Build) void {
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
const nats = b.addModule("nats", .{
|
||||
.root_source_file = .{ .path = "src/nats.zig" },
|
||||
.root_source_file = b.path("src/nats.zig"),
|
||||
});
|
||||
nats.addIncludePath(.{ .path = b.getInstallPath(.header, "") });
|
||||
|
||||
const nats_c = nats_build.nats_c_lib(b, .{
|
||||
.name = "nats-c",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
nats.linkLibrary(nats_c);
|
||||
|
||||
const tests = b.addTest(.{
|
||||
.name = "nats-zig-unit-tests",
|
||||
.root_source_file = .{ .path = "tests/main.zig" },
|
||||
.root_source_file = b.path("tests/main.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
@ -38,7 +38,6 @@ pub fn build(b: *std.Build) void {
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.nats_module = nats,
|
||||
.nats_c = nats_c,
|
||||
});
|
||||
}
|
||||
|
||||
@ -46,7 +45,6 @@ const ExampleOptions = struct {
|
||||
target: std.Build.ResolvedTarget,
|
||||
optimize: std.builtin.OptimizeMode,
|
||||
nats_module: *std.Build.Module,
|
||||
nats_c: *std.Build.Step.Compile,
|
||||
};
|
||||
|
||||
const Example = struct {
|
||||
@ -66,13 +64,12 @@ pub fn add_examples(b: *std.Build, options: ExampleOptions) void {
|
||||
inline for (examples) |example| {
|
||||
const ex_exe = b.addExecutable(.{
|
||||
.name = example.name,
|
||||
.root_source_file = .{ .path = example.file },
|
||||
.root_source_file = b.path(example.file),
|
||||
.target = options.target,
|
||||
.optimize = .Debug,
|
||||
});
|
||||
|
||||
ex_exe.root_module.addImport("nats", options.nats_module);
|
||||
ex_exe.linkLibrary(options.nats_c);
|
||||
|
||||
const install = b.addInstallArtifact(ex_exe, .{});
|
||||
example_step.dependOn(&install.step);
|
||||
|
@ -1,6 +1,6 @@
|
||||
.{
|
||||
.name = "nats.zig",
|
||||
.version = "0.0.1",
|
||||
.name = "nats_client",
|
||||
.version = "0.1.0",
|
||||
.paths = .{
|
||||
"src",
|
||||
"deps/nats.c/src",
|
||||
@ -13,8 +13,8 @@
|
||||
},
|
||||
.dependencies = .{
|
||||
.libressl = .{
|
||||
.url = "https://github.com/epicyclic-dev/LibreSSL-portable/archive/e95f71abab96329b3465b931822ba250c8f49236.tar.gz",
|
||||
.hash = "12209998e2dc9474dc232f6be9a8bde9e49cde3e42ed71bfe8d514758f0a398b3d30",
|
||||
.url = "https://github.com/epicyclic-dev/LibreSSL-portable/archive/62af702f8d57a4cd651e1cc30784abf39a3a4e66.tar.gz",
|
||||
.hash = "122045ccefa4e7b4537e106d3045150f77d2aad4fce730d59678a9a8a151608a1d17",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -25,11 +25,11 @@ pub fn nats_c_lib(
|
||||
|
||||
lib.linkLibC();
|
||||
lib.addCSourceFiles(.{ .files = &common_sources, .flags = &cflags });
|
||||
lib.addIncludePath(.{ .path = nats_src_prefix ++ "include" });
|
||||
lib.addIncludePath(b.path(nats_src_prefix ++ "include"));
|
||||
// if building with streaming support (protocol.pb-c.c includes
|
||||
// <protobuf-c/protobuf-c.h>, unfortunately)
|
||||
lib.addIncludePath(.{ .path = "deps" });
|
||||
lib.addIncludePath(.{ .path = nats_src_prefix ++ "stan" });
|
||||
lib.addIncludePath(b.path("deps"));
|
||||
lib.addIncludePath(b.path(nats_src_prefix ++ "stan"));
|
||||
lib.addCSourceFiles(.{ .files = &streaming_sources, .flags = &cflags });
|
||||
lib.addCSourceFiles(.{ .files = &protobuf_c_sources, .flags = &cflags });
|
||||
|
||||
|
@ -14,9 +14,7 @@
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
pub const nats_c = @cImport({
|
||||
@cInclude("nats/nats.h");
|
||||
});
|
||||
const nats_c = @import("./nats_c.zig").nats_c;
|
||||
|
||||
const Subscription = @import("./subscription.zig").Subscription;
|
||||
const SubscriptionCallbackSignature = @import("./subscription.zig").SubscriptionCallbackSignature;
|
||||
|
@ -14,9 +14,7 @@
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
pub const nats_c = @cImport({
|
||||
@cInclude("nats/nats.h");
|
||||
});
|
||||
const nats_c = @import("./nats_c.zig").nats_c;
|
||||
|
||||
// pub const AllocError = Error || std.mem.Allocator.Error;
|
||||
|
||||
|
@ -14,9 +14,7 @@
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
pub const nats_c = @cImport({
|
||||
@cInclude("nats/nats.h");
|
||||
});
|
||||
const nats_c = @import("./nats_c.zig").nats_c;
|
||||
|
||||
const err_ = @import("./error.zig");
|
||||
const Error = err_.Error;
|
||||
|
@ -14,9 +14,7 @@
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
pub const nats_c = @cImport({
|
||||
@cInclude("nats/nats.h");
|
||||
});
|
||||
pub const nats_c = @import("./nats_c.zig").nats_c;
|
||||
|
||||
const err_ = @import("./error.zig");
|
||||
const con_ = @import("./connection.zig");
|
||||
|
3
src/nats_c.zig
Normal file
3
src/nats_c.zig
Normal file
@ -0,0 +1,3 @@
|
||||
pub const nats_c = @cImport({
|
||||
@cInclude("nats/nats.h");
|
||||
});
|
@ -14,9 +14,7 @@
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
const nats_c = @cImport({
|
||||
@cInclude("nats/nats.h");
|
||||
});
|
||||
const nats_c = @import("./nats_c.zig").nats_c;
|
||||
|
||||
const err_ = @import("./error.zig");
|
||||
const Status = err_.Status;
|
||||
|
@ -14,9 +14,7 @@
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
pub const nats_c = @cImport({
|
||||
@cInclude("nats/nats.h");
|
||||
});
|
||||
const nats_c = @import("./nats_c.zig").nats_c;
|
||||
|
||||
const Connection = @import("./connection.zig").Connection;
|
||||
|
||||
|
@ -14,9 +14,7 @@
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
pub const nats_c = @cImport({
|
||||
@cInclude("nats/nats.h");
|
||||
});
|
||||
const nats_c = @import("./nats_c.zig").nats_c;
|
||||
|
||||
pub fn checkUserDataType(comptime T: type) void {
|
||||
switch (@typeInfo(T)) {
|
||||
|
@ -20,7 +20,7 @@ const TestLaunchError = error{
|
||||
|
||||
pub const TestServer = struct {
|
||||
allocator: std.mem.Allocator,
|
||||
process: std.ChildProcess,
|
||||
process: std.process.Child,
|
||||
key_dir: ?std.testing.TmpDir,
|
||||
url: [:0]u8,
|
||||
|
||||
@ -99,8 +99,8 @@ pub const TestServer = struct {
|
||||
const out_dir = std.testing.tmpDir(.{});
|
||||
key_dir = out_dir;
|
||||
|
||||
try out_dir.dir.writeFile("server.key", pair.key);
|
||||
try out_dir.dir.writeFile("server.cert", pair.cert);
|
||||
try out_dir.dir.writeFile(.{ .sub_path = "server.key", .data = pair.key });
|
||||
try out_dir.dir.writeFile(.{ .sub_path = "server.cert", .data = pair.cert });
|
||||
// since testing.tmpDir will actually bury itself in zig-cache/tmp,
|
||||
// there's not an easy way to extract files from within the temp
|
||||
// directory except through using realPath, as far as I can tell
|
||||
@ -123,7 +123,7 @@ pub const TestServer = struct {
|
||||
|
||||
defer options.allocator.free(args);
|
||||
|
||||
var child = std.ChildProcess.init(args, options.allocator);
|
||||
var child = std.process.Child.init(args, options.allocator);
|
||||
child.stdin_behavior = .Ignore;
|
||||
child.stdout_behavior = .Pipe;
|
||||
child.stderr_behavior = .Pipe;
|
||||
|
Loading…
x
Reference in New Issue
Block a user