summaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authorT <t@tjp.lol>2026-05-26 10:33:24 -0600
committerT <t@tjp.lol>2026-05-26 10:42:41 -0600
commitedad4fc123099a780d960feea4fe37efb6d979d8 (patch)
tree7fea8bf150fb80af493d7da65417872a4df460e5 /src/main.zig
parentc2f727e188c1558bcc6b34569af2feab3b0366c0 (diff)
include and link lua 5.4, smoke test in panto cli main.zig
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig
index 20da910..6fbdb4b 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -2,6 +2,14 @@ const std = @import("std");
const panto = @import("panto");
const ping_tool = @import("ping_tool.zig");
+// Lua 5.4 C API. Linked statically via build.zig from the upstream lua.org
+// source tarball pinned in build.zig.zon.
+const lua = @cImport({
+ @cInclude("lua.h");
+ @cInclude("lauxlib.h");
+ @cInclude("lualib.h");
+});
+
const Receiver = panto.provider.Receiver;
const ReceiverVTable = panto.provider.ReceiverVTable;
const ContentBlockType = panto.provider.ContentBlockType;
@@ -92,6 +100,26 @@ const CLIReceiver = struct {
}
};
+/// Spin up a Lua interpreter, run a no-op, tear it down. Catches
+/// link/compile errors on the Lua dependency at the earliest moment.
+/// Logs only in debug builds; release builds run silently.
+fn luaSmokeCheck() void {
+ const L = lua.luaL_newstate() orelse {
+ std.log.err("lua: luaL_newstate returned null", .{});
+ return;
+ };
+ defer lua.lua_close(L);
+ lua.luaL_openlibs(L);
+
+ // Push _VERSION to confirm libs loaded.
+ _ = lua.lua_getglobal(L, "_VERSION");
+ const ver = lua.lua_tolstring(L, -1, null);
+ if (ver != null) {
+ std.log.debug("lua: {s} linked OK", .{ver});
+ }
+ lua.lua_settop(L, 0);
+}
+
fn loadConfig(environ_map: *const std.process.Environ.Map) !panto.config.Config {
const style_str = environ_map.get("PANTO_API_STYLE") orelse "openai_chat";
const style = std.meta.stringToEnum(panto.config.APIStyle, style_str) orelse {
@@ -167,6 +195,10 @@ pub fn main(init: std.process.Init) !void {
const alloc = init.gpa;
const io = init.io;
+ // Smoke test: prove Lua is linked. Slice 1 — no extension runtime
+ // wired up yet, this just confirms the static lib comes through.
+ luaSmokeCheck();
+
const config = try loadConfig(init.environ_map);
var stdout_buffer: [4096]u8 = undefined;