-
Notifications
You must be signed in to change notification settings - Fork 2.1k
533 lines (485 loc) · 23.8 KB
/
native-compile-platforms.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
name: <Native> Compile
on:
pull_request:
paths:
- 'templates/**'
- 'native/**'
- '.github/workflows/native-compile-platforms.yml'
# 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:
compile_windows:
name: "Windows"
if:
(! contains(github.event.pull_request.body, '[X] does not change any runtime related code or build configuration'))
runs-on: windows-2019
steps:
- uses: actions/checkout@v2
- 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: Install deps
uses: humbletim/[email protected]
with:
vulkan-query-version: 1.2.189.0
vulkan-components: Vulkan-Headers, Vulkan-Loader
vulkan-use-cache: true
- name: Compile win64
shell: bash
env:
COCOS_ENGINE_DEV: 1
run: |
cd $GITHUB_WORKSPACE/templates/windows
echo "message(STATUS \"hook before \${CC_TARGET_NAME}\")" >> Pre-Sample.cmake
echo "message(STATUS \"hook after \${CC_TARGET_NAME}\")" >> Post-Sample.cmake
mkdir -p build-win64/proj
touch build-win64/proj/cfg.cmake
echo "set(CC_USE_GLES3 ON)" >> build-win64/proj/cfg.cmake
echo "set(CC_USE_VULKAN ON)" >> build-win64/proj/cfg.cmake
echo "set(CC_USE_GLES2 ON)" >> build-win64/proj/cfg.cmake
echo "set(USE_SPINE OFF)" >> build-win64/proj/cfg.cmake
echo "set(USE_DRAGONBONES OFF)" >> build-win64/proj/cfg.cmake
echo "set(USE_WEBSOCKET_SERVER ON)" >> build-win64/proj/cfg.cmake
echo "set(CMAKE_CXX_STANDARD_REQUIRED ON)" >> build-win64/proj/cfg.cmake
echo "set(CC_EXECUTABLE_NAME \"\")" >> build-win64/proj/cfg.cmake
mkdir build-win64/assets
cd build-win64
RES_DIR=${GITHUB_WORKSPACE//\\//}/templates/windows/build-win64
COCOS_X_PATH=${GITHUB_WORKSPACE//\\//}/native
cmake ../ -G"Visual Studio 16 2019" -DRES_DIR=$RES_DIR -DCOCOS_X_PATH=$COCOS_X_PATH -Ax64
cmake --build . --config Release
echo "Compile Win64 Release Done!"
compile_android_minimal:
name: "Android Minimal"
if:
(! contains(github.event.pull_request.body, '[X] does not change any runtime related code or build configuration'))
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- 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
- uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r21e
add-to-path: false
local-cache: true
- uses: actions/setup-java@v3
id: setup-jdk
with:
distribution: 'zulu'
java-version: '17'
- name: Compile
env:
COCOS_ENGINE_DEV: 1
run: |
NATIVE_ROOT=$GITHUB_WORKSPACE/native
ANDROID_NDK=${{ steps.setup-ndk.outputs.ndk-path }}
NATIVE_DIR=$GITHUB_WORKSPACE/templates/android-template
echo "Compiling Android ... "
cd $GITHUB_WORKSPACE/templates/
echo "message(STATUS \"hook before \${CC_TARGET_NAME}\")" >> android/template/Pre-Sample.cmake
echo "message(STATUS \"hook after \${CC_TARGET_NAME}\")" >> android/template/Post-Sample.cmake
if [ ! -d android-template ]; then
cp -r android/template android-template
fi
cd $GITHUB_WORKSPACE/templates/android/build
mkdir -p build-android/proj
touch build-android/proj/cfg.cmake
echo "set(CI_FORCE_MINIMAL_FEATURES ON)" >> build-android/proj/cfg.cmake
echo "set(COCOS_X_PATH $NATIVE_ROOT)" >> build-android/proj/cfg.cmake
echo "set(CC_EXECUTABLE_NAME \"\")" >> build-android/proj/cfg.cmake
mkdir -p build-android/proj/res/values
cat << EOF > build-android/proj/res/values/strings.xml
<resources>
<string name="app_name" translatable="false">CocosGame</string>
</resources>
EOF
mkdir -p build-android/assets
ASSET_DIR=$GITHUB_WORKSPACE/templates/android/build/build-android/
sed -i "s@^PROP_NDK_PATH.*@PROP_NDK_PATH=$ANDROID_NDK@g" gradle.properties
sed -i "s@^APPLICATION_ID.*@APPLICATION_ID=com.cocos.android@g" gradle.properties
sed -i "s@^RES_PATH.*@RES_PATH=$ASSET_DIR@g" gradle.properties
sed -i "s@^COCOS_ENGINE_PATH.*@COCOS_ENGINE_PATH=$NATIVE_ROOT@g" gradle.properties
sed -i "s@^NATIVE_DIR.*@NATIVE_DIR=$NATIVE_DIR@g" gradle.properties
# To speedup CI, compile x86 only
# sed -i "s@^PROP_APP_ABI.*@PROP_APP_ABI=armeabi-v7a:arm64-v8a:x86@g" gradle.properties
sed -i "s@^PROP_APP_ABI.*@PROP_APP_ABI=x86@g" gradle.properties
echo "Compile Android - cmake ..."
echo "ANDROID_NDK ${ANDROID_NDK} or ${ANDROID_NDK_HOME}"
# ./gradlew :CocosGame:assembleDebug --quiet
./gradlew :CocosGame:assembleRelease --quiet
echo "Compile Android Debug Done!"
compile_android:
name: "Android"
if:
(! contains(github.event.pull_request.body, '[X] does not change any runtime related code or build configuration'))
runs-on: ubuntu-latest
steps:
- name: Before free space
run: |
df -h
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@d5af243ce7bacb67384aa6c5b1fc5f169e30903e
with:
tool-cache: true
android: false
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- name: After free space
run: |
df -h
- uses: actions/checkout@v2
- 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
- uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r21e
add-to-path: false
local-cache: true
- uses: actions/setup-java@v3
id: setup-jdk
with:
distribution: 'zulu'
java-version: '17'
- name: Compile
env:
COCOS_ENGINE_DEV: 1
run: |
NATIVE_ROOT=$GITHUB_WORKSPACE/native
ANDROID_NDK=${{ steps.setup-ndk.outputs.ndk-path }}
NATIVE_DIR=$GITHUB_WORKSPACE/templates/android-template
echo "Compiling Android ... "
cd $GITHUB_WORKSPACE/templates/
echo "message(STATUS \"hook before \${CC_TARGET_NAME}\")" >> android/template/Pre-Sample.cmake
echo "message(STATUS \"hook after \${CC_TARGET_NAME}\")" >> android/template/Post-Sample.cmake
if [ ! -d android-template ]; then
cp -r android/template android-template
fi
cd $GITHUB_WORKSPACE/templates/android/build
mkdir -p build-android/proj
touch build-android/proj/cfg.cmake
echo "set(CC_USE_GLES3 ON)" >> build-android/proj/cfg.cmake
echo "set(CC_USE_VULKAN ON)" >> build-android/proj/cfg.cmake
echo "set(CC_USE_GLES2 ON)" >> build-android/proj/cfg.cmake
echo "set(USE_WEBSOCKET_SERVER ON)" >> build-android/proj/cfg.cmake
echo "set(CMAKE_CXX_STANDARD_REQUIRED ON)" >> build-android/proj/cfg.cmake
echo "set(COCOS_X_PATH $NATIVE_ROOT)" >> build-android/proj/cfg.cmake
echo "set(CC_EXECUTABLE_NAME \"\")" >> build-android/proj/cfg.cmake
mkdir -p build-android/proj/res/values
cat << EOF > build-android/proj/res/values/strings.xml
<resources>
<string name="app_name" translatable="false">CocosGame</string>
</resources>
EOF
mkdir -p build-android/assets
ASSET_DIR=$GITHUB_WORKSPACE/templates/android/build/build-android/
sed -i "s@^PROP_NDK_PATH.*@PROP_NDK_PATH=$ANDROID_NDK@g" gradle.properties
sed -i "s@^APPLICATION_ID.*@APPLICATION_ID=com.cocos.android@g" gradle.properties
sed -i "s@^RES_PATH.*@RES_PATH=$ASSET_DIR@g" gradle.properties
sed -i "s@^COCOS_ENGINE_PATH.*@COCOS_ENGINE_PATH=$NATIVE_ROOT@g" gradle.properties
sed -i "s@^NATIVE_DIR.*@NATIVE_DIR=$NATIVE_DIR@g" gradle.properties
# To speedup CI, compile arm64-v8a only
# sed -i "s@^PROP_APP_ABI.*@PROP_APP_ABI=armeabi-v7a:arm64-v8a:x86@g" gradle.properties
df -h
sed -i "s@^PROP_APP_ABI.*@PROP_APP_ABI=arm64-v8a@g" gradle.properties
echo "Compile Android - cmake ..."
echo "ANDROID_NDK ${ANDROID_NDK} or ${ANDROID_NDK_HOME}"
./gradlew :CocosGame:assembleDebug --quiet
df -h
./gradlew clean
sed -i "s@^PROP_APP_ABI.*@PROP_APP_ABI=armeabi-v7a@g" gradle.properties
./gradlew :CocosGame:assembleDebug --quiet
df -h
echo "Compile Android Debug Done!"
compile_openharmony:
name: "Openharmony"
if:
(! contains(github.event.pull_request.body, '[X] does not change any runtime related code or build configuration'))
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- 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
- uses: actions/setup-java@v3
id: setup-jdk
with:
distribution: 'zulu'
java-version: '17'
- name: Get oh sdk cache directory path
id: oh-sdk-cache-dir-path
run: |
echo "cache dir: "
echo "dir=$HOME/openharmony" >> $GITHUB_OUTPUT
- name: Output cache dir
run: |
echo "Output cache dir: ${{ steps.oh-sdk-cache-dir-path.outputs.dir }}"
- name: Cache OH SDK
id: cache-oh-sdk
uses: actions/cache@v3
env:
cache-name: cache-oh-sdk-9
with:
path: ${{ steps.oh-sdk-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-build-${{ env.cache-name }}
- name: Add package.json
run: |
echo "{}" > package.json
echo "{\"name\": \"tests\",\"lockfileVersion\": 3,\"requires\": true,\"packages\": {}}" > package-lock.json
- uses: actions/setup-node@v3
with:
node-version: 14
cache: 'npm'
- if: ${{ steps.cache-oh-sdk.outputs.cache-hit != 'true' }}
name: No Cache found, install oh sdk
continue-on-error: false
run: |
if [ ! -d "$HOME/openharmony" ]; then
mkdir -p $HOME/openharmony
echo "Download commandline-tools-linux.zip ..."
curl -o commandline-tools-linux.zip "https://contentcenter-vali-drcn.dbankcdn.cn/pvt_2/DeveloperAlliance_package_901_9/b1/v3/E6zhv5UFQ2-inIwNJhTN6Q/commandline-tools-linux-2.0.0.2.zip?HW-CC-KV=V1&HW-CC-Date=20230621T074401Z&HW-CC-Expire=315360000&HW-CC-Sign=621224257B02079B1E76C0A56FDF21483400B1E3556213F88DC79BC9BE7D595D"
echo "Unzip commandline-tools-linux.zip ..."
unzip commandline-tools-linux.zip -d $HOME/openharmony > /dev/null
cd $HOME/openharmony
ls -l
cd command-line-tools
echo "=============== PATCHING sdkmanager/bin/sdkmgr file ==============="
sed -i "[email protected][email protected]=UTF-8 -Duser.country=CN@g" ./sdkmanager/bin/sdkmgr
cd bin
./sdkmgr list
echo "=============== INSTALL HOS toolchains:9 ==============="
./sdkmgr install toolchains:9 --accept-license > /dev/null
echo "=============== INSTALL OH SDK ets:9 ==============="
./sdkmgr install OpenHarmony/ets:9 --accept-license > /dev/null
echo "=============== INSTALL OH SDK js:9 ==============="
./sdkmgr install OpenHarmony/js:9 --accept-license > /dev/null
echo "=============== INSTALL OH SDK native:9 ==============="
./sdkmgr install OpenHarmony/native:9 --accept-license > /dev/null
echo "=============== INSTALL OH SDK toolchains:9 ==============="
./sdkmgr install OpenHarmony/toolchains:9 --accept-license > /dev/null
echo "=============== INSTALL OH SDK DONE ==============="
./sdkmgr list
fi
- name: Compile for Openharmony
run: |
which node
which npm
which java
node -v
npm -v
java --version
echo "=============== list files in oh sdk ($HOME/openharmony) ==============="
pushd $HOME/openharmony
ls -l
popd
NATIVE_ROOT=$GITHUB_WORKSPACE/native
echo "Compiling Openharmony ... "
cd $GITHUB_WORKSPACE/templates/openharmony
echo "message(STATUS \"hook before \${CC_TARGET_NAME}\")" >> Pre-Sample.cmake
echo "message(STATUS \"hook after \${CC_TARGET_NAME}\")" >> Post-Sample.cmake
mkdir -p build-oh/proj
touch build-oh/proj/cfg.cmake
echo "set(CC_USE_GLES3 ON)" >> build-oh/proj/cfg.cmake
echo "set(CC_USE_VULKAN OFF)" >> build-oh/proj/cfg.cmake
echo "set(CC_USE_GLES2 ON)" >> build-oh/proj/cfg.cmake
echo "set(USE_WEBSOCKET_SERVER OFF)" >> build-oh/proj/cfg.cmake
echo "set(CMAKE_CXX_STANDARD_REQUIRED ON)" >> build-oh/proj/cfg.cmake
echo "set(COCOS_X_PATH $NATIVE_ROOT)" >> build-oh/proj/cfg.cmake
echo "set(CC_EXECUTABLE_NAME \"\")" >> build-oh/proj/cfg.cmake
echo "set(USE_SE_V8 OFF)" >> build-oh/proj/cfg.cmake
echo "set(USE_SE_NAPI ON)" >> build-oh/proj/cfg.cmake
echo "=============== cat build-oh/proj/cfg.cmake ==============="
cat build-oh/proj/cfg.cmake
mkdir -p build-oh/assets
ASSET_DIR=$GITHUB_WORKSPACE/templates/openharmony/build-oh
echo "=============== HACK ./entry/build-profile.json5 ==============="
sed -i "s@[^-]DRES_DIR[^=]@$ASSET_DIR@g" ./entry/build-profile.json5
sed -i "s@[^-]DCOMMON_DIR[^=]@$GITHUB_WORKSPACE/templates/common@g" ./entry/build-profile.json5
# To speedup CI, compile arm64-v8a only
sed -i "s@\"armeabi-v7a\",@@g" ./entry/build-profile.json5
echo "entry/build-profile.json5: "
cat ./entry/build-profile.json5
echo "=============== HACK ./hvigor/hvigor-wrapper.js ==============="
sed -i "s@HVIGOR_WRAPPER_PNPM_SCRIPT_PATH,\[\"install\"\]@HVIGOR_WRAPPER_PNPM_SCRIPT_PATH,\[\"install\", \"--lockfile=false\"\]@g" ./hvigor/hvigor-wrapper.js
echo "=============== SET NPM OH REGISTRY ==============="
echo "@ohos:registry=https://repo.harmonyos.com/npm/" >> ~/.npmrc
npm config get @ohos:registry
npm config get registry
echo "=============== UPDATE local.properties ==============="
echo "nodejs.dir=/usr/bin" >> local.properties
echo "hwsdk.dir=$HOME/openharmony/hwsdk" >> local.properties
echo "=============== UPDATE ./hvigor/hvigor-config.json5 ==============="
echo "{\"hvigorVersion\":\"3.0.2\",\"dependencies\":{\"@ohos/hvigor-ohos-plugin\":\"3.0.2\"}}" > ./hvigor/hvigor-config.json5
echo "=============== Do not import game.ts for cocos_worker.ts ==============="
sed -i '/<% if(!useV8) { %>/,/<% } %>/d' ./entry/src/main/ets/workers/cocos_worker.ts
echo "=============== EXECUTE hvigorw ==============="
./hvigorw clean -i
./hvigorw --stop-daemon -i
./hvigorw assembleHap -p debuggable=true --no-daemon -d
#./hvigorw default@ProcessLibs -p debuggable=true --no-daemon -d
echo "=============== EXECUTE hvigorw DONE ==============="
compile_mac_x86_64:
name: "MacOS x86_64"
if:
(! contains(github.event.pull_request.body, '[X] does not change any runtime related code or build configuration'))
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- 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: Compile
env:
COCOS_ENGINE_DEV: 1
run: |
NUM_OF_CORES=`getconf _NPROCESSORS_ONLN`
NATIVE_ROOT=$GITHUB_WORKSPACE/native
echo "Compiling MacOSX ... "
cd $GITHUB_WORKSPACE/templates/mac
echo "message(STATUS \"hook before \${CC_TARGET_NAME}\")" >> Pre-Sample.cmake
echo "message(STATUS \"hook after \${CC_TARGET_NAME}\")" >> Post-Sample.cmake
mkdir -p build-mac/proj
touch build-mac/proj/cfg.cmake
echo "set(CC_USE_VULKAN OFF)" >> build-mac/proj/cfg.cmake
echo "set(CC_USE_GLES2 OFF)" >> build-mac/proj/cfg.cmake
echo "set(CC_USE_GLES3 OFF)" >> build-mac/proj/cfg.cmake
echo "set(CC_USE_METAL ON)" >> build-mac/proj/cfg.cmake
echo "set(USE_WEBSOCKET_SERVER OFF)" >> build-mac/proj/cfg.cmake
echo "set(CMAKE_CXX_STANDARD_REQUIRED ON)" >> build-mac/proj/cfg.cmake
echo "set(CC_EXECUTABLE_NAME \"\")" >> build-mac/proj/cfg.cmake
mkdir build-mac/assets
RES_DIR=$GITHUB_WORKSPACE/templates/mac/build-mac
cd build-mac
cmake ../ -GXcode -DCMAKE_OSX_ARCHITECTURES=x86_64 -DRES_DIR=$RES_DIR -DCOCOS_X_PATH=$NATIVE_ROOT
set +e
cmake --build . --config Release -- -quiet -jobs $NUM_OF_CORES -arch x86_64
retcode=$?
set -e
if [ $retcode -ne 0 ]; then
echo "-----------------------------------------------------------------------------------------------"
echo "------------------------------------ recompile without `-quiet` -------------------------------"
echo "-----------------------------------------------------------------------------------------------"
cmake --build . --config Release -- -jobs $NUM_OF_CORES -arch x86_64
fi
echo "Compile MacOSX x86_64 Release Done!"
compile_mac_arm64:
name: "MacOS arm64"
if:
(! contains(github.event.pull_request.body, '[X] does not change any runtime related code or build configuration'))
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- 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: Compile
env:
COCOS_ENGINE_DEV: 1
run: |
NUM_OF_CORES=`getconf _NPROCESSORS_ONLN`
NATIVE_ROOT=$GITHUB_WORKSPACE/native
echo "Compiling MacOSX ... "
cd $GITHUB_WORKSPACE/templates/mac
mkdir -p build-mac/proj
touch build-mac/proj/cfg.cmake
echo "set(CC_USE_VULKAN OFF)" >> build-mac/proj/cfg.cmake
echo "set(CC_USE_GLES2 OFF)" >> build-mac/proj/cfg.cmake
echo "set(CC_USE_GLES3 OFF)" >> build-mac/proj/cfg.cmake
echo "set(CC_USE_METAL ON)" >> build-mac/proj/cfg.cmake
echo "set(USE_WEBSOCKET_SERVER OFF)" >> build-mac/proj/cfg.cmake
echo "set(CMAKE_CXX_STANDARD_REQUIRED ON)" >> build-mac/proj/cfg.cmake
echo "set(CC_EXECUTABLE_NAME \"\")" >> build-mac/proj/cfg.cmake
mkdir build-mac/assets
RES_DIR=$GITHUB_WORKSPACE/templates/mac/build-mac
cd build-mac
cmake ../ -GXcode -DCMAKE_OSX_ARCHITECTURES=arm64 -DRES_DIR=$RES_DIR -DCOCOS_X_PATH=$NATIVE_ROOT
set +e
cmake --build . --config Release -- -quiet -jobs $NUM_OF_CORES -arch arm64
retcode=$?
set -e
if [ $retcode -ne 0 ]; then
echo "-----------------------------------------------------------------------------------------------"
echo "------------------------------------ recompile without `-quiet` -------------------------------"
echo "-----------------------------------------------------------------------------------------------"
cmake --build . --config Release -- -jobs $NUM_OF_CORES -arch arm64
fi
echo "Compile MacOSX ARM64 Release Done!"
compile_iOS:
name: "iOS"
if:
(! contains(github.event.pull_request.body, '[X] does not change any runtime related code or build configuration'))
runs-on: macos-11
steps:
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: 12.4
- uses: actions/checkout@v2
- 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: Compile
env:
COCOS_ENGINE_DEV: 1
run: |
set -x
NUM_OF_CORES=`getconf _NPROCESSORS_ONLN`
NATIVE_ROOT=$GITHUB_WORKSPACE/native
echo "Compiling iOS ... "
cd $GITHUB_WORKSPACE/templates/ios
echo "message(STATUS \"hook before \${CC_TARGET_NAME}\")" >> Pre-Sample.cmake
echo "message(STATUS \"hook after \${CC_TARGET_NAME}\")" >> Post-Sample.cmake
mkdir -p build-ios/proj
touch build-ios/proj/cfg.cmake
echo "set(CC_USE_GLES3 OFF)" >> build-ios/proj/cfg.cmake
echo "set(CC_USE_VULKAN OFF)" >> build-ios/proj/cfg.cmake
echo "set(CC_USE_GLES2 OFF)" >> build-ios/proj/cfg.cmake
echo "set(CC_USE_METAL ON)" >> build-ios/proj/cfg.cmake
echo "set(TARGET_IOS_VERSION 11.0)" >> build-ios/proj/cfg.cmake
echo "set(USE_WEBSOCKET_SERVER OFF)" >> build-ios/proj/cfg.cmake
echo "set(USE_DRAGONBONES OFF)" >> build-ios/proj/cfg.cmake
echo "set(CMAKE_CXX_STANDARD_REQUIRED OFF)" >> build-ios/proj/cfg.cmake
echo "set(MACOSX_BUNDLE_GUI_IDENTIFIER com.cocos.demo.ios)" >> build-ios/proj/cfg.cmake
echo "set(CC_EXECUTABLE_NAME \"\")" >> build-ios/proj/cfg.cmake
mkdir build-ios/assets
cd build-ios
RES_DIR=$GITHUB_WORKSPACE/templates/ios/build-ios
cmake ../ -GXcode -DCMAKE_SYSTEM_NAME=iOS \
-DCMAKE_OSX_SYSROOT=iphoneos \
-DCMAKE_OSX_ARCHITECTURES=arm64 \
-DRES_DIR=$RES_DIR \
-DCOCOS_X_PATH=$NATIVE_ROOT
set +e
#cmake --build . --config Debug -- -quiet -jobs $NUM_OF_CORES -allowProvisioningUpdates CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO
cmake --build . --config Debug -- -quiet -jobs $NUM_OF_CORES CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO
retcode=$?
set -e
if [ $retcode -ne 0 ]; then
echo "-----------------------------------------------------------------------------------------------"
echo "------------------------------------ recompile without `-quiet` -------------------------------"
echo "-----------------------------------------------------------------------------------------------"
cmake --build . --config Debug -- -jobs $NUM_OF_CORES CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO
fi
echo "Compile iOS Done!"