summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-16 23:59:29 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commitaabb92d26f6b46cd4c482e0e2cbc8e9e9751db0d (patch)
treef5139ed90cf1747f3aa3aaa0f6266bab2a335c10 /build.zig
parentc7ebfb6d18c44fec676da3d683e0b4e54001bd21 (diff)
parentbc6fe168278957ad15cf87826c8410e7358e0849 (diff)
downloadsketchbook-aabb92d26f6b46cd4c482e0e2cbc8e9e9751db0d.tar.gz
sketchbook-aabb92d26f6b46cd4c482e0e2cbc8e9e9751db0d.zip
Merge the session recorder and the talk primitives
Recording (sessions, marks, clips, the reload speed-ups under them) and anim's Deck with its example talk, together; no conflicts; zig build test: 161/161 steps, 127/127 tests. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig38
1 files changed, 36 insertions, 2 deletions
diff --git a/build.zig b/build.zig
index 9b99597..7bb3d0b 100644
--- a/build.zig
+++ b/build.zig
@@ -174,13 +174,17 @@ pub fn build(b: *Build) void {
for ([_]*Build.Module{
b.createModule(.{ .root_source_file = b.path("src/vector/root.zig"), .target = target, .optimize = optimize, .imports = vector_imports }),
b.createModule(.{ .root_source_file = b.path("src/scope/root.zig"), .target = target, .optimize = optimize, .imports = scope_imports }),
- b.createModule(.{ .root_source_file = b.path("src/anim/root.zig"), .target = target, .optimize = optimize, .imports = anim_imports }),
b.createModule(.{ .root_source_file = b.path("src/glsl.zig"), .target = target, .optimize = optimize }),
b.createModule(.{ .root_source_file = b.path("src/abi.zig"), .target = target, .optimize = optimize }),
b.createModule(.{ .root_source_file = b.path("src/sketch/root.zig"), .target = target, .optimize = optimize, .imports = sketch_imports }),
b.createModule(.{ .root_source_file = b.path("src/math/root.zig"), .target = target, .optimize = optimize }),
b.createModule(.{ .root_source_file = b.path("src/host/root.zig"), .target = target, .optimize = optimize, .imports = &.{ .{ .name = "abi", .module = abi }, .{ .name = "c", .module = c }, .{ .name = "gpu", .module = gpu }, .{ .name = "tracy", .module = tracy }, .{ .name = "cloud9", .module = cloud9 }, .{ .name = "xitdb", .module = xitdb } } }),
}) |module| test_step.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = module })).step);
+ // The anim module alone: its unit tests, and below the player's scenes.
+ const test_anim = b.step("test-anim", "Test the anim module: its unit tests and the player on its test scenes");
+ const anim_tests = b.addRunArtifact(b.addTest(.{ .root_module = b.createModule(.{ .root_source_file = b.path("src/anim/root.zig"), .target = target, .optimize = optimize, .imports = anim_imports }) }));
+ test_anim.dependOn(&anim_tests.step);
+ test_step.dependOn(&anim_tests.step);
// The noise tests again on wasm32 as the web builds it, under Node's
// WASI: the golden bits must come out the same in the browser as
@@ -244,13 +248,43 @@ pub fn build(b: *Build) void {
// custom object between vector objects, and a compiled one, which is
// also exported, at half size.
const live = sb.addScene(.{ .root_source_file = b.path("test/scene_live.zig") });
- test_step.dependOn(&live.app.addScript(live.app.addExecutable(), b.path("test/scene_live.script"), .{}).step);
+ const live_script = live.app.addScript(live.app.addExecutable(), b.path("test/scene_live.script"), .{});
+ test_step.dependOn(&live_script.step);
+ test_anim.dependOn(&live_script.step);
const compiled = sb.addScene(.{ .root_source_file = b.path("test/scene_compiled.zig") });
const compiled_exe = compiled.app.addExecutable();
const compiled_script = compiled.app.addScript(compiled_exe, b.path("test/scene_compiled.script"), .{});
compiled_script.addArg("--define");
compiled_script.addPrefixedDirectoryArg("frames=", compiled.app.addExport(compiled_exe, .{ .fps = 30, .size = .{ 640, 360 }, .frames = 200 }).frames);
test_step.dependOn(&compiled_script.step);
+ test_anim.dependOn(&compiled_script.step);
+
+ // The talk example: a Deck in a sketch's own State, stepped, sent back,
+ // jumped by slides, clicked on its slider, reloaded mid-wait with its
+ // first step retimed, and exported twice, with the same frames.
+ const talk_imports: []const Build.Module.Import = &.{ .{ .name = "anim", .module = sb.modules.anim }, .{ .name = "sketch", .module = sketch } };
+ const talk = sb.app(.{ .name = "talk", .root_source_file = b.path("examples/talk.zig"), .imports = &.{
+ .{ .name = "anim", .module = sb.modules.anim },
+ .{ .name = "typst", .module = sb.addTypst(b.createModule(.{ .root_source_file = b.path("examples/talk.zig"), .imports = talk_imports })) },
+ } });
+ const talk_check = talk.addReloadCheck(.{ .script = b.path("test/talk.script"), .edits = &.{.{
+ .file = "examples/talk.zig",
+ .old = "s.play(.{ title.write(), law.write() }, .{});",
+ .new = "s.play(.{ title.write(), law.write() }, .{ .seconds = 3 });",
+ }} });
+ const talk_exe = talk.addExecutable();
+ for ([_][]const u8{ "a", "b" }, [_]u64{ 400, 401 }) |define, frames| {
+ talk_check.run.addArg("--define");
+ talk_check.run.addPrefixedDirectoryArg(b.fmt("{s}=", .{define}), talk.addExport(talk_exe, .{ .fps = 30, .frames = frames, .size = .{ 640, 360 } }).frames);
+ }
+ // `zig build talk` shows it in a window; `zig build talk-lib --watch`
+ // beside it reloads every edit in place.
+ const talk_lib = talk.addLibrary();
+ b.step("talk", "Run the talk example in a window (reload edits with `zig build talk-lib --watch`)").dependOn(&talk.addRun(talk_lib, .{ .state = ".zig-cache/talk.state" }).step);
+ b.step("talk-lib", "Build and install the talk example's hot-reloadable library").dependOn(&b.addInstallArtifact(talk_lib, .{}).step);
+ const test_talk = b.step("test-talk", "Play the talk example: steps, back, slides, its slider, a reload mid-wait and its export");
+ test_talk.dependOn(&talk_check.run.step);
+ test_step.dependOn(&talk_check.run.step);
// Both vector renderers against resvg, through the host (tools/svgdiff.py).
const svgview = sb.app(.{ .name = "svgview", .root_source_file = b.path("test/svgview.zig"), .imports = &.{.{ .name = "vector", .module = sb.modules.vector }} });