diff options
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| { |
