added extra_args

This commit is contained in:
Dario48 2026-06-21 01:02:48 +02:00
commit c21f5767ee

View file

@ -13,8 +13,8 @@ export fn glfw_error_callback(@"error": c_int, description: [*c]const u8) callco
pub const std_options: std.Options = .{};
fn formatArgv(alloc: std.mem.Allocator, format: []const u8, path: []const u8) ![][]u8 {
var outer = std.ArrayList([]u8).empty;
fn formatArgv(alloc: std.mem.Allocator, format: []const u8, path: []const u8, extra_args: ?[]const []const u8) ![][]const u8 {
var outer = std.ArrayList([]const u8).empty;
errdefer {
for (outer.items) |arr| {
alloc.free(arr);
@ -87,6 +87,9 @@ fn formatArgv(alloc: std.mem.Allocator, format: []const u8, path: []const u8) ![
try outer.append(alloc, owned);
if (extra_args) |a|
try outer.appendSlice(alloc, a);
return outer.toOwnedSlice(alloc);
}
@ -129,7 +132,7 @@ const map = blk: {
const binOptMap = map[0];
const floatOptMap = map[1];
var argv: ?[][]u8 = null;
var argv: ?[][]const u8 = null;
var stackTraceBuf: [32]usize = undefined; // you never know how long the rabbit stack trace goes
var stackTrace: std.debug.StackTrace = undefined;
@ -195,6 +198,7 @@ pub fn main(init: std.process.Init) !void {
name: []const u8,
emu: []const u8,
path: []const u8,
extra_args: ?[]const []const u8,
},
}, init.arena.allocator(), content, &diag, .{}) catch |err| {
std.log.err("{f}", .{diag});
@ -302,7 +306,7 @@ pub fn main(init: std.process.Init) !void {
for (zon.emus) |emu| {
std.log.debug(" emu.name: '{s}'", .{emu.name});
if (std.mem.eql(u8, emu.name, rom.emu)) {
argv = formatArgv(init.arena.allocator(), emu.exec_format, rom.path) catch |err| blk: {
argv = formatArgv(init.arena.allocator(), emu.exec_format, rom.path, rom.extra_args) catch |err| blk: {
handleErr(err);
break :blk null;
};