summaryrefslogtreecommitdiff
path: root/src/host/root.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-28 21:07:13 -0300
committerGabriel Schneider <[email protected]>2026-11-12 13:22:02 -0300
commit590ba7b9b579b97e34b51ab7e3460ebc85713343 (patch)
tree6a73a7570ff4f79f41deff078455877b9bc6571b /src/host/root.zig
parentbc8e6eb1bfef0c5e9b3c40fc1e4fd5a1659e2b03 (diff)
downloadsketchbook-590ba7b9b579b97e34b51ab7e3460ebc85713343.tar.gz
sketchbook-590ba7b9b579b97e34b51ab7e3460ebc85713343.zip
sketchbook: Zig 0.17, a Store on disk, requests, a scope (waveform, spectrum, spectrogram), audio codecs and fonts, web host
Diffstat (limited to 'src/host/root.zig')
-rw-r--r--src/host/root.zig11
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
\\
;