Skip to content

Fix a compilation error on xcode 16.0 #7897

Fix a compilation error on xcode 16.0

Fix a compilation error on xcode 16.0 #7897

name: <Native> Run Unit Tests
on:
pull_request:
paths:
- 'templates/**'
- 'native/**'
# github.head_ref is only defined on pull_request events
concurrency:
group: ${{ github.workflow }}-${{ github.actor }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
unit-test-with-cmake:
name: "Run on macOS"
if:
(! contains(github.event.pull_request.body, '[X] does not change any runtime related code or build configuration'))
runs-on: macos-latest
defaults:
run:
working-directory: ${{github.workspace}}/native
steps:
- uses: actions/checkout@v4
- uses: lukka/get-cmake@latest
with:
cmakeVersion: 3.28.3
- name: Check cmake version
run: |
echo "CMake version: "
cmake --version
- name: Download external libraries
shell: bash
run: |
EXT_VERSION=`node ../.github/workflows/get-native-external-version.js`
git clone --branch $EXT_VERSION --depth 1 https://github.com/cocos/cocos-engine-external external
- name: Run Unit Tests
shell: bash
run: |
cpus=$(sysctl hw.ncpu | awk '{print $2}')
echo "cpus: ${cpus}"
which cmake
cmake --version
cmake -B tests/unit-test/build -S tests/unit-test -GXcode
cd tests/unit-test/build
# cmake --build tests/unit-test/build --config Release -j${cpus}
ls -l
xcodebuild -project CocosTest.xcodeproj -scheme "CocosTest" -jobs ${cpus} -arch arm64 -configuration Release build CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO
./src/Release/CocosTest
#### TODO(PatriceJiang): model split
# - name: Run Module Tests
# shell: bash
# run: |
# cd tests/module-tests
# bash run-test-windows.sh
sebind-with-windows:
name: "sebind tests"
if:
(! contains(github.event.pull_request.body, '[X] does not change any runtime related code or build configuration'))
runs-on: windows-latest
defaults:
run:
working-directory: ${{github.workspace}}/native
steps:
- uses: actions/checkout@v4
- name: Download external libraries
shell: bash
run: |
EXT_VERSION=`node ../.github/workflows/get-native-external-version.js`
git clone --branch $EXT_VERSION --depth 1 https://github.com/cocos/cocos-engine-external external
- name: Generate bindings
run: |
cd ./tools/swig-config
echo "Create auto-generated jsbinding glue codes."
node genbindings.js
git status
- name: Run Sebind Tests
shell: bash
run: |
cd ${GITHUB_WORKSPACE}/native
cp -r ../templates/windows tests/sebind-tests/win64
cd tests/sebind-tests
mkdir -p proj
cp cfg.cmake proj/
GW="${GITHUB_WORKSPACE//\\/\/}"
cmake -B proj -S win64 -DRES_DIR="${GW}/native/tests/sebind-tests" -DCOCOS_X_PATH="${GW}/native" -DAPP_NAME=sebind
cmake --build proj -j2
# cd proj/Debug
## can not boot on this machine
# ./sebind.exe || true
# if [[ -f "result.txt" ]];
# then
# echo "success!"
# else
# echo "Run sebind-tests fail!"
# exit 1
# fi
# sebind-run-on-linux:
# name: "Test sebind on Ubuntu"
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: Download external libraries
# shell: bash
# run: |
# EXT_VERSION=`node ./.github/workflows/get-native-external-version.js`
# git clone --branch $EXT_VERSION --depth 1 https://github.com/cocos/cocos-engine-external native/external
# - name: Generate bindings
# run: |
# cd ./native/tools/swig-config
# node genbindings.js
# git status
# - name: Install dependencies
# run: |
# sudo apt install libx11-dev -y
# sudo apt install libsndio-dev -y
# sudo apt install ninja-build -y
# - name: Run Sebind Tests
# shell: bash
# run: |
# cd ${GITHUB_WORKSPACE}/native
# cp -r ../templates/linux tests/sebind-tests/linux
# cd tests/sebind-tests
# mkdir -p proj
# cp cfg.cmake proj
# cmake -G Ninja -B proj -S linux -DRES_DIR=${GITHUB_WORKSPACE}/native/tests/sebind-tests/ -DCOCOS_X_PATH=${GITHUB_WORKSPACE}/native -DAPP_NAME=sebind
# cmake --build proj
# cd proj
# ./sebind || true
# if [[ -f "result.txt" ]];
# then
# echo "success!"
# else
# echo "Run sebind-tests fail!" > /dev/stderr
# fi