Skip to content

Commit 674fc07

Browse files
Setup github actions for V3 (#20701)
1 parent 64977e5 commit 674fc07

File tree

5 files changed

+175
-40
lines changed

5 files changed

+175
-40
lines changed

.github/workflows/main.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: CI
4+
5+
on:
6+
push:
7+
branches: [ v4, v3 ]
8+
pull_request:
9+
branches: [ v4, v3 ]
10+
11+
# Allows you to run this workflow manually from the Actions tab
12+
workflow_dispatch:
13+
14+
jobs:
15+
ubuntu-18_04:
16+
runs-on: ubuntu-18.04
17+
steps:
18+
- uses: actions/checkout@v2
19+
- run: python download-deps.py --r no
20+
- run: echo -e "y" | bash build/install-deps-linux.sh
21+
- run: cmake -B b -S .
22+
- run: cmake --build b
23+
24+
ubuntu-20_04:
25+
runs-on: ubuntu-20.04
26+
steps:
27+
- uses: actions/checkout@v2
28+
- run: python download-deps.py --r no
29+
- run: echo -e "y" | bash build/install-deps-linux.sh
30+
- run: cmake -B b -S .
31+
- run: cmake --build b
32+
33+
windows-2019:
34+
runs-on: windows-2019
35+
steps:
36+
- uses: actions/checkout@v2
37+
- run: python download-deps.py --r no
38+
- run: cmake -B b -S . -G "Visual Studio 16 2019" -A Win32
39+
- run: cmake --build b
40+
41+
windows-2022:
42+
runs-on: windows-2022
43+
steps:
44+
- uses: actions/checkout@v2
45+
- run: python download-deps.py --r no
46+
- run: cmake -B b -S . -G "Visual Studio 17 2022" -A Win32
47+
- run: cmake --build b
48+
49+
macos-10_15:
50+
runs-on: macos-10.15
51+
steps:
52+
- uses: actions/checkout@v2
53+
- run: python download-deps.py --r no
54+
- run: cmake -B b -S .
55+
- run: cmake --build b
56+
57+
macos-11:
58+
runs-on: macos-11
59+
steps:
60+
- uses: actions/checkout@v2
61+
- run: python download-deps.py --r no
62+
- run: cmake -B b -S .
63+
- run: cmake --build b
64+
65+
macos-10_15_ios:
66+
runs-on: macos-10.15
67+
steps:
68+
- uses: actions/checkout@v2
69+
- run: python download-deps.py --r no
70+
- run: cmake -B b -S . -GXcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator
71+
- run: cmake --build b --config Release --target cpp-tests -- -quiet
72+
73+
macos-11_ios:
74+
runs-on: macos-11
75+
steps:
76+
- uses: actions/checkout@v2
77+
- run: python download-deps.py --r no
78+
- run: cmake -B b -S . -GXcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator
79+
- run: cmake --build b --config Release --target cpp-tests -- -quiet -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)"
80+
81+
windows-2019-android:
82+
runs-on: windows-2019
83+
steps:
84+
- uses: actions/checkout@v2
85+
- run: python download-deps.py --r no
86+
- run: ./gradlew assembleRelease -PPROP_BUILD_TYPE=cmake --info
87+
shell: bash
88+
working-directory: tests/cpp-tests/proj.android
89+
90+
ubuntu-20_04-android:
91+
runs-on: ubuntu-20.04
92+
steps:
93+
- uses: actions/checkout@v2
94+
- run: python download-deps.py --r no
95+
- run: ./gradlew assembleRelease -PPROP_BUILD_TYPE=cmake --info
96+
shell: bash
97+
working-directory: tests/cpp-tests/proj.android

build/install-deps-linux.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ DEPENDS+=' libglu1-mesa-dev'
1717
DEPENDS+=' libgl2ps-dev'
1818
DEPENDS+=' libxi-dev'
1919
DEPENDS+=' libzip-dev'
20-
DEPENDS+=' libpng12-dev'
20+
DEPENDS+=' libpng-dev'
2121
DEPENDS+=' libcurl4-gnutls-dev'
2222
DEPENDS+=' libfontconfig1-dev'
2323
DEPENDS+=' libsqlite3-dev'
2424
DEPENDS+=' libglew-dev'
2525
DEPENDS+=' libssl-dev'
2626
DEPENDS+=' libgtk-3-dev'
2727
DEPENDS+=' binutils'
28+
DEPENDS+=' xorg-dev'
2829

