Build wasm/asmjs libraryies #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build wasm/asmjs libraryies | |
on: | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: "Select a library" | |
required: true | |
default: "Spine" | |
type: choice | |
options: | |
- Spine | |
jobs: | |
build_spine_wasm_asmjs: | |
name: "Build spine wasm/asmjs libs" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup emsdk | |
uses: dumganhar/setup-emsdk@997d2cde2deabda085a11f98e86e842915b0e846 | |
with: | |
version: 3.1.41 | |
actions-cache-folder: 'emsdk-cache-3.1.41' | |
- name: Verify | |
run: | | |
which emcc | |
emcc -v | |
- name: Install ninja | |
run: | | |
if ! command -v ninja &> /dev/null; then | |
echo "Ninja not found, installing..." | |
# sudo apt update | |
sudo apt install ninja-build | |
else | |
echo "Ninja is already installed." | |
fi | |
which ninja | |
- name: Apply emscripten patches | |
run: | | |
echo "--------------------------------- Save bind.cpp ---------------------------------" | |
cp $EMSDK/upstream/emscripten/system/lib/embind/bind.cpp $EMSDK/upstream/emscripten/system/lib/embind/bind.cpp.bak | |
echo "--------------------------------- Apply embind bind.cpp patches ---------------------------------" | |
cp -f .github/workflows/emscripten-patches/embind/bind.cpp $EMSDK/upstream/emscripten/system/lib/embind/ | |
echo "--------------------------------- Apply patches DONE! ---------------------------------" | |
cat $EMSDK/upstream/emscripten/system/lib/embind/bind.cpp | |
- name: Build Spine WASM | |
run: | | |
cd ./native/cocos/editor-support/spine-wasm | |
mkdir build-wasm | |
cd build-wasm | |
emcmake cmake .. -GNinja | |
ninja | |
ls -l | |
- name: Build Spine ASMJS | |
run: | | |
cd ./native/cocos/editor-support/spine-wasm | |
sed -i 's/set(BUILD_WASM 1)/set(BUILD_WASM 0)/g' CMakeLists.txt | |
mkdir build-asmjs | |
cd build-asmjs | |
emcmake cmake .. -GNinja | |
ninja | |
ls -l | |
- name: Copy files to dist directory | |
run: | | |
mkdir dist | |
cp ./native/cocos/editor-support/spine-wasm/build-wasm/spine.wasm ./dist/ | |
cp ./native/cocos/editor-support/spine-wasm/build-wasm/spine.js ./dist/spine.wasm.js | |
cp ./native/cocos/editor-support/spine-wasm/build-asmjs/spine.js.mem ./dist/ | |
cp ./native/cocos/editor-support/spine-wasm/build-asmjs/spine.js ./dist/spine.asm.js | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: spine-emscripten | |
path: dist | |
- name: Restore patches | |
run: | | |
echo "-------------------------- Restore patches ---------------------------------" | |
rm $EMSDK/upstream/emscripten/system/lib/embind/bind.cpp | |
mv $EMSDK/upstream/emscripten/system/lib/embind/bind.cpp.bak $EMSDK/upstream/emscripten/system/lib/embind/bind.cpp | |
echo "-------------------------- Restore patches DONE! ---------------------------------" | |
cat $EMSDK/upstream/emscripten/system/lib/embind/bind.cpp |