Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 2 additions & 5 deletions build/codecs.zig
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading