This commit is contained in:
Jorijn van der Graaf 2026-05-18 22:31:28 +02:00
commit 765cf33069
6 changed files with 10895 additions and 11 deletions

View file

@ -46,7 +46,12 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
// through to /usr/include and pick up a system libdeflate of a different
// ABI (1.25 dropped LIBDEFLATEEXPORT) instead of the vendored 1.8 fork.
cfg.compileFlags.push_back(std::format("-I{}", fs::absolute("lib/gdeflate/libdeflate").string()));
const std::array<fs::path, 12> libdeflateSources = {
// libdeflate's lib/x86/ subdir is x86-specific CPU-feature detection
// (CPUID + AVX checks); compiling it for wasm32 fails on the inline
// assembly and missing intrinsics. wasm32 builds skip it; libdeflate's
// dispatcher falls through to the generic C path.
const bool isWasm = cfg.target.find("wasm") != std::string::npos;
std::vector<fs::path> libdeflateSources = {
"lib/gdeflate/libdeflate/lib/adler32",
"lib/gdeflate/libdeflate/lib/crc32",
"lib/gdeflate/libdeflate/lib/deflate_compress",
@ -58,8 +63,10 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
"lib/gdeflate/libdeflate/lib/utils",
"lib/gdeflate/libdeflate/lib/zlib_compress",
"lib/gdeflate/libdeflate/lib/zlib_decompress",
"lib/gdeflate/libdeflate/lib/x86/cpu_features",
};
if (!isWasm) {
libdeflateSources.emplace_back("lib/gdeflate/libdeflate/lib/x86/cpu_features");
}
for (const fs::path& p : libdeflateSources) cfg.cFiles.push_back(p);
std::array<fs::path, 4> ifaces = {