summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-16 20:31:59 -0300
committerGabriel Schneider <[email protected]>2026-11-16 20:31:59 -0300
commit82fca5c9f29124f37f6dcd08e73e6999ce44a69d (patch)
treeb3d5487659aa933d47699e5e420fa6140b0b75f3 /build.zig
parente77b01d4b5504cea08a3f88cf8502897d868a1d3 (diff)
downloadsketchbook-82fca5c9f29124f37f6dcd08e73e6999ce44a69d.tar.gz
sketchbook-82fca5c9f29124f37f6dcd08e73e6999ce44a69d.zip
Add display-paced frame timing and presentation feedback in Zig
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig16
1 files changed, 16 insertions, 0 deletions
diff --git a/build.zig b/build.zig
index efb4dfb..1933d92 100644
--- a/build.zig
+++ b/build.zig
@@ -79,6 +79,9 @@ pub fn build(b: *Build) void {
});
b.step("test-control", "Test 9P control validation and screenshot snapshots").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = host, .filters = &.{ "control writes", "9P reads" } })).step);
+ b.step("test-timing", "Test display clock, recorded ticks, timing history and console controls").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = host, .filters = &.{ "timing", "presentation", "frames are whole", "a tick's dt" } })).step);
+
+ b.step("test-presentation", "Test presentation feedback, pacing and trace snapshots").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = host, .filters = &.{"presentation"} })).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);
@@ -356,6 +359,11 @@ fn cModule(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.Optimi
\\#include <SDL3/SDL.h>
\\#include "codecs.h"
\\#include "text.h"
+ \\#if defined(__linux__)
+ \\#include <time.h>
+ \\#include <wayland-client.h>
+ \\#include "presentation-time-client-protocol.h"
+ \\#endif
),
.target = target,
.optimize = optimize,
@@ -364,6 +372,14 @@ fn cModule(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.Optimi
translator.addIncludePath(b.path("vendor"));
translator.mod.addCSourceFile(.{ .file = b.path("vendor/codecs.c"), .flags = &.{"-fno-sanitize=undefined"} });
if (target.result.os.tag == .linux) {
+ const protocol = b.path("vendor/presentation-time/presentation-time.xml");
+ const header = b.addSystemCommand(&.{ "wayland-scanner", "client-header" });
+ header.addFileArg(protocol);
+ translator.addIncludePath(header.addOutputFileArg("presentation-time-client-protocol.h").dirname());
+ const source = b.addSystemCommand(&.{ "wayland-scanner", "private-code" });
+ source.addFileArg(protocol);
+ translator.mod.addCSourceFile(.{ .file = source.addOutputFileArg("presentation-time-protocol.c"), .flags = &.{"-std=c99"} });
+ translator.mod.linkSystemLibrary("wayland-client", .{ .use_pkg_config = .force });
translator.mod.addCSourceFile(.{ .file = b.path("vendor/text.c"), .flags = &.{"-std=c23"} });
translator.mod.linkSystemLibrary("pangocairo-1.0", .{ .use_pkg_config = .force });
translator.mod.linkSystemLibrary("pangoft2-1.0", .{ .use_pkg_config = .force });