2930
sudo apt-get install --force-yes --yes $DEPENDS > /dev/null

cmake/Modules/CocosBuildHelpers.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ endmacro()
269269
# custom Xcode property for iOS target
270270
macro(cocos_config_target_xcode_property cocos_target)
271271
if(IOS)
272-
set_xcode_property(${cocos_target} IPHONEOS_DEPLOYMENT_TARGET "8.0")
272+
set_xcode_property(${cocos_target} IPHONEOS_DEPLOYMENT_TARGET "9.0")
273273
set_xcode_property(${cocos_target} ENABLE_BITCODE "NO")
274274
set_xcode_property(${cocos_target} ONLY_ACTIVE_ARCH "YES")
275275
endif()

cmake/Modules/CocosConfigDefine.cmake

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@
1717
set(PLATFORM_FOLDER linux)
1818
endif()
1919
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
20-
if(IOS)
21-
set(APPLE TRUE)
22-
set(PLATFORM_FOLDER ios)
23-
else()
24-
set(APPLE TRUE)
25-
set(MACOSX TRUE)
26-
set(PLATFORM_FOLDER mac)
27-
endif()
20+
set(APPLE TRUE)
21+
set(MACOSX TRUE)
22+
set(PLATFORM_FOLDER mac)
23+
elseif(${CMAKE_SYSTEM_NAME} MATCHES "iOS")
24+
set(APPLE TRUE)
25+
set(IOS TRUE)
26+
set(PLATFORM_FOLDER ios)
2827
else()
2928
message(FATAL_ERROR "Unsupported platform, CMake will exit")
3029
return()

download-deps.py

Lines changed: 68 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python
2-
#coding=utf-8
2+
3+
# coding=utf-8
34
#
45
# ./download-deps.py
56
#
@@ -42,14 +43,12 @@
4243
import sys
4344
import traceback
4445
import distutils
45-
import fileinput
4646
import json
4747

4848
from optparse import OptionParser
4949
from time import time
5050
from time import sleep
5151
from sys import stdout
52-
from distutils.errors import DistutilsError
5352
from distutils.dir_util import copy_tree, remove_tree
5453

5554

@@ -92,10 +91,16 @@ def __init__(self, workpath, config_path, version_path, remote_version_key=None)
9291
except:
9392
self._move_dirs = None
9493
self._filename = self._current_version + '.zip'
95-
self._url = data["repo_parent"] + self._repo_name + '/archive/' + self._filename
94+
self._url = data["repo_parent"] + \
95+
self._repo_name + '/archive/' + self._filename
9696
self._zip_file_size = int(data["zip_file_size"])
9797
# 'v' letter was swallowed by github, so we need to substring it from the 2nd letter
98-
self._extracted_folder_name = os.path.join(self._workpath, self._repo_name + '-' + self._current_version[1:])
98+
if self._current_version[0] == 'v':
99+
self._extracted_folder_name = os.path.join(
100+
self._workpath, self._repo_name + '-' + self._current_version[1:])
101+
else:
102+
self._extracted_folder_name = os.path.join(
103+
self._workpath, self._repo_name + '-' + self._current_version)
99104

100105
try:
101106
data = self.load_json_file(version_path)
@@ -107,10 +112,10 @@ def __init__(self, workpath, config_path, version_path, remote_version_key=None)
107112
print("==> version file doesn't exist")
108113

109114
def get_input_value(self, prompt):
110-
if sys.version_info[0] > 2:
111-
ret = input(prompt)
112-
else:
115+
if(python_2):
113116
ret = raw_input(prompt)
117+
else:
118+
ret = input(prompt)
114119
ret.rstrip(" \t")
115120
return ret
116121

