From c252b1412852489853112fdd27d0467e368c28b6 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 13 Dec 2024 09:34:19 +0800 Subject: [PATCH 1/3] Fix that package size check may be wrong if spine cpp code changed but the generated wasm is not merged into external repo. --- .github/workflows/web-interface-check.yml | 98 +++++++++++++++++------ 1 file changed, 72 insertions(+), 26 deletions(-) diff --git a/.github/workflows/web-interface-check.yml b/.github/workflows/web-interface-check.yml index 22dfeee8df8..951f1765fff 100644 --- a/.github/workflows/web-interface-check.yml +++ b/.github/workflows/web-interface-check.yml @@ -20,6 +20,28 @@ jobs: with: node-version: '18.x' + - 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 + - uses: actions/checkout@v4 name: Checkout Base Ref with: @@ -43,6 +65,50 @@ jobs: ref: "${{ env.EXT_VERSION }}" fetch-depth: 1 +- name: Apply emscripten patches (BASE) + 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/.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 (BASE) + run: | + cd ./engine/native/cocos/editor-support/spine-wasm + mkdir build-wasm + cd build-wasm + emcmake cmake .. -GNinja + ninja + ls -l + + - name: Build Spine ASMJS (BASE) + run: | + cd ./engine/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 (BASE) + run: | + mkdir dist + cp ./engine/native/cocos/editor-support/spine-wasm/build-wasm/spine.wasm ./dist/ + cp ./engine/native/cocos/editor-support/spine-wasm/build-wasm/spine.js ./dist/spine.wasm.js + cp ./engine/native/cocos/editor-support/spine-wasm/build-asmjs/spine.js.mem ./dist/ + cp ./engine/native/cocos/editor-support/spine-wasm/build-asmjs/spine.js ./dist/spine.asm.js + echo "-------- Before replace spine wasm -----------" + ls -l ./engine/native/external/emscripten/spine/ + cp -f ./dist/* ./engine/native/external/emscripten/spine/ + echo "-------- After replace spine wasm ------------" + ls -l ./engine/native/external/emscripten/spine/ + echo "-----------------------------------------------" + cd ./engine/native/external + git status + - name: Build Base Declarations working-directory: ./engine run: | @@ -99,18 +165,7 @@ 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 + - name: Apply emscripten patches (HEAD) run: | echo "--------------------------------- Save bind.cpp ---------------------------------" cp $EMSDK/upstream/emscripten/system/lib/embind/bind.cpp $EMSDK/upstream/emscripten/system/lib/embind/bind.cpp.bak @@ -119,18 +174,7 @@ jobs: 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 + - name: Build Spine WASM (HEAD) run: | cd ./engine-HEAD/native/cocos/editor-support/spine-wasm mkdir build-wasm @@ -139,7 +183,7 @@ jobs: ninja ls -l - - name: Build Spine ASMJS + - name: Build Spine ASMJS (HEAD) run: | cd ./engine-HEAD/native/cocos/editor-support/spine-wasm sed -i 's/set(BUILD_WASM 1)/set(BUILD_WASM 0)/g' CMakeLists.txt @@ -149,7 +193,7 @@ jobs: ninja ls -l - - name: Copy files to external directory + - name: Copy files to external directory (HEAD) run: | mkdir dist cp ./engine-HEAD/native/cocos/editor-support/spine-wasm/build-wasm/spine.wasm ./dist/ @@ -162,6 +206,8 @@ jobs: echo "-------- After replace spine wasm ------------" ls -l ./engine-HEAD/native/external/emscripten/spine/ echo "-----------------------------------------------" + cd ./engine-HEAD/native/external + git status - name: Upload Artifact uses: actions/upload-artifact@v4 From d11c5def99787f30d066ea3c5f8085f17fef2460 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 13 Dec 2024 09:40:13 +0800 Subject: [PATCH 2/3] Update yml --- .github/workflows/web-interface-check.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/web-interface-check.yml b/.github/workflows/web-interface-check.yml index 951f1765fff..36e41ea64d3 100644 --- a/.github/workflows/web-interface-check.yml +++ b/.github/workflows/web-interface-check.yml @@ -65,7 +65,7 @@ jobs: ref: "${{ env.EXT_VERSION }}" fetch-depth: 1 -- name: Apply emscripten patches (BASE) + - name: Apply emscripten patches (BASE) run: | echo "--------------------------------- Save bind.cpp ---------------------------------" cp $EMSDK/upstream/emscripten/system/lib/embind/bind.cpp $EMSDK/upstream/emscripten/system/lib/embind/bind.cpp.bak @@ -117,6 +117,14 @@ jobs: node ./.github/workflows/package-size-check.js fi + - name: Restore patches (BASE) + 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 + - name: Clear npm Cache run: | npm cache clean --force @@ -221,7 +229,7 @@ jobs: npm install node ./.github/workflows/package-size-check.js - - name: Restore patches + - name: Restore patches (HEAD) run: | echo "-------------------------- Restore patches ---------------------------------" rm $EMSDK/upstream/emscripten/system/lib/embind/bind.cpp From 8a51258ffcbab39929cfbeed2b6e3cf053ee4d75 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 13 Dec 2024 10:06:10 +0800 Subject: [PATCH 3/3] Fix web-interface-check.yml --- .github/workflows/web-interface-check.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/web-interface-check.yml b/.github/workflows/web-interface-check.yml index 36e41ea64d3..f28a6968a23 100644 --- a/.github/workflows/web-interface-check.yml +++ b/.github/workflows/web-interface-check.yml @@ -95,6 +95,7 @@ jobs: - name: Copy files to external directory (BASE) run: | + rm -rf dist mkdir dist cp ./engine/native/cocos/editor-support/spine-wasm/build-wasm/spine.wasm ./dist/ cp ./engine/native/cocos/editor-support/spine-wasm/build-wasm/spine.js ./dist/spine.wasm.js @@ -203,6 +204,7 @@ jobs: - name: Copy files to external directory (HEAD) run: | + rm -rf dist 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