From 2dfddee8c6fab6eb76cbfe3d95f7c30bfb870702 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 25 Sep 2026 21:53:00 -0300 Subject: sketchbook: what the game's review needed - input.started: true on the first update of a run, never after a reload, for a sketch to stop what should not resume from saved state. - A console line that errors fails its script. Sketch commands answer unknown, done or failed (abi.Outcome) instead of a bool that hid errors. - addScript also takes the hot-reloadable library, run through the generic host, so scripts can reload a real build. - Sounds that do not load are .none, not an empty clip. - sk_tag reads an enum field's tag name from the web build, for tests. --- build.zig | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'build.zig') diff --git a/build.zig b/build.zig index 9fc9049..8de7f01 100644 --- a/build.zig +++ b/build.zig @@ -406,16 +406,20 @@ pub const App = struct { cwd: ?Build.LazyPath = null, }; - /// Plays a script headless against `exe` (from `addExecutable`), with a - /// throwaway state file. Fails when an expectation does. - pub fn addScript(app: App, exe: *Build.Step.Compile, script: Build.LazyPath, options: ScriptOptions) *Build.Step.Run { + /// Plays a script headless, with a throwaway state file, against + /// `artifact`: the executable (`addExecutable`), or the hot-reloadable + /// library (`addLibrary`) through the generic host, which scripts can + /// `reload`. Fails when an expectation or a console line does. + pub fn addScript(app: App, artifact: *Build.Step.Compile, script: Build.LazyPath, options: ScriptOptions) *Build.Step.Run { const b = app.sb.b; - const run = b.addRunArtifact(exe); + const library = artifact.isDynamicLibrary(); + const run = b.addRunArtifact(if (library) app.sb.host_exe else artifact); run.addArgs(&.{ "--headless", "--fresh", "--script" }); run.addFileArg(script); run.addArg("--state"); _ = run.addOutputFileArg(b.fmt("{s}.state", .{app.name})); for (options.defines) |pair| run.addArgs(&.{ "--define", b.fmt("{s}={s}", .{ pair[0], pair[1] }) }); + if (library) run.addArtifactArg(artifact); run.setCwd(options.cwd orelse b.path(".")); run.expectExitCode(0); run.has_side_effects = true; -- cgit v1.3