@@ -120,27 +125,39 @@ def download_file(self):
120125
os.remove(self._filename)
121126
except OSError:
122127
pass
123-
print("==> Ready to download '%s' from '%s'" % (self._filename, self._url))
124-
import urllib2
128+
print("==> Ready to download '%s' from '%s'" %
129+
(self._filename, self._url))
130+
if(python_2):
131+
import urllib2 as urllib
132+
else:
133+
import urllib.request as urllib
125134
try:
126-
u = urllib2.urlopen(self._url)
127-
except urllib2.HTTPError as e:
135+
u = urllib.urlopen(self._url)
136+
except Exception as e:
128137
if e.code == 404:
129-
print("==> Error: Could not find the file from url: '%s'" % (self._url))
130-
print("==> Http request failed, error code: " + str(e.code) + ", reason: " + e.read())
138+
print("==> Error: Could not find the file from url: '%s'" %
139+
(self._url))
140+
print("==> Http request failed, error code: " +
141+
str(e.code) + ", reason: " + str(e.read()))
131142
sys.exit(1)
132143

133144
f = open(self._filename, 'wb')
134145
meta = u.info()
135-
content_len = meta.getheaders("Content-Length")
146+
content_len = 0
147+
if(python_2):
148+
content_len = meta.getheaders("Content-Length")
149+
else:
150+
content_len = meta['Content-Length']
151+
136152
file_size = 0
137153
if content_len and len(content_len) > 0:
138154
file_size = int(content_len[0])
139155
else:
140156
# github server may not reponse a header information which contains `Content-Length`,
141157
# therefore, the size needs to be written hardcode here. While server doesn't return
142158
# `Content-Length`, use it instead
143-
print("==> WARNING: Couldn't grab the file size from remote, use 'zip_file_size' section in '%s'" % self._config_path)
159+
print("==> WARNING: Couldn't grab the file size from remote, use 'zip_file_size' section in '%s'" %
160+
self._config_path)
144161
file_size = self._zip_file_size
145162

146163
print("==> Start to download, please wait ...")
@@ -165,9 +182,11 @@ def download_file(self):
165182
speed = block_size_per_second / (new_time - old_time) / 1000.0
166183
if file_size != 0:
167184
percent = file_size_dl * 100. / file_size
168-
status = r"Downloaded: %6dK / Total: %dK, Percent: %3.2f%%, Speed: %6.2f KB/S " % (file_size_dl / 1000, file_size / 1000, percent, speed)
185+
status = r"Downloaded: %6dK / Total: %dK, Percent: %3.2f%%, Speed: %6.2f KB/S " % (
186+
file_size_dl / 1000, file_size / 1000, percent, speed)
169187
else:
170-
status = r"Downloaded: %6dK, Speed: %6.2f KB/S " % (file_size_dl / 1000, speed)
188+
status = r"Downloaded: %6dK, Speed: %6.2f KB/S " % (
189+
file_size_dl / 1000, speed)
171190
print(status),
172191
sys.stdout.flush()
173192
print("\r"),
@@ -224,7 +243,8 @@ def unpack_zipfile(self, extract_dir):
224243
print("==> Extraction done!")
225244

226245
def ask_to_delete_downloaded_zip_file(self):
227-
ret = self.get_input_value("==> Would you like to save '%s'? So you don't have to download it later. [Yes/no]: " % self._filename)
246+
ret = self.get_input_value(
247+
"==> Would you like to save '%s'? So you don't have to download it later. [Yes/no]: " % self._filename)
228248
ret = ret.strip()
229249
if ret != 'yes' and ret != 'y' and ret != 'no' and ret != 'n':
230250
print("==> Saving the dependency libraries by default")
@@ -237,16 +257,17 @@ def download_zip_file(self):
237257
self.download_file_with_retry(5, 3)
238258
try:
239259
if not zipfile.is_zipfile(self._filename):
240-
raise UnrecognizedFormat("%s is not a zip file" % (self._filename))
260+
raise UnrecognizedFormat(
261+
"%s is not a zip file" % (self._filename))
241262
except UnrecognizedFormat as e:
242-
print("==> Unrecognized zip format from your local '%s' file!" % (self._filename))
263+
print("==> Unrecognized zip format from your local '%s' file!" %
264+
(self._filename))
243265
if os.path.isfile(self._filename):
244266
os.remove(self._filename)
245267
print("==> Download it from internet again, please wait...")
246268
self.download_zip_file()
247269

