From 9b484a3a67c1e736388bd9059d2c93ba99488932 Mon Sep 17 00:00:00 2001 From: Jeremy Collins Date: Mon, 24 Aug 2026 22:16:44 -0400 Subject: [PATCH] Build the codecs from source by default on every target --- build.zig | 14 +++++--------- build/codecs.zig | 7 ++----- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/build.zig b/build.zig index 8567c7c..286986d 100644 --- a/build.zig +++ b/build.zig @@ -54,21 +54,17 @@ pub fn build(b: *std.Build) void { // reference for correctness. const use_libpng = b.option(bool, "libpng", "Decode PNG with libpng instead of the built-in reader") orelse true; // A directory holding cross-built codec archives: include/ plus - // lib/libwebp.a and lib/libpng16.a. Set it for a target that has no system - // package manager, such as an iOS or visionOS device. Left unset, the codecs - // come from Homebrew on macOS and from the system elsewhere. + // lib/libwebp.a and lib/libpng16.a, for a build that wants neither the + // bundled sources nor the platform's copies. // An empty value counts as unset, so an embedder can pass the option // unconditionally. const codec_dir: ?[]const u8 = blk: { const d = b.option([]const u8, "codec-dir", "Directory of cross-built codec archives (include/ + lib/)") orelse break :blk null; break :blk if (d.len == 0) null else d; }; - // Compile the codecs from source instead of taking them from the platform. - // Windows and Android have neither Homebrew nor a system copy, so they turn - // it on by themselves. A cross build asks for it too: the system headers of - // the host describe the host, and a release wants an archive that carries - // its own decoders rather than one that hunts for them on the target. - const codec_source = b.option(bool, "codec-source", "Compile libwebp and libpng from source") orelse (windows or android); + // On for every target; a distro build that must link the platform's + // codecs passes -Dcodec-source=false. + const codec_source = b.option(bool, "codec-source", "Compile libwebp and libpng from source") orelse true; // The version the library reports and the shared library stamps into its // soname. A release passes the tag, so nobody hand-edits a version to match // one. build.zig.zon carries the default, for every other build. diff --git a/build/codecs.zig b/build/codecs.zig index 6d09c58..18f3731 100644 --- a/build/codecs.zig +++ b/build/codecs.zig @@ -1,10 +1,7 @@ //! libwebp, libpng and zlib compiled from source into the charttable module. //! -//! The other targets take these from the platform: Homebrew's static archives -//! on macOS, the system packages elsewhere, or a directory of cross-built -//! archives named by `-Dcodec-dir`. Windows has none of those, and the option -//! defaults are on, so the sources are fetched by the package manager -//! (build.zig.zon) and built here. +//! The default on every target; `-Dcodec-source=false` links the platform's +//! libraries instead, `-Dcodec-dir` names cross-built archives. //! //! Only the decoders are built. charttable reads tiles; it never writes a WebP //! or a PNG, so libwebp's encoder, mux and demux are left out and libpng's