diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index 6a25a14..dde5e96 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -253,3 +253,57 @@ jobs: shell: bash run: | cmake --build cmake-build/build/android-release-vcpkg --target unit_tests omath + + ############################################################################## + # 6) WebAssembly (Emscripten) – Clang / Ninja / wasm32-emscripten + ############################################################################## + wasm-build-and-test: + name: WebAssembly (Emscripten) (wasm32-emscripten) + runs-on: ubuntu-latest + env: + VCPKG_ROOT: ${{ github.workspace }}/vcpkg + steps: + - name: Checkout repository (with sub-modules) + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install basic tool-chain + shell: bash + run: | + sudo apt-get update + sudo apt-get install -y ninja-build + + - name: Setup Emscripten + uses: mymindstorm/setup-emsdk@v14 + with: + version: 'latest' + + - name: Verify Emscripten + shell: bash + run: | + echo "EMSDK=$EMSDK" + emcc --version + # Verify toolchain file exists + ls -la "$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake" + + - name: Set up vcpkg + shell: bash + run: | + git clone https://github.com/microsoft/vcpkg "$VCPKG_ROOT" + cd "$VCPKG_ROOT" + ./bootstrap-vcpkg.sh + + - name: Configure (cmake --preset) + shell: bash + run: | + cmake --preset wasm-release-vcpkg \ + -DVCPKG_INSTALL_OPTIONS="--allow-unsupported" \ + -DOMATH_BUILD_TESTS=ON \ + -DOMATH_BUILD_BENCHMARK=OFF \ + -DVCPKG_MANIFEST_FEATURES="imgui;tests" + + - name: Build + shell: bash + run: | + cmake --build cmake-build/build/wasm-release-vcpkg --target unit_tests omath \ No newline at end of file diff --git a/CMakePresets.json b/CMakePresets.json index c718ce9..7f14cbc 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -327,6 +327,44 @@ "cacheVariables": { "CMAKE_BUILD_TYPE": "Release" } + }, + { + "name": "wasm-base", + "hidden": true, + "generator": "Ninja", + "binaryDir": "${sourceDir}/cmake-build/build/${presetName}", + "installDir": "${sourceDir}/cmake-build/install/${presetName}", + "cacheVariables": { + "CMAKE_MAKE_PROGRAM": "ninja" + } + }, + { + "name": "wasm-base-vcpkg", + "hidden": true, + "inherits": "wasm-base", + "cacheVariables": { + "OMATH_BUILD_VIA_VCPKG": "ON", + "CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", + "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "$env{EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake", + "VCPKG_INSTALLED_DIR": "${sourceDir}/cmake-build/vcpkg_installed", + "VCPKG_TARGET_TRIPLET": "wasm32-emscripten" + } + }, + { + "name": "wasm-debug-vcpkg", + "displayName": "WASM Debug Vcpkg", + "inherits": "wasm-base-vcpkg", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + }, + { + "name": "wasm-release-vcpkg", + "displayName": "WASM Release Vcpkg", + "inherits": "wasm-base-vcpkg", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } } ] } \ No newline at end of file