Compare commits
8 commits
0a386496cd
...
8b2535db19
Author | SHA1 | Date | |
---|---|---|---|
8b2535db19 | |||
51751adce6 | |||
f823f66c90 | |||
ee2b38f0af | |||
0ea031d913 | |||
4d317d7bf0 | |||
b7361361bc | |||
9af61100d0 |
5 changed files with 32 additions and 25 deletions
|
@ -34,10 +34,13 @@ pub fn build(b: *std.Build) void {
|
||||||
const asio_dep = b.dependency("asio", mode);
|
const asio_dep = b.dependency("asio", mode);
|
||||||
const tracy_dep = if (tracy_enabled) b.dependency("tracy", mode) else undefined;
|
const tracy_dep = if (tracy_enabled) b.dependency("tracy", mode) else undefined;
|
||||||
|
|
||||||
const lib = b.addStaticLibrary(.{
|
const lib = b.addLibrary(.{
|
||||||
.name = "thespian",
|
.name = "thespian",
|
||||||
|
.linkage = .static,
|
||||||
|
.root_module = b.createModule(.{
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
if (tracy_enabled) {
|
if (tracy_enabled) {
|
||||||
lib.root_module.addCMacro("TRACY_ENABLE", "1");
|
lib.root_module.addCMacro("TRACY_ENABLE", "1");
|
||||||
|
@ -90,9 +93,11 @@ pub fn build(b: *std.Build) void {
|
||||||
thespian_mod.linkLibrary(lib);
|
thespian_mod.linkLibrary(lib);
|
||||||
|
|
||||||
const tests = b.addTest(.{
|
const tests = b.addTest(.{
|
||||||
|
.root_module = b.createModule(.{
|
||||||
.root_source_file = b.path("test/tests.zig"),
|
.root_source_file = b.path("test/tests.zig"),
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
tests.root_module.addImport("build_options", options_mod);
|
tests.root_module.addImport("build_options", options_mod);
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0.14.0
|
0.15.1
|
||||||
|
|
|
@ -5,16 +5,16 @@
|
||||||
|
|
||||||
.dependencies = .{
|
.dependencies = .{
|
||||||
.cbor = .{
|
.cbor = .{
|
||||||
.url = "git+https://github.com/neurocyte/cbor?ref=master#ba2955fe3aa08456ed61a0e087be1e2ec46927e0",
|
.url = "git+https://github.com/neurocyte/cbor?ref=master#0708420594f5af0a8289e6e1bae0ae03f011731f",
|
||||||
.hash = "cbor-1.0.0-RcQE_NEzAQAGoED9NqVSWT0fhB8peqbXe99IixQKTeVp",
|
.hash = "cbor-1.0.0-RcQE_CUwAQChkeU-LO-eTSbLAdRox-wuxUGmi2nDAWri",
|
||||||
},
|
},
|
||||||
.asio = .{
|
.asio = .{
|
||||||
.url = "https://github.com/neurocyte/asio/archive/24d28864ec5aae6146d88a172288e3bf3f099734.tar.gz",
|
.url = "git+https://github.com/neurocyte/asio#0f1cbf24e5fb6fabe7078a20b76452f42e24a0df",
|
||||||
.hash = "asio-1.30.2-tLhDdyKA4QBqQFDrsuK_hO1HfqX-DQMl-Sku7yy4vUfM",
|
.hash = "asio-1.30.2-tLhDd0SB4QB1041_DEW_1cvEw8eMfBYLAwjN_G53Fn66",
|
||||||
},
|
},
|
||||||
.tracy = .{
|
.tracy = .{
|
||||||
.url = "https://github.com/neurocyte/zig-tracy/archive/82f18a661af17089198fb7c489ef253f02b939b5.tar.gz",
|
.url = "git+https://github.com/neurocyte/zig-tracy#67070c146104d93fd3bed5091738f22e33e13bce",
|
||||||
.hash = "zig_tracy-0.0.3-5-cp3JZ2AAC6j-gWFhPKXyF6WASJpCzQeNy7Bi712t1a",
|
.hash = "zig_tracy-0.0.3-5-cp3Ht3AAAfHqShKfTK7waFK3Wjd3l2NheiqxvRRAdo",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
.paths = .{
|
.paths = .{
|
||||||
|
|
|
@ -30,7 +30,7 @@ pub const sighdl_backtrace = if (builtin.os.tag != .windows) c_posix.sighdl_back
|
||||||
|
|
||||||
pub const max_message_size = 8 * 4096;
|
pub const max_message_size = 8 * 4096;
|
||||||
const message_buf_allocator = std.heap.c_allocator;
|
const message_buf_allocator = std.heap.c_allocator;
|
||||||
threadlocal var message_buffer: std.ArrayList(u8) = std.ArrayList(u8).init(message_buf_allocator);
|
threadlocal var message_buffer: std.ArrayList(u8) = .empty;
|
||||||
threadlocal var error_message_buffer: [256]u8 = undefined;
|
threadlocal var error_message_buffer: [256]u8 = undefined;
|
||||||
threadlocal var error_buffer_tl: c.thespian_error = .{
|
threadlocal var error_buffer_tl: c.thespian_error = .{
|
||||||
.base = null,
|
.base = null,
|
||||||
|
@ -147,6 +147,7 @@ pub const message = struct {
|
||||||
|
|
||||||
pub fn fmt(value: anytype) Self {
|
pub fn fmt(value: anytype) Self {
|
||||||
message_buffer.clearRetainingCapacity();
|
message_buffer.clearRetainingCapacity();
|
||||||
|
var writer = std.Io.Writer.Allocating.fromArrayList(message_buf_allocator, &message_buffer);
|
||||||
const f = comptime switch (@typeInfo(@TypeOf(value))) {
|
const f = comptime switch (@typeInfo(@TypeOf(value))) {
|
||||||
.@"struct" => |info| if (info.is_tuple)
|
.@"struct" => |info| if (info.is_tuple)
|
||||||
fmt_internal
|
fmt_internal
|
||||||
|
@ -154,15 +155,16 @@ pub const message = struct {
|
||||||
@compileError("thespian.message template should be a tuple: " ++ @typeName(@TypeOf(value))),
|
@compileError("thespian.message template should be a tuple: " ++ @typeName(@TypeOf(value))),
|
||||||
else => fmt_internal_scalar,
|
else => fmt_internal_scalar,
|
||||||
};
|
};
|
||||||
f(message_buffer.writer(), value) catch |e| std.debug.panic("thespian.message.fmt: {any}", .{e});
|
f(&writer.writer, value) catch |e| std.debug.panic("thespian.message.fmt: {any}", .{e});
|
||||||
|
message_buffer = writer.toArrayList();
|
||||||
return .{ .buf = message_buffer.items };
|
return .{ .buf = message_buffer.items };
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fmt_internal_scalar(writer: std.ArrayList(u8).Writer, value: anytype) !void {
|
fn fmt_internal_scalar(writer: *std.Io.Writer, value: anytype) !void {
|
||||||
return fmt_internal(writer, .{value});
|
return fmt_internal(writer, .{value});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fmt_internal(writer: std.ArrayList(u8).Writer, value: anytype) !void {
|
fn fmt_internal(writer: *std.Io.Writer, value: anytype) !void {
|
||||||
try cbor.writeValue(writer, value);
|
try cbor.writeValue(writer, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,9 +184,9 @@ pub const message = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fmtbuf_internal(buf: []u8, value: anytype) !Self {
|
fn fmtbuf_internal(buf: []u8, value: anytype) !Self {
|
||||||
var stream = std.io.fixedBufferStream(buf);
|
var stream: std.Io.Writer = .fixed(buf);
|
||||||
try cbor.writeValue(stream.writer(), value);
|
try cbor.writeValue(&stream, value);
|
||||||
return .{ .buf = stream.getWritten() };
|
return .{ .buf = stream.buffered() };
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn len(self: Self) usize {
|
pub fn len(self: Self) usize {
|
||||||
|
@ -230,15 +232,15 @@ pub fn exit_message(e: anytype, stack_trace: ?*std.builtin.StackTrace) message {
|
||||||
var debug_info_arena_allocator: std.heap.ArenaAllocator = std.heap.ArenaAllocator.init(std.heap.page_allocator);
|
var debug_info_arena_allocator: std.heap.ArenaAllocator = std.heap.ArenaAllocator.init(std.heap.page_allocator);
|
||||||
defer debug_info_arena_allocator.deinit();
|
defer debug_info_arena_allocator.deinit();
|
||||||
const a = debug_info_arena_allocator.allocator();
|
const a = debug_info_arena_allocator.allocator();
|
||||||
var out = std.ArrayList(u8).init(a);
|
var out: std.Io.Writer.Allocating = .init(a);
|
||||||
store_stack_trace(stack_trace_.*, out.writer());
|
store_stack_trace(stack_trace_.*, &out.writer);
|
||||||
return message.fmtbuf(&error_message_buffer, .{ "exit", e, out.items }) catch unreachable;
|
return message.fmtbuf(&error_message_buffer, .{ "exit", e, out.writer.buffered() }) catch unreachable;
|
||||||
} else {
|
} else {
|
||||||
return message.fmtbuf(&error_message_buffer, .{ "exit", e }) catch unreachable;
|
return message.fmtbuf(&error_message_buffer, .{ "exit", e }) catch unreachable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn store_stack_trace(stack_trace: std.builtin.StackTrace, writer: anytype) void {
|
fn store_stack_trace(stack_trace: std.builtin.StackTrace, writer: *std.Io.Writer) void {
|
||||||
nosuspend {
|
nosuspend {
|
||||||
if (builtin.strip_debug_info) {
|
if (builtin.strip_debug_info) {
|
||||||
writer.print("Unable to store stack trace: debug info stripped\n", .{}) catch return;
|
writer.print("Unable to store stack trace: debug info stripped\n", .{}) catch return;
|
||||||
|
|
2
zig
2
zig
|
@ -24,7 +24,7 @@ if [ "$ARCH" == "arm64" ]; then
|
||||||
ARCH=aarch64
|
ARCH=aarch64
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ZIGVER="zig-$OS-$ARCH-$VERSION"
|
ZIGVER="zig-$ARCH-$OS-$VERSION"
|
||||||
ZIG=$ZIGDIR/$ZIGVER/zig
|
ZIG=$ZIGDIR/$ZIGVER/zig
|
||||||
|
|
||||||
if [ "$1" == "update" ]; then
|
if [ "$1" == "update" ]; then
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue