summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig24
1 files changed, 19 insertions, 5 deletions
diff --git a/build.zig b/build.zig
index eaa4454..ccec959 100644
--- a/build.zig
+++ b/build.zig
@@ -109,12 +109,16 @@ pub fn build(b: *Build) void {
b.step("test-sessions", "Test the sessions database: frames, keyframes, marks, clips").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = host, .filters = &.{"session"} })).step);
b.step("test-presentation", "Test presentation feedback, pacing and trace snapshots").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = host, .filters = &.{"presentation"} })).step);
+ // The sketch library's tests measure text with no host: through
+ // sketchbook-text, as an app's tests do (`App.addTest`).
+ const sketch_tests = b.createModule(.{ .root_source_file = b.path("src/sketch/root.zig"), .target = target, .optimize = optimize, .imports = sketch_imports });
+ sketch_tests.linkLibrary(text_library);
const test_audio = b.step("test-audio", "Test sound: the voice mixer (reconciling, limiting, pitch, groups), sfxr, and a made sound played as a voice");
test_audio.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = host, .filters = &.{ "voice", "mixer" } })).step);
- test_audio.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = b.createModule(.{ .root_source_file = b.path("src/sketch/root.zig"), .target = target, .optimize = optimize, .imports = sketch_imports }), .filters = &.{"sfxr"} })).step);
+ test_audio.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = sketch_tests, .filters = &.{"sfxr"} })).step);
const setup_tests = b.step("test-setup", "Test resource setup lifecycle and arguments");
- for ([_]*Build.Module{ host, b.createModule(.{ .root_source_file = b.path("src/sketch/root.zig"), .target = target, .optimize = optimize, .imports = sketch_imports }) }) |module| setup_tests.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = module, .filters = &.{"setup"} })).step);
+ for ([_]*Build.Module{ host, sketch_tests }) |module| setup_tests.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = module, .filters = &.{"setup"} })).step);
const host_exe = b.addExecutable(.{
.name = "sketchbook",
@@ -127,7 +131,7 @@ pub fn build(b: *Build) void {
});
b.installArtifact(host_exe);
- var sb: Sketchbook = .{ .b = b, .target = target, .optimize = optimize, .modules = .{ .abi = abi, .sketch = sketch, .host = host, .tracy = tracy, .vector = undefined, .scope = undefined, .anim = undefined, .gltf = gltf, .cloud9 = cloud9 }, .host_exe = host_exe, .gltf_generator = gltf_generator, .web = b.path("web"), .glsl = b.path("src/glsl.zig"), .tools = b.path("tools"), .anim_dir = b.path("src/anim"), .gltf_render_dir = b.path("src/gltf_render"), .script_optimize = optimize, .shared = .create(b) };
+ var sb: Sketchbook = .{ .b = b, .target = target, .optimize = optimize, .modules = .{ .abi = abi, .sketch = sketch, .host = host, .tracy = tracy, .vector = undefined, .scope = undefined, .anim = undefined, .gltf = gltf, .cloud9 = cloud9 }, .host_exe = host_exe, .text = text_library, .gltf_generator = gltf_generator, .web = b.path("web"), .glsl = b.path("src/glsl.zig"), .tools = b.path("tools"), .anim_dir = b.path("src/anim"), .gltf_render_dir = b.path("src/gltf_render"), .script_optimize = optimize, .shared = .create(b) };
// Vector graphics: built with the same shader step apps use. Both forms
// of its shaders are exported, so apps' web builds can swap them too.
@@ -185,7 +189,7 @@ pub fn build(b: *Build) void {
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/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 }),
+ sketch_tests,
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 }, .{ .name = "font_atlas", .module = font_atlas } } }),
}) |module| test_step.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = module })).step);
@@ -264,7 +268,12 @@ pub fn build(b: *Build) void {
test_web.dependOn(&render_web.step);
// `Host.textSize` against the text drawn (test/text.zig).
const text = sb.app(.{ .name = "text", .root_source_file = b.path("test/text.zig") });
- test_step.dependOn(&text.addScript(text.addExecutable(), b.path("test/text.script"), .{}).step);
+ const text_script = text.addScript(text.addExecutable(), b.path("test/text.script"), .{});
+ test_step.dependOn(&text_script.step);
+ const test_text = b.step("test-text", "Test text: layout (sketch.text), the atlas's rasters against pardes's, and test/text.script");
+ test_text.dependOn(&text_script.step);
+ test_text.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = sketch_tests, .filters = &.{"paragraph"} })).step);
+ test_text.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = host, .filters = &.{"pardes's"} })).step);
// A sound the sketch made, as a voice: once per serial, not again on a
// replay (test/voices.zig).
const voices = sb.app(.{ .name = "voices", .root_source_file = b.path("test/voices.zig") });
@@ -831,6 +840,7 @@ pub fn init(b: *Build, options: Options) Sketchbook {
.optimize = options.optimize,
.modules = .{ .abi = dep.module("abi"), .sketch = dep.module("sketch"), .host = dep.module("host"), .tracy = dep.module("tracy"), .vector = dep.module("vector"), .scope = dep.module("scope"), .anim = dep.module("anim"), .gltf = dep.module("gltf"), .cloud9 = dep.module("cloud9") },
.host_exe = dep.artifact("sketchbook"),
+ .text = dep.artifact("sketchbook-text"),
.gltf_generator = dep.artifact("gltf-bindings"),
.web = dep.path("web"),
.glsl = dep.path("src/glsl.zig"),
@@ -884,6 +894,9 @@ pub const Sketchbook = struct {
modules: struct { abi: *Build.Module, sketch: *Build.Module, host: *Build.Module, tracy: *Build.Module, vector: *Build.Module, scope: *Build.Module, anim: *Build.Module, gltf: *Build.Module, cloud9: *Build.Module },
/// The generic host: loads and hot-reloads a sketch library.
host_exe: *Build.Step.Compile,
+ /// FreeType, HarfBuzz and vendor/text.c: what the host measures text
+ /// with, linked into an app's tests (`App.addTest`) so they measure too.
+ text: *Build.Step.Compile,
/// `host.js` and the `index.html` template.
web: Build.LazyPath,
/// The GLSL declaration generator (see `addGlslLayouts`).
@@ -1636,6 +1649,7 @@ pub const App = struct {
.imports = app.imports,
});
if (options.root_source_file != null) module.addImport("app", app.module);
+ module.linkLibrary(app.sb.text);
return b.addTest(.{ .root_module = module });
}