Skip to content

Commit 15bbe8b

Browse files
committed
Testing - WebAssembly build validation #256
Add GitHub Actions workflow for WebAssembly build validation on Windows using MinGW
1 parent e9855c9 commit 15bbe8b

File tree

1 file changed

+122
-0
lines changed

1 file changed

+122
-0
lines changed
+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# This workflow validates the WebAssembly build on Windows using MinGW and MSYS2.
2+
# It is triggered on pushes to the master branch.
3+
# The workflow includes steps to install dependencies, configure, build, and clean up the project.
4+
5+
name: WebAssembly build
6+
7+
on:
8+
pull_request:
9+
branches:
10+
- '**'
11+
push:
12+
branches:
13+
- 'master'
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
17+
cancel-in-progress: true
18+
19+
env:
20+
USERNAME: Open-Cascade-SAS
21+
VCPKG_EXE: ${{ github.workspace }}/vcpkg/vcpkg
22+
FEED_URL: https://nuget.pkg.github.com/Open-Cascade-SAS/index.json
23+
VCPKG_BINARY_SOURCES: "clear;nuget,https://nuget.pkg.github.com/Open-Cascade-SAS/index.json,readwrite"
24+
EMSDK_VERSION: 3.1.51
25+
26+
jobs:
27+
wasm-build:
28+
name: WebAssembly Build
29+
runs-on: windows-2022
30+
31+
strategy:
32+
matrix:
33+
build_type: [Debug, Release]
34+
35+
steps:
36+
- name: Checkout repository
37+
uses: actions/[email protected]
38+
39+
- name: Set up MSYS2
40+
uses: msys2/setup-msys2@v2
41+
with:
42+
msystem: MINGW64
43+
update: true
44+
install: >-
45+
mingw-w64-x86_64-toolchain
46+
mingw-w64-x86_64-cmake
47+
mingw-w64-x86_64-ninja
48+
49+
- name: Setup Emscripten
50+
uses: mymindstorm/setup-emsdk@v14
51+
with:
52+
version: ${{ env.EMSDK_VERSION }}
53+
actions-cache-folder: emsdk-cache
54+
55+
- name: Setup vcpkg
56+
run: |
57+
git clone https://github.com/microsoft/vcpkg.git
58+
.\vcpkg\bootstrap-vcpkg.bat
59+
shell: cmd
60+
61+
- name: Add NuGet sources
62+
run: |
63+
.$(${{ env.VCPKG_EXE }} fetch nuget) `
64+
sources add `
65+
-Source "${{ env.FEED_URL }}" `
66+
-StorePasswordInClearText `
67+
-Name GitHubPackages `
68+
-UserName "${{ env.USERNAME }}" `
69+
-Password "${{ secrets.GITHUB_TOKEN }}"
70+
.$(${{ env.VCPKG_EXE }} fetch nuget) `
71+
setapikey "${{ secrets.GITHUB_TOKEN }}" `
72+
-Source "${{ env.FEED_URL }}"
73+
shell: pwsh
74+
75+
- name: Configure VCPKG
76+
shell: bash
77+
run: |
78+
mkdir -p build-${{ matrix.build_type }}
79+
cd build-${{ matrix.build_type }}
80+
emcmake cmake -G "Ninja" \
81+
-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake \
82+
-DVCPKG_TARGET_TRIPLET=wasm32-emscripten \
83+
-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \
84+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
85+
-DBUILD_USE_VCPKG=ON \
86+
-DUSE_MMGR_TYPE=NATIVE \
87+
-DBUILD_LIBRARY_TYPE=Static \
88+
-DBUILD_MODULE_Draw=OFF \
89+
-DUSE_FREETYPE=ON \
90+
-DUSE_TK=OFF \
91+
-DUSE_DRACO=ON \
92+
-DUSE_FFMPEG=OFF \
93+
-DUSE_FREEIMAGE=ON \
94+
-DUSE_GLES2=ON \
95+
-DUSE_OPENVR=OFF \
96+
-DUSE_VTK=OFF \
97+
-DUSE_TBB=OFF \
98+
-DUSE_RAPIDJSON=ON \
99+
-DUSE_OPENGL=ON \
100+
-DINSTALL_DIR="${{ github.workspace }}/install-wasm-${{ matrix.build_type }}" \
101+
-DCMAKE_CXX_FLAGS="-s WASM=1 -s EXPORTED_RUNTIME_METHODS=['ccall','cwrap'] -s ALLOW_MEMORY_GROWTH=1" \
102+
-DCMAKE_EXECUTABLE_SUFFIX=".js" \
103+
..
104+
105+
- name: Build
106+
shell: bash
107+
run: |
108+
cd build-${{ matrix.build_type }}
109+
cmake --build . --config ${{ matrix.build_type }} --target install -- -j4
110+
111+
- name: Upload artifacts
112+
uses: actions/upload-artifact@v4
113+
with:
114+
name: wasm-build-${{ matrix.build_type }}
115+
path: install-wasm-${{ matrix.build_type }}
116+
retention-days: 7
117+
118+
- name: Clear build directory
119+
shell: pwsh
120+
run: |
121+
Remove-Item -Recurse -Force build-${{ matrix.build_type }}
122+
Remove-Item -Recurse -Force install-wasm-${{ matrix.build_type }}

0 commit comments

Comments
 (0)