From a40593cc42eaf3f3ef212131ebcaa4b9fce6dba1 Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Wed, 14 Oct 2026 11:15:02 -0500 Subject: [PATCH] Depend on the decoders and the sound-output libraries zig-riff, zig-ogg, zig-flac, zig-opus and zig-mp3 for the formats a Sound is loaded from, and zig-pipewire and zig-wsapi for the sound output, each lazy so that only the target's own backend is fetched. All are on Zig 0.17. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013GnDsfLDmzoHCS7p8w1dKf --- build.zig | 21 +++++++++++++++++++++ build.zig.zon | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/build.zig b/build.zig index 68cb8ea..d497c29 100644 --- a/build.zig +++ b/build.zig @@ -17,6 +17,27 @@ pub fn build(b: *std.Build) void { .optimize = optimize, }); + // The decoders, one per format a Sound can be loaded from. zig-ogg is + // named directly as well as through zig-flac because Opus lives in Ogg + // too, and zig-opus does not unwrap it. + inline for (.{ "riff", "ogg", "flac", "opus", "mp3" }) |name| { + const dep = b.dependency(name, .{ .target = target, .optimize = optimize }); + mod.addImport(name, dep.module(name)); + } + + // The sound output, which is the only part that differs by platform. The + // other platform's backend is lazy, so it is never fetched for a build + // that cannot use it. + switch (target.result.os.tag) { + .linux => if (b.lazyDependency("pipewire", .{ .target = target, .optimize = optimize })) |dep| { + mod.addImport("pipewire", dep.module("pipewire")); + }, + .windows => if (b.lazyDependency("wasapi", .{ .target = target, .optimize = optimize })) |dep| { + mod.addImport("wasapi", dep.module("wasapi")); + }, + else => {}, + } + const test_step = b.step("test", "Run the unit tests"); // LLVM rather than the self-hosted backend, which emits no coverage // instrumentation for kcov or the fuzzer to read. diff --git a/build.zig.zon b/build.zig.zon index 3edf288..3a07ca9 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -3,7 +3,38 @@ .version = "0.0.0", .fingerprint = 0x4caf55fe26b1dc8f, // Changing this has security and trust implications. .minimum_zig_version = "0.17.0", - .dependencies = .{}, + .dependencies = .{ + .riff = .{ + .url = "git+https://git.jcollie.dev/jeff/zig-riff.git#95720d487115c285f5b890e5788499f3931a4d26", + .hash = "riff-0.3.0-HAfI3hvpAAC0x2BglCLXC8KbAh-2QsqaM7iGWlOdcji3", + }, + .ogg = .{ + .url = "git+https://git.jcollie.dev/jeff/zig-ogg.git#705662b256cab123aa29bd020d7b8521a7a5760c", + .hash = "ogg-0.3.0-AI2CC7inAgCAi7EVrxJdEgzXHSw4t3h3fr4IYA4W_dWw", + }, + .flac = .{ + .url = "git+https://git.jcollie.dev/jeff/zig-flac.git#89fffae87114a8d15329c95cde86b3a963fba16b", + .hash = "flac-0.3.0-16osTGHcBQDqxVR-qhyvJhZ1vsH4wWNNUkyLB8VQDor4", + }, + .opus = .{ + .url = "git+https://git.jcollie.dev/jeff/zig-opus.git#da36b08c851be33eaaf712c2b9aa93dc78512df1", + .hash = "opus-0.4.0-JoIcxmQyFwBPc8olZV40rXMhTxg5io5m5qsc0AUdTa6v", + }, + .mp3 = .{ + .url = "git+https://git.jcollie.dev/jeff/zig-mp3.git#630798ae9e98bffe641c44d70571f206421f4e24", + .hash = "zig_mp3-0.2.0-yG5WDJfgDgAhAmcQYpSUFiO1bfXoW9XpTOXgLRgmAFU6", + }, + .pipewire = .{ + .url = "git+https://git.jcollie.dev/jeff/zig-pipewire.git#b97236221878cae8cea64b46a912df8f342dad8c", + .hash = "pipewire-0.2.0-lH35Hg-dBgAl54C6I1srRR_4pjWFIHkgWoqOtYY8aJ1g", + .lazy = true, + }, + .wasapi = .{ + .url = "git+https://git.jcollie.dev/jeff/zig-wsapi.git#ee982775975bb633ab60bbcb5cc8410dbb4ac7b5", + .hash = "wasapi-0.2.0-Y48zc6T8BgC7s-Eo-qUz5GDtxbwP4Qx80WZM0tchtr_p", + .lazy = true, + }, + }, .paths = .{ "build.zig", "build.zig.zon", -- knotmirror 0.0.1