//! Build-time codegen: emit a Zig module exposing the compiled //! `libpanto-lua` shared object (`panto.so`) as embedded bytes. Bootstrap //! writes these to `/lib/lua//panto.so` on first run so the //! embedded VM's `require('panto')` resolves to the native module on a //! cold machine with no network — the guaranteed initial module load. //! //! Invoked from `build.zig`: //! //! gen-panto-so-embed //! //! `` is the filename the generated module `@embedFile`s; the //! actual `.so` is materialized alongside the generated file under that //! name via `addCopyFile` so `@embedFile` can reach it. const std = @import("std"); pub fn main(init: std.process.Init) !void { const io = init.io; var args = init.minimal.args.iterate(); defer args.deinit(); _ = args.next(); const embed_name = args.next() orelse return error.MissingEmbedName; const out_path = args.next() orelse return error.MissingOutPath; var out_file = try std.Io.Dir.cwd().createFile(io, out_path, .{}); defer out_file.close(io); var buf: [4096]u8 = undefined; var writer = out_file.writer(io, &buf); const w = &writer.interface; try w.print( \\//! Auto-generated. Do not edit. See build/gen_panto_so_embed.zig. \\ \\/// The compiled `libpanto-lua` shared object, embedded so the \\/// bootstrap can stage it onto the embedded VM's `package.cpath`. \\pub const bytes: []const u8 = @embedFile("{s}"); \\ , .{embed_name}); try w.flush(); }