mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-03 01:12:42 +08:00
[v3.8.5] Reduce package size for spine module (#17783)
This commit is contained in:
@@ -67,12 +67,90 @@ jobs:
|
||||
ref: "${{ env.EXT_VERSION_HEAD }}"
|
||||
fetch-depth: 1
|
||||
|
||||
- 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: 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 ./engine-HEAD/.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: 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: Build Spine WASM
|
||||
run: |
|
||||
cd ./engine-HEAD/native/cocos/editor-support/spine-wasm
|
||||
mkdir build-wasm
|
||||
cd build-wasm
|
||||
emcmake cmake .. -GNinja
|
||||
ninja
|
||||
ls -l
|
||||
|
||||
- name: Build Spine ASMJS
|
||||
run: |
|
||||
cd ./engine-HEAD/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 external directory
|
||||
run: |
|
||||
mkdir dist
|
||||
cp ./engine-HEAD/native/cocos/editor-support/spine-wasm/build-wasm/spine.wasm ./dist/
|
||||
cp ./engine-HEAD/native/cocos/editor-support/spine-wasm/build-wasm/spine.js ./dist/spine.wasm.js
|
||||
cp ./engine-HEAD/native/cocos/editor-support/spine-wasm/build-asmjs/spine.js.mem ./dist/
|
||||
cp ./engine-HEAD/native/cocos/editor-support/spine-wasm/build-asmjs/spine.js ./dist/spine.asm.js
|
||||
echo "-------- Before replace spine wasm -----------"
|
||||
ls -l ./engine-HEAD/native/external/emscripten/spine/
|
||||
cp -f ./dist/* ./engine-HEAD/native/external/emscripten/spine/
|
||||
echo "-------- After replace spine wasm ------------"
|
||||
ls -l ./engine-HEAD/native/external/emscripten/spine/
|
||||
echo "-----------------------------------------------"
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: spine-emscripten
|
||||
path: dist
|
||||
|
||||
- name: Build Head Declarations
|
||||
working-directory: ./engine-HEAD
|
||||
run: |
|
||||
npm install
|
||||
node ./.github/workflows/package-size-check.js
|
||||
|
||||
- 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
|
||||
|
||||
- uses: LouisBrunner/diff-action@v2.0.0
|
||||
with:
|
||||
old: ./engine/bin/.declarations/cc.d.ts
|
||||
|
||||
Reference in New Issue
Block a user