diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-10 16:05:20 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-10 16:43:58 -0300 |
| commit | 165bb6c1344b98de7bef1d3c2b72147b4a40797a (patch) | |
| tree | 0e70e6222700063f604f78673f6ab3a5bfb9242d /anim/build.zig | |
| parent | 66a2a7cf733f6abc1f79561c52d901ce67019fb1 (diff) | |
| download | computeranim-165bb6c1344b98de7bef1d3c2b72147b4a40797a.tar.gz computeranim-165bb6c1344b98de7bef1d3c2b72147b4a40797a.zip | |
canim: the renderer speaks the design language
The blocks, their states and the tokens carry the catalogue's names:
atoms in ui, chain/reg/slot in rows, insn with its line column, jump lane
and annotations (read, write, taken or not, a call with its arguments, a
return, a syscall) in disasm, bytes and hexdump with field paper and the
reading column, the three splits and relayout in stage, the ties (thread,
link and pin, projection, echo). A lens is a band over the whole context,
its drawing left and its bytes right. Frames' spans on the stack, each
instruction's line and a callee's parameter count come from the tracer.
A gallery scene draws every block; the test compares six of its pages
with pictures kept in test/gallery, drawn from a recording kept there
too. The scenes are ported; the motion checks report no pop and no
metronome in any of them.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Diffstat (limited to 'anim/build.zig')
| -rw-r--r-- | anim/build.zig | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/anim/build.zig b/anim/build.zig index b693919..2f50e4a 100644 --- a/anim/build.zig +++ b/anim/build.zig @@ -15,7 +15,7 @@ const std = @import("std"); const sketchbook = @import("sketchbook"); -const scenes = [_][]const u8{ "title", "fib", "list", "sort", "syscalls", "zoom" }; +const scenes = [_][]const u8{ "title", "fib", "list", "sort", "syscalls", "zoom", "gallery" }; pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); @@ -69,7 +69,7 @@ pub fn build(b: *std.Build) void { .{ .name = "steps", .source = "fib.c", .by = "insn" }, .{ .name = "hello", .source = "hello.c", .by = "line", .reads = "note" }, .{ .name = "sort", .source = "sort.c", .by = "line", .instr = "calls,vars,stores,loads" }, - .{ .name = "list", .source = "list.c", .by = "line", .instr = "calls,vars,stores", .alloc = true }, + .{ .name = "list", .source = "list.c", .by = "line", .instr = "calls,vars,stores,loads", .alloc = true }, }) |r| { const source = b.path(b.fmt("tools/{s}", .{r.source})); var program: std.Build.LazyPath = undefined; @@ -79,7 +79,9 @@ pub fn build(b: *std.Build) void { cc.addFileArg(plugin); cc.addArg("--rt"); cc.addArtifactArg(zt.artifact("ztrace-rt")); - cc.addArgs(&.{ "--", "clang", "-O0", "-g" }); + // Not position-independent: code and heap at short addresses, as + // the design's columns are drawn for (seven digits, not twelve). + cc.addArgs(&.{ "--", "clang", "-O0", "-g", "-no-pie" }); cc.addFileArg(source); cc.addArg("-o"); program = cc.addOutputFileArg(r.name); @@ -117,6 +119,10 @@ pub fn build(b: *std.Build) void { _ = embedded.addCopyFile(source, r.source); table.print(b.allocator, "pub const {s}: Program = .{{ .trace = @embedFile(\"{s}\"), .file = \"{s}\", .source = @embedFile(\"{s}\") }};\n", .{ r.name, file, r.source, r.source }) catch @panic("OOM"); } + // The gallery's own: a recording of the list kept in test/gallery, so its + // pictures change when the drawing does and not when a new recording does. + _ = embedded.addCopyFile(b.path("test/gallery/list.ztrace"), "gallery.ztrace"); + table.print(b.allocator, "pub const gallery: Program = .{{ .trace = @embedFile(\"gallery.ztrace\"), .file = \"list.c\", .source = @embedFile(\"list.c\") }};\n", .{}) catch @panic("OOM"); const recordings = b.createModule(.{ .root_source_file = embedded.add("recordings.zig", b.fmt( \\//! Generated by canim's build.zig: the recordings and the sources they ran. \\pub const Program = struct {{ trace: []const u8, file: []const u8, source: []const u8 }}; @@ -174,6 +180,22 @@ pub fn build(b: *std.Build) void { motion.stdio = .inherit; b.step("motion", "Judge -Dscene's motion: out/motion/NAME/ gets contact sheets of each transition and plots of change per frame").dependOn(&motion.step); } + if (std.mem.eql(u8, name, "gallery")) { + // The catalogue drawn: its pages against the pictures in test/gallery + // (`zig build gallery` draws them anew), at the design's size. + for ([_]struct { []const u8, []const u8 }{ .{ "test", ".zig-cache/canim" }, .{ "gallery", "test/gallery" } }) |use| { + const run = b.addRunArtifact(exe); + run.addArgs(&.{ "--headless", "--fresh", "--size", "1920x1080", "--define", b.fmt("dir={s}", .{use[1]}), "--script" }); + run.addFileArg(b.path("test/gallery.script")); + run.addArg("--state"); + _ = run.addOutputFileArg(b.fmt("gallery-{s}.state", .{use[0]})); + run.setCwd(b.path(".")); + run.expectExitCode(0); + run.has_side_effects = true; + if (std.mem.eql(u8, use[0], "test")) test_step.dependOn(&run.step) else b.step("gallery", "Draw the gallery's pages anew into test/gallery, the pictures the test compares with").dependOn(&run.step); + } + continue; + } test_step.dependOn(&scene.app.addScript(exe, b.path(b.fmt("test/{s}.script", .{name})), .{}).step); for ([_][]const u8{ "1920x1080", "3840x2160" }) |size| { |
