diff options
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 29 |
1 files changed, 28 insertions, 1 deletions
@@ -298,6 +298,31 @@ pub fn build(b: *Build) void { test_talk.dependOn(&talk_check.run.step); test_step.dependOn(&talk_check.run.step); + // The manual example: Figure 2-1 of the Intel SDM, Vol. 2, page 31, as + // a talk in the stock player. The PDF is named, never committed: built + // without it, the scene says so, and only its script needs it. + const pdf = b.option([]const u8, "manual", "The Intel SDM Vol. 2 PDF for the manual example (default ~/01-resources/intel-devref-ii.pdf)") orelse + b.pathJoin(&.{ b.graph.environ_map.get("HOME") orelse "/", "01-resources", "intel-devref-ii.pdf" }); + const have_pdf = if (std.Io.Dir.cwd().access(b.graph.io, pdf, .{})) true else |_| false; + const manual_options = b.addOptions(); + manual_options.addOption(?[]const u8, "pdf", if (have_pdf) pdf else null); + const manual = sb.addScene(.{ .root_source_file = b.path("examples/manual.zig"), .imports = &.{.{ .name = "manual", .module = manual_options.createModule() }} }); + const manual_lib = manual.app.addLibrary(); + b.step("manual", "Play the manual example in a window (-Dmanual=PDF, Vol. 2 of the Intel SDM)").dependOn(&manual.app.addRun(manual_lib, .{ .state = ".zig-cache/manual.state" }).step); + test_step.dependOn(&manual_lib.step); + if (have_pdf) { + const manual_exe = manual.app.addExecutable(); + const manual_script = manual.app.addScript(manual_exe, b.path("test/manual.script"), .{}); + // Two exports (a frame cap apiece, so the build runs both), which + // quit at the end, as the stock player does. + for ([_][]const u8{ "a", "b" }, [_]u64{ 1000, 1001 }) |define, cap| { + manual_script.addArg("--define"); + manual_script.addPrefixedDirectoryArg(b.fmt("{s}=", .{define}), manual.app.addExport(manual_exe, .{ .fps = 10, .frames = cap, .size = .{ 640, 360 } }).frames); + } + b.step("test-manual", "Play the manual example through its steps, and export it twice").dependOn(&manual_script.step); + test_step.dependOn(&manual_script.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 }} }); const diff = b.addSystemCommand(&.{ "python3", "tools/svgdiff.py" }); @@ -322,11 +347,13 @@ pub fn build(b: *Build) void { .{ .name = "anim", .module = sb.modules.anim }, .{ .name = "scene", .module = compiled.module }, .{ .name = "typst", .module = compiled.typst }, + .{ .name = "manual", .module = manual.module }, + .{ .name = "manual_typst", .module = manual.typst }, }, }), })); bench.has_side_effects = true; - b.step("bench", "Time parsing and drawing a scene's Typst (release mode, must be under 1ms)").dependOn(&bench.step); + b.step("bench", "Time parsing and drawing scenes' Typst (release mode: a simple object under 1ms, a PDF page in its own budget)").dependOn(&bench.step); // After the tests above, not beside them: it measures time. for (test_step.dependencies.items) |step| bench.step.dependOn(step); test_step.dependOn(&bench.step); |
