Add reusable xdelta3 static library - #295
Merged
Merged
Conversation
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>
`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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.