diff options
Diffstat (limited to 'src/host/root.zig')
| -rw-r--r-- | src/host/root.zig | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/host/root.zig b/src/host/root.zig index 637a325..2876c0f 100644 --- a/src/host/root.zig +++ b/src/host/root.zig @@ -6,6 +6,8 @@ //! --headless offscreen video, silent audio //! --script FILE play a script instead of reading devices //! --fresh start from default state: no snapshots or recordings +//! --profile-gpu time each GPU command alone, print the times at exit +//! --console LINE run a console line once the sketch is loaded (repeatable) //! --define NAME=VALUE substitute {NAME} in the script const std = @import("std"); const c = @import("c"); @@ -24,6 +26,8 @@ pub fn main(init: std.process.Init, linked: ?abi.Sketch) !void { var script_path: ?[]const u8 = null; var defines: std.ArrayList([2][]const u8) = .empty; defer defines.deinit(gpa); + var lines: std.ArrayList([]const u8) = .empty; + defer lines.deinit(gpa); var args = init.minimal.args.iterate(); _ = args.skip(); @@ -34,6 +38,10 @@ pub fn main(init: std.process.Init, linked: ?abi.Sketch) !void { options.fresh = true; } else if (std.mem.eql(u8, arg, "--headless")) { options.headless = true; + } else if (std.mem.eql(u8, arg, "--profile-gpu")) { + options.profile_gpu = true; + } else if (std.mem.eql(u8, arg, "--console")) { + try lines.append(gpa, args.next() orelse fatal("--console needs a line")); } else if (std.mem.eql(u8, arg, "--script")) { script_path = args.next() orelse fatal("--script needs a file"); } else if (std.mem.eql(u8, arg, "--define")) { @@ -56,6 +64,7 @@ pub fn main(init: std.process.Init, linked: ?abi.Sketch) !void { var host: Host = undefined; try host.init(gpa, init.io, init.environ_map, options, linked); defer host.deinit(); + for (lines.items) |line| host.runLine(line, c.SDL_GetTicksNS()) catch {}; if (script_path) |path| { const source = try std.Io.Dir.cwd().readFileAlloc(init.io, path, gpa, .limited(1 << 20)); defer gpa.free(source); @@ -71,6 +80,8 @@ const usage = \\ --headless offscreen video, silent audio, no vsync \\ --script FILE play a script instead of reading devices \\ --fresh start from default state: no snapshots or recordings + \\ --profile-gpu time each GPU command alone, print the times at exit + \\ --console LINE run a console line once the sketch is loaded (repeatable) \\ --define NAME=VALUE substitute {NAME} in the script \\ ; |
