Skip to content

Add reusable xdelta3 static library - #295

Merged
jmacd merged 5 commits into
mainfrom
jmacd/static
Jun 21, 2026
Merged

Add reusable xdelta3 static library#295
jmacd merged 5 commits into
mainfrom
jmacd/static

Conversation

@jmacd

@jmacd jmacd commented Jun 20, 2026

Copy link
Copy Markdown
Owner

Build the unity-build xdelta3.c once as a reusable core library (libxdelta3, alias xdelta3::xdelta3) compiled with XD3_MAIN=0, gated by the new XD3_BUILD_LIB option (default ON). Install it with a CMake package config (find_package(xdelta3)) and a relocatable pkg-config file, exporting the usize_t/ABI-sizing macros on the library's interface so consumers need no config.h. XD3_LIB_LZMA (default OFF) optionally compiles in and propagates liblzma. A new lib_smoke.c consumer runs an encode/decode round-trip as a ctest, and a library-consumer CI job exercises the installed find_package and pkg-config flows.

Make the default RFC 3284 code table a compile-time const array instead of a lazily-initialized static, removing the one data race in the core so concurrent streams are safe. A debug-only check asserts it still matches xd3_build_code_table.

Add the XD3_SECONDARY_FGK option (default OFF): FGK adaptive-Huffman secondary compression is effectively unused since DJW is the only secondary compressor xdelta3 selects on its own, so it is now disabled in the tool and the library by default. The regression-test targets still build it to keep its code path covered.

jmacd and others added 2 commits June 20, 2026 16:41
Build the unity-build xdelta3.c once as a reusable core library
(libxdelta3, alias xdelta3::xdelta3) compiled with XD3_MAIN=0, gated by
the new XD3_BUILD_LIB option (default ON).  Install it with a CMake
package config (find_package(xdelta3)) and a relocatable pkg-config file,
exporting the usize_t/ABI-sizing macros on the library's interface so
consumers need no config.h.  XD3_LIB_LZMA (default OFF) optionally
compiles in and propagates liblzma.  A new lib_smoke.c consumer runs an
encode/decode round-trip as a ctest, and a library-consumer CI job
exercises the installed find_package and pkg-config flows.

Make the default RFC 3284 code table a compile-time const array instead
of a lazily-initialized static, removing the one data race in the core so
concurrent streams are safe.  A debug-only check asserts it still matches
xd3_build_code_table.

Add the XD3_SECONDARY_FGK option (default OFF): FGK adaptive-Huffman
secondary compression is effectively unused since DJW is the only
secondary compressor xdelta3 selects on its own, so it is now disabled in
the tool and the library by default.  The regression-test targets still
build it to keep its code path covered.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jmacd and others added 3 commits June 20, 2026 16:52
`cmake --install` of an armor-enabled build aborted because BLAKE3's
FetchContent install rules try to install a libblake3.pc that it
generates in the wrong directory, and the fetched dependencies also
polluted the install prefix.  Mark the liblzma and BLAKE3 FetchContent
declarations EXCLUDE_FROM_ALL (CMake >= 3.28) so their targets are still
statically linked but contribute no install rules.

Also build the library-install consumer CI job with XD3_ARMOR=OFF: the
library never includes armor, so it needs neither BLAKE3 nor the fetch.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The installed package exported the target under its internal name
(xdelta3::xdelta3lib), so a consumer using the documented
xdelta3::xdelta3 imported target failed to configure against a clean
install.  This was masked locally because find_package resolved to the
build tree via CMake's package registry, where the xdelta3::xdelta3 alias
exists.  Set EXPORT_NAME so the installed imported target matches the
alias, the consumer test, and the README.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Applying EXCLUDE_FROM_ALL to the xz (liblzma) FetchContent build left its
CTest test executables unbuilt while xz still registered them, so the
XD3_LZMA_FETCH test run reported them as "Not Run" failures.  Only BLAKE3
needs the exclusion (to drop its broken libblake3.pc install rule), so
scope it to BLAKE3 and let xz build and run its own tests as before.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jmacd
jmacd merged commit 19bab1c into main Jun 21, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant