mirror of
https://mzte.de/git/LordMZTE/dotfiles.git
synced 2024-11-15 22:43:02 +01:00
add stack traces to mzte-nv errors
This commit is contained in:
parent
f74f7b0fd4
commit
2fa42e1507
4 changed files with 38 additions and 28 deletions
|
@ -24,7 +24,10 @@ pub fn build(b: *std.build.Builder) !void {
|
||||||
lib.linkLibC();
|
lib.linkLibC();
|
||||||
lib.linkSystemLibrary("luajit");
|
lib.linkSystemLibrary("luajit");
|
||||||
|
|
||||||
lib.strip = mode != .Debug;
|
lib.strip = switch (mode) {
|
||||||
|
.Debug, .ReleaseSafe => false,
|
||||||
|
.ReleaseFast, .ReleaseSmall => true,
|
||||||
|
};
|
||||||
lib.unwind_tables = true;
|
lib.unwind_tables = true;
|
||||||
|
|
||||||
b.getInstallStep().dependOn(&b.addInstallFile(lib.getOutputSource(), "share/nvim/mzte-nv.so").step);
|
b.getInstallStep().dependOn(&b.addInstallFile(lib.getOutputSource(), "share/nvim/mzte-nv.so").step);
|
||||||
|
|
|
@ -11,13 +11,20 @@ pub fn luaFunc(comptime func: fn (*c.lua_State) anyerror!c_int) c.lua_CFunction
|
||||||
return &struct {
|
return &struct {
|
||||||
fn f(l: ?*c.lua_State) callconv(.C) c_int {
|
fn f(l: ?*c.lua_State) callconv(.C) c_int {
|
||||||
return func(l.?) catch |e| {
|
return func(l.?) catch |e| {
|
||||||
var buf: [128]u8 = undefined;
|
var buf: [1024 * 4]u8 = undefined;
|
||||||
const err_s = std.fmt.bufPrintZ(
|
var fbs = std.io.fixedBufferStream(&buf);
|
||||||
&buf,
|
fbs.writer().print("Zig Error: {s}\n", .{@errorName(e)}) catch @panic("OOM");
|
||||||
"Zig Error: {s}",
|
if (@errorReturnTrace()) |ert| {
|
||||||
.{@errorName(e)},
|
std.debug.writeStackTrace(
|
||||||
) catch unreachable;
|
ert.*,
|
||||||
c.lua_pushstring(l, err_s.ptr);
|
fbs.writer(),
|
||||||
|
std.heap.c_allocator,
|
||||||
|
std.debug.getSelfDebugInfo() catch @panic("WTF"),
|
||||||
|
.no_color,
|
||||||
|
) catch @panic("OOM");
|
||||||
|
}
|
||||||
|
|
||||||
|
luaPushString(l, fbs.getWritten());
|
||||||
_ = c.lua_error(l);
|
_ = c.lua_error(l);
|
||||||
unreachable;
|
unreachable;
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
(define (run)
|
(define (run)
|
||||||
(define nvim-config-dir (build-path (find-system-path 'home-dir) ".config" "nvim"))
|
(define nvim-config-dir (build-path (find-system-path 'home-dir) ".config" "nvim"))
|
||||||
(install-zig "mzte-nv")
|
(install-zig "mzte-nv" "ReleaseSafe")
|
||||||
(rm nvim-config-dir)
|
(rm nvim-config-dir)
|
||||||
(copy "mzte-nv/conf" nvim-config-dir)
|
(copy "mzte-nv/conf" nvim-config-dir)
|
||||||
(cmd "mzte-nv-compile" (path->string nvim-config-dir))
|
(cmd "mzte-nv-compile" (path->string nvim-config-dir))
|
||||||
|
|
|
@ -34,9 +34,9 @@
|
||||||
(define-logging copy copy-directory/files)
|
(define-logging copy copy-directory/files)
|
||||||
|
|
||||||
(define-logging install-zig
|
(define-logging install-zig
|
||||||
(λ (path)
|
(λ (path [mode "ReleaseFast"])
|
||||||
(parameterize ([current-directory path] [log-calls #f])
|
(parameterize ([current-directory path] [log-calls #f])
|
||||||
(cmd "zig" "build" "-p" (output-bin-path) "-Doptimize=ReleaseFast"))))
|
(cmd "zig" "build" "-p" (output-bin-path) (string-append "-Doptimize=" mode)))))
|
||||||
|
|
||||||
(define-logging install-rust
|
(define-logging install-rust
|
||||||
(λ (path)
|
(λ (path)
|
||||||
|
|
Loading…
Reference in a new issue