summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-07-08 12:25:04 -0300
committerGabriel Schneider <[email protected]>2026-08-01 15:02:07 -0300
commit172eb56fee0b6bde698e72be2bca55a90fe81ce9 (patch)
treef2fd94709facf134c3670db4c1a20a5eaca1d53d /build.zig
parentb91e5ebf8b529d0ced0bf18e83b17df0bd2374ce (diff)
downloadpardes-172eb56fee0b6bde698e72be2bca55a90fe81ce9.tar.gz
pardes-172eb56fee0b6bde698e72be2bca55a90fe81ce9.zip
steam deck nice version
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig51
1 files changed, 47 insertions, 4 deletions
diff --git a/build.zig b/build.zig
index d0b4496e..a387db9e 100644
--- a/build.zig
+++ b/build.zig
@@ -5,7 +5,17 @@ pub const TreeSitterGrammars = enum { disabled, minimal, full };
const GhosttyArtifact = enum { ghostty, lib };
pub fn build(b: *std.Build) void {
- const target = b.standardTargetOptions(.{});
+ // Default target is the Steam Deck (deckcap's trick): x86_64 linux-gnu
+ // with the glibc version pinned low, so a binary built on a rolling-
+ // release host runs on SteamOS — a native build references the host's
+ // newer versioned libm/libc symbols and dies with "GLIBC_2.4x not found"
+ // on the deck. Override with -Dtarget= as usual.
+ const target = b.standardTargetOptions(.{ .default_target = .{
+ .cpu_arch = .x86_64,
+ .os_tag = .linux,
+ .abi = .gnu,
+ .glibc_version = .{ .major = 2, .minor = 38, .patch = 0 },
+ } });
const requested_optimize = b.standardOptimizeOption(.{});
const platform = b.option(Platform, "platform", "which shell to build (tty, gui, web)") orelse .tty;
const static = b.option(bool, "static", "statically link") orelse false;
@@ -284,10 +294,16 @@ pub fn build(b: *std.Build) void {
// the SPIR-V compiled at build time from shaders/*.glsl — or, on web, the
// GL ES shader sources compiled at runtime by WebGL.
if (platform == .gui or platform == .web) {
+ // sanitize_c MUST stay off: zig cc's UBSan (on for C in Debug AND
+ // ReleaseSafe) traps hidapi's mismatched fn-pointer calls the moment
+ // a HID gamepad is enumerated — SDL_Init SIGILLs on the deck itself
+ // (ud2 in SDL_hid_set_nonblocking_REAL); headless boxes never see it.
+ // SDL3 always statically linked (like deckcap): the gui binary must
+ // only need system libc/libm — never a shared libSDL3.
const sdl_dep = if (emscripten_include) |include|
- b.lazyDependency("sdl", .{ .target = target, .optimize = optimize, .system_include_path = include })
+ b.lazyDependency("sdl", .{ .target = target, .optimize = optimize, .sanitize_c = .off, .preferred_linkage = .static, .system_include_path = include })
else
- b.lazyDependency("sdl", .{ .target = target, .optimize = optimize });
+ b.lazyDependency("sdl", .{ .target = target, .optimize = optimize, .sanitize_c = .off, .preferred_linkage = .static });
if (sdl_dep) |dep| {
const sdl_lib = dep.artifact("SDL3");
if (libc_file) |f| sdl_lib.setLibCFile(f);
@@ -326,6 +342,12 @@ pub fn build(b: *std.Build) void {
root_mod.addAnonymousImport("overlay.frag.spv", .{
.root_source_file = compileGlsl(b, "shaders/overlay.frag.glsl", "fragment", "overlay.frag.spv"),
});
+ root_mod.addAnonymousImport("crt.vert.spv", .{
+ .root_source_file = compileGlsl(b, "shaders/crt.vert.glsl", "vertex", "crt.vert.spv"),
+ });
+ root_mod.addAnonymousImport("crt.frag.spv", .{
+ .root_source_file = compileGlsl(b, "shaders/crt.frag.glsl", "fragment", "crt.frag.spv"),
+ });
}
}
@@ -436,7 +458,28 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
.root_source_file = b.path("src/modal.zig"),
}) });
- b.step("unit-test", "run the modal.zig unit tests").dependOn(&b.addRunArtifact(unit).step);
+ const unit_step = b.step("unit-test", "run the modal.zig + crt.zig + deck replay unit tests");
+ unit_step.dependOn(&b.addRunArtifact(unit).step);
+ // crt.zig is pure std — the mouse-mapping-vs-shader-formula test
+ const crt_test = b.addTest(.{ .root_module = b.createModule(.{
+ .target = target,
+ .optimize = optimize,
+ .root_source_file = b.path("src/crt.zig"),
+ }) });
+ unit_step.dependOn(&b.addRunArtifact(crt_test).step);
+ // deck.zig is pure std too; replay.zig drives it with slices of real
+ // Steam Deck recordings (test/deck/*.zon, deckcap capture format)
+ const deck_test = b.addTest(.{ .root_module = b.createModule(.{
+ .target = target,
+ .optimize = optimize,
+ .root_source_file = b.path("test/deck/replay.zig"),
+ }) });
+ deck_test.root_module.addImport("deck", b.createModule(.{
+ .target = target,
+ .optimize = optimize,
+ .root_source_file = b.path("src/deck.zig"),
+ }));
+ unit_step.dependOn(&b.addRunArtifact(deck_test).step);
}
}