248270
def download_file_with_retry(self, times, delay):
249-
import urllib2
250271
times_count = 0
251272
while(times_count < times):
252273
times_count += 1
@@ -290,15 +311,17 @@ def fix_fmod_link(self, extract_dir):
290311
import platform
291312
if platform.system() != "Linux":
292313
return
293-
print("==> Fix fmod link ... ")
294-
fmod_path = os.path.join(extract_dir, "linux-specific/fmod/prebuilt/64-bit")
314+
print("==> Fix fmod link ... ")
315+
fmod_path = os.path.join(
316+
extract_dir, "linux-specific/fmod/prebuilt/64-bit")
295317
if os.path.exists(fmod_path):
296318
os.unlink(os.path.join(fmod_path, "libfmod.so.6"))
297319
os.unlink(os.path.join(fmod_path, "libfmodL.so.6"))
298320
os.symlink("libfmod.so", os.path.join(fmod_path, "libfmod.so.6"))
299321
os.symlink("libfmodL.so", os.path.join(fmod_path, "libfmodL.so.6"))
300322
else:
301-
print("==> fmod directory not found `%s`, failed to fix fmod link!"%fmod_path)
323+
print(
324+
"==> fmod directory not found `%s`, failed to fix fmod link!" % fmod_path)
302325

303326
def run(self, workpath, folder_for_extracting, remove_downloaded, force_update, download_only):
304327
if not force_update and not self.need_to_update():
@@ -318,13 +341,16 @@ def run(self, workpath, folder_for_extracting, remove_downloaded, force_update,
318341

319342
self.clean_external_folder(folder_for_extracting)
320343
print("==> Copying files...")
321-
distutils.dir_util.copy_tree(self._extracted_folder_name, folder_for_extracting)
344+
distutils.dir_util.copy_tree(
345+
self._extracted_folder_name, folder_for_extracting)
322346
if self._move_dirs is not None:
323347
for srcDir in self._move_dirs.keys():
324-
distDir = os.path.join( os.path.join(workpath, self._move_dirs[srcDir]), srcDir)
348+
distDir = os.path.join(os.path.join(
349+
workpath, self._move_dirs[srcDir]), srcDir)
325350
if os.path.exists(distDir):
326351
shutil.rmtree(distDir)
327-
shutil.move( os.path.join(folder_for_extracting, srcDir), distDir)
352+
shutil.move(os.path.join(
353+
folder_for_extracting, srcDir), distDir)
328354
self.fix_fmod_link(folder_for_extracting)
329355
print("==> Cleaning...")
330356
if os.path.exists(self._extracted_folder_name):
@@ -339,6 +365,14 @@ def run(self, workpath, folder_for_extracting, remove_downloaded, force_update,
339365
print("==> Download (%s) finish!" % self._filename)
340366

341367

368+
def _is_python_version_2():
369+
major_ver = sys.version_info[0]
370+
print("The python version is %d.%d." % (major_ver, sys.version_info[1]))
371+
if major_ver > 2:
372+
return False
373+
return True
374+
375+
342376
def main():
343377
workpath = os.path.dirname(os.path.realpath(__file__))
344378

@@ -360,11 +394,15 @@ def main():
360394
print("=======================================================")
361395
print("==> Prepare to download external libraries!")
362396
external_path = os.path.join(workpath, 'external')
363-
installer = CocosZipInstaller(workpath, os.path.join(workpath, 'external', 'config.json'), os.path.join(workpath, 'external', 'version.json'), "prebuilt_libs_version")
364-
installer.run(workpath, external_path, opts.remove_downloaded, opts.force_update, opts.download_only)
397+
installer = CocosZipInstaller(workpath, os.path.join(workpath, 'external', 'config.json'), os.path.join(
398+
workpath, 'external', 'version.json'), "prebuilt_libs_version")
399+
installer.run(workpath, external_path, opts.remove_downloaded,
400+
opts.force_update, opts.download_only)
401+
365402

366403
# -------------- main --------------
367404
if __name__ == '__main__':
405+
python_2 = _is_python_version_2()
368406
try:
369407
main()
370408
except Exception as e:

0 commit comments

Comments
 (0)