Skip to content

Testing - WebAssembly build validation #13

Testing - WebAssembly build validation

Testing - WebAssembly build validation #13

# This workflow validates the WebAssembly build on Windows using MinGW and MSYS2.
# It is triggered on pushes to the master branch.
# The workflow includes steps to install dependencies, configure, build, and clean up the project.
name: WebAssembly build
on:
pull_request:
branches:
- '**'
push:
branches:
- 'master'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
env:
USERNAME: Open-Cascade-SAS
VCPKG_EXE: ${{ github.workspace }}/vcpkg/vcpkg
FEED_URL: https://nuget.pkg.github.com/Open-Cascade-SAS/index.json
VCPKG_BINARY_SOURCES: "clear;nuget,https://nuget.pkg.github.com/Open-Cascade-SAS/index.json,readwrite"
EMSDK_VERSION: 3.1.51
jobs:
wasm-build:
name: WebAssembly Build
runs-on: windows-2022
strategy:
matrix:
build_type: [Debug, Release]
steps:
- name: Checkout repository
uses: actions/[email protected]
- name: Set up MSYS2
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
install: >-
mingw-w64-x86_64-toolchain
mingw-w64-x86_64-cmake
mingw-w64-x86_64-ninja
git
- name: Setup vcpkg
run: |
git clone https://github.com/microsoft/vcpkg.git
.\vcpkg\bootstrap-vcpkg.bat
shell: cmd
- name: Add NuGet sources
run: |
.$(${{ env.VCPKG_EXE }} fetch nuget) sources add -Source "${{ env.FEED_URL }}" -StorePasswordInClearText -Name GitHubPackages -UserName "${{ env.USERNAME }}" -Password "${{ secrets.GITHUB_TOKEN }}"
.$(${{ env.VCPKG_EXE }} fetch nuget) setapikey "${{ secrets.GITHUB_TOKEN }}" -Source "${{ env.FEED_URL }}"
shell: pwsh
- name: Setup Emscripten
run: |
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install ${{ env.EMSDK_VERSION }}
./emsdk activate ${{ env.EMSDK_VERSION }}
echo "EMSDK=${{ github.workspace }}/emsdk" >> $GITHUB_ENV
echo "${{ github.workspace }}/emsdk" >> $GITHUB_PATH
echo "${{ github.workspace }}/emsdk/upstream/emscripten" >> $GITHUB_PATH
shell: bash
- name: Configure OCCT with vcpkg
shell: bash
run: |
source "${{ github.workspace }}/emsdk/emsdk_env.sh"
mkdir -p "build-${{ matrix.build_type }}"
cd "build-${{ matrix.build_type }}"
set "VCPKG_ROOT=${{ github.workspace }}/vcpkg"
emcmake cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=wasm32-emscripten -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE="$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake" -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DBUILD_USE_VCPKG=ON -DUSE_MMGR_TYPE=NATIVE -DBUILD_LIBRARY_TYPE=Static -DBUILD_MODULE_Draw=OFF -DUSE_FREETYPE=ON -DUSE_TK=OFF -DUSE_DRACO=ON -DUSE_FFMPEG=OFF -DUSE_FREEIMAGE=ON -DUSE_GLES2=OFF -DUSE_OPENVR=OFF -DUSE_VTK=OFF -DUSE_TBB=OFF -DUSE_RAPIDJSON=ON -DUSE_OPENGL=OFF -DINSTALL_DIR="${{ github.workspace }}/install-wasm-${{ matrix.build_type }}" -DCMAKE_CXX_FLAGS="-s WASM=1 -s EXPORTED_RUNTIME_METHODS=['ccall','cwrap'] -s ALLOW_MEMORY_GROWTH=1" -DCMAKE_EXECUTABLE_SUFFIX=".js" ..
- name: Build
shell: bash
run: |
cd build-${{ matrix.build_type }}
cmake --build . --config ${{ matrix.build_type }} --target install -- -j4