basisu_wuffs.cpp defines WUFFS_IMPLEMENTATION and #includes the unmodified encoder/3rdparty/wuffs-v0.4.c with all warnings silenced in that TU only (MSVC #pragma warning(push, 0)/pop; gcc/clang diagnostic push/ignored/pop). basisu_wuffs_config.h holds the Wuffs configuration (modules BASE core/ interfaces/pixconv, ADLER32, CRC32, DEFLATE, ZLIB, PNG, JPEG, TARGA, QOI; RGBA_NONPREMUL destination only; WUFFS_CONFIG__AVOID_CPU_ARCH = no SIMD), shared with basisu_enc.cpp's declarations-only include (next commit). With BASISU_USE_WUFFS_LDR_LOADER=0 the TU compiles to nothing. Added to every build that compiles the encoder: root CMakeLists.txt (native, -m32, WASI, Python module) with a BASISU_USE_WUFFS_LDR_LOADER option (default ON), webgl/encoder/CMakeLists.txt (all Emscripten variants, same option), and encoder_lib.vcxproj/.filters (basisu.sln: basisu, examples). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Prebuilt versions of basis_encoder.js and basis_encoder.wasm are included in the build/ folder, and are sufficient for local demos. Note the encoder also includes the transcoder. To build the encoder yourself, first install emscripten (tutorial) and cmake (download). Then run:
cd webgl/encoder/build/
emcmake cmake ../
make
Strict Content-Security-Policy (no unsafe-eval)
By default, the generated JavaScript glue uses new Function() to build its
embind bindings at runtime. A Content-Security-Policy without 'unsafe-eval'
blocks this, and module startup fails with an EvalError. To build glue that
never calls eval() or new Function(), add -DNO_DYNAMIC_EXECUTION=ON:
emcmake cmake ../ -DNO_DYNAMIC_EXECUTION=ON
make
This adds -s DYNAMIC_EXECUTION=0 -s EMBIND_AOT=1 to the link flags. The
.wasm file does not change. EMBIND_AOT generates the bindings at build
time, so JavaScript-to-WASM calls stay as fast as in the default build. The
page still needs 'wasm-unsafe-eval' in script-src to compile the
WebAssembly module. Use -DEMBIND_AOT=OFF to get the smaller, generic
bindings, which are slower per call.