This guide provides step-by-step instructions for setting up and building the Clipper2 WebAssembly (WASM) module.
Before you begin, ensure you have the following prerequisites installed on your system:
- Emscripten: Follow the installation steps detailed here.
- Important: Remember to install any dependencies and source the environment variables as described in the guide.
Change into the C++ directory:
cd clipper2/CPPSet up a build directory for out-of-source builds:
mkdir build
cd buildUse emcmake with cmake to generate the necessary build files:
emcmake cmake ../ \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_FLAGS_RELEASE="-O3" \
-DCLIPPER2_HI_PRECISION=OFFCompile the library files using emmake:
emmake makeThis step will create libClipper2.a and libClipper2Z.a library files.
Return to the root directory and run the WebAssembly compilation script:
cd ..
sh clipper2-wasm/compile-wasm.sh prodAfter completing these steps, you will find the WASM builds in the clipper2-wasm/dist directory.
Append --embind-emit-tsd ../clipper2z.d.ts to the ES6 export, manually add the Factory export and the glue-stub functions.