1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
const std = @import("std");
const sketchbook = @import("sketchbook");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const sb = sketchbook.init(b, .{ .target = target, .optimize = optimize });
// A scene is one file, played by sketchbook's `anim` player. `-Dscene`
// picks the one `run`, `lib`, `web` and `export` use; `test` plays each
// of these through its script.
const scenes = [_]struct { []const u8, []const u8 }{
.{ "scenes/intro.zig", "test/intro.script" },
.{ "scenes/live.zig", "test/live.script" },
};
const selected = b.option([]const u8, "scene", "The scene to play (default scenes/intro.zig)") orelse scenes[0][0];
const player = addPlayer(sb, selected);
const steps = player.app.addSteps(.{ .web = .{} });
for (scenes) |entry| {
const same = std.mem.eql(u8, entry[0], selected);
const each = if (same) player else addPlayer(sb, entry[0]);
const exe = if (same) steps.exe else each.app.addExecutable();
steps.e2e.dependOn(&each.app.addScript(exe, b.path(entry[1]), .{}).step);
}
}
/// The player built around one scene file, named after it (`vecanim-intro`),
/// so that players of different scenes keep their own state and library.
fn addPlayer(sb: sketchbook.Sketchbook, path: []const u8) sketchbook.Sketchbook.Scene {
return sb.addScene(.{ .name = sb.b.fmt("vecanim-{s}", .{std.fs.path.stem(path)}), .root_source_file = sb.b.path(path) });
}
|