mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 08:02:39 +08:00
145 lines
5.5 KiB
YAML
145 lines
5.5 KiB
YAML
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: mymindstorm/setup-emsdk@v14
|
|
with:
|
|
version: 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 3.8 WASM
|
|
run: |
|
|
cd native/cocos/editor-support/spine-wasm
|
|
mkdir build-wasm
|
|
cd build-wasm
|
|
emcmake cmake .. -GNinja
|
|
ninja
|
|
ls -l
|
|
|
|
- name: Build Spine 3.8 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 Spine 3.8 files to external directory
|
|
run: |
|
|
DIST_PATH="dist/3.8"
|
|
rm -rf $DIST_PATH
|
|
mkdir -p $DIST_PATH
|
|
cp native/cocos/editor-support/spine-wasm/build-wasm/spine.wasm ./$DIST_PATH
|
|
cp native/cocos/editor-support/spine-wasm/build-wasm/spine.js ./$DIST_PATH/spine.wasm.js
|
|
cp native/cocos/editor-support/spine-wasm/build-asmjs/spine.js.mem ./$DIST_PATH/
|
|
cp native/cocos/editor-support/spine-wasm/build-asmjs/spine.js ./$DIST_PATH/spine.asm.js
|
|
echo "-------- Before replace spine wasm -----------"
|
|
mkdir -p native/external/emscripten/spine/3.8
|
|
ls -l native/external/emscripten/spine/3.8
|
|
cp -f ./$DIST_PATH/* native/external/emscripten/spine/3.8
|
|
echo "-------- After replace spine wasm ------------"
|
|
ls -l native/external/emscripten/spine/3.8
|
|
echo "-----------------------------------------------"
|
|
cd native/external
|
|
git status
|
|
|
|
- name: Build Spine 4.2 WASM
|
|
run: |
|
|
cd native/cocos/editor-support/spine-wasm
|
|
sed -i 's/set(BUILD_WASM 0)/set(BUILD_WASM 1)/g' CMakeLists.txt
|
|
sed -i 's/set(SPINE_VERSION "3.8")/set(SPINE_VERSION "4.2")/g' CMakeLists.txt
|
|
rm -rf build-wasm
|
|
mkdir build-wasm
|
|
cd build-wasm
|
|
emcmake cmake .. -GNinja
|
|
ninja
|
|
ls -l
|
|
|
|
- name: Build Spine 4.2 ASMJS
|
|
run: |
|
|
cd native/cocos/editor-support/spine-wasm
|
|
sed -i 's/set(SPINE_VERSION "3.8")/set(SPINE_VERSION "4.2")/g' CMakeLists.txt
|
|
sed -i 's/set(BUILD_WASM 1)/set(BUILD_WASM 0)/g' CMakeLists.txt
|
|
rm -rf build-asmjs
|
|
mkdir build-asmjs
|
|
cd build-asmjs
|
|
emcmake cmake .. -GNinja
|
|
ninja
|
|
ls -l
|
|
|
|
- name: Copy Spine 4.2 files to external directory
|
|
run: |
|
|
DIST_PATH="dist/4.2"
|
|
rm -rf $DIST_PATH
|
|
mkdir -p $DIST_PATH
|
|
cp native/cocos/editor-support/spine-wasm/build-wasm/spine.wasm ./$DIST_PATH
|
|
cp native/cocos/editor-support/spine-wasm/build-wasm/spine.js ./$DIST_PATH/spine.wasm.js
|
|
cp native/cocos/editor-support/spine-wasm/build-asmjs/spine.js.mem ./$DIST_PATH/
|
|
cp native/cocos/editor-support/spine-wasm/build-asmjs/spine.js ./$DIST_PATH/spine.asm.js
|
|
echo "-------- Before replace spine wasm -----------"
|
|
mkdir -p native/external/emscripten/spine/4.2/
|
|
ls -l native/external/emscripten/spine/4.2/
|
|
cp -f ./$DIST_PATH/* native/external/emscripten/spine/4.2/
|
|
echo "-------- After replace spine wasm ------------"
|
|
ls -l native/external/emscripten/spine/4.2/
|
|
echo "-----------------------------------------------"
|
|
cd native/external
|
|
git status
|
|
|
|
- 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
|