Skip to content

Commit 84a6afc

Browse files
Setup github actions for V4 (cocos2d#20702)
1 parent 084b7c2 commit 84a6afc

File tree

12 files changed

+188
-46
lines changed

12 files changed

+188
-46
lines changed

.github/workflows/main.yml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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+
with:
20+
submodules: recursive
21+
- run: python download-deps.py --r no
22+
- run: echo -e "y" | bash install-deps-linux.sh
23+
- run: cmake -B b -S .
24+
- run: cmake --build b
25+
26+
ubuntu-20_04:
27+
runs-on: ubuntu-20.04
28+
steps:
29+
- uses: actions/checkout@v2
30+
with:
31+
submodules: recursive
32+
- run: python download-deps.py --r no
33+
- run: echo -e "y" | bash install-deps-linux.sh
34+
- run: cmake -B b -S .
35+
- run: cmake --build b
36+
37+
windows-2019:
38+
runs-on: windows-2019
39+
steps:
40+
- uses: actions/checkout@v2
41+
with:
42+
submodules: recursive
43+
- run: python download-deps.py --r no
44+
- run: cmake -B b -S . -G "Visual Studio 16 2019" -A Win32
45+
- run: cmake --build b
46+
47+
windows-2022:
48+
runs-on: windows-2022
49+
steps:
50+
- uses: actions/checkout@v2
51+
with:
52+
submodules: recursive
53+
- run: python download-deps.py --r no
54+
- run: cmake -B b -S . -G "Visual Studio 17 2022" -A Win32
55+
- run: cmake --build b
56+
57+
macos-10_15:
58+
runs-on: macos-10.15
59+
steps:
60+
- uses: actions/checkout@v2
61+
with:
62+
submodules: recursive
63+
- run: python download-deps.py --r no
64+
- run: cmake -B b -S .
65+
- run: cmake --build b
66+
67+
macos-11:
68+
runs-on: macos-11
69+
steps:
70+
- uses: actions/checkout@v2
71+
with:
72+
submodules: recursive
73+
- run: python download-deps.py --r no
74+
- run: cmake -B b -S .
75+
- run: cmake --build b
76+
77+
macos-10_15_ios:
78+
runs-on: macos-10.15
79+
steps:
80+
- uses: actions/checkout@v2
81+
with:
82+
submodules: recursive
83+
- run: python download-deps.py --r no
84+
- run: cmake -B b -S . -GXcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator
85+
- run: cmake --build b --config Release --target cpp-tests -- -quiet
86+
87+
macos-11_ios:
88+
runs-on: macos-11
89+
steps:
90+
- uses: actions/checkout@v2
91+
with:
92+
submodules: recursive
93+
- run: python download-deps.py --r no
94+
- run: cmake -B b -S . -GXcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator
95+
- run: cmake --build b --config Release --target cpp-tests -- -quiet -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)"
96+
97+
windows-2019-android:
98+
runs-on: windows-2019
99+
steps:
100+
- uses: actions/checkout@v2
101+
with:
102+
submodules: recursive
103+
- run: python download-deps.py --r no
104+
- run: ./gradlew assembleRelease -PPROP_BUILD_TYPE=cmake --info
105+
shell: bash
106+
working-directory: tests/cpp-tests/proj.android
107+
108+
ubuntu-20_04-android:
109+
runs-on: ubuntu-20.04
110+
steps:
111+
- uses: actions/checkout@v2
112+
with:
113+
submodules: recursive
114+
- run: python download-deps.py --r no
115+
- run: ./gradlew assembleRelease -PPROP_BUILD_TYPE=cmake --info
116+
shell: bash
117+
working-directory: tests/cpp-tests/proj.android

cocos/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ if(XCODE OR VS)
148148
cocos_mark_code_files("cocos2d")
149149
endif()
150150

151-
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16.0")
151+
if(${CMAKE_VERSION} VERSION_GREATER "3.16.0")
152152
message("CMake 3.16 target_precompile_headers")
153153
target_precompile_headers(cocos2d PRIVATE
154154
"$<$<COMPILE_LANGUAGE:CXX>:cocos2d.h>")

download-deps.py

Lines changed: 61 additions & 36 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,13 +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
9898
if self._current_version[0] == 'v':
99-
self._extracted_folder_name = os.path.join(self._workpath, self._repo_name + '-' + self._current_version[1:])
99+
self._extracted_folder_name = os.path.join(
100+
self._workpath, self._repo_name + '-' + self._current_version[1:])
100101
else:
101-
self._extracted_folder_name = os.path.join(self._workpath, self._repo_name + '-' + self._current_version)
102+
self._extracted_folder_name = os.path.join(
103+
self._workpath, self._repo_name + '-' + self._current_version)
102104

103105
try:
104106
data = self.load_json_file(version_path)
@@ -110,7 +112,10 @@ def __init__(self, workpath, config_path, version_path, remote_version_key=None)
110112
print("==> version file doesn't exist")
111113

112114
def get_input_value(self, prompt):
113-
ret = raw_input(prompt)
115+
if(python_2):
116+
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,22 +365,17 @@ def run(self, workpath, folder_for_extracting, remove_downloaded, force_update,
339365
print("==> Download (%s) finish!" % self._filename)
340366

341367

342-
def _check_python_version():
368+
def _is_python_version_2():
343369
major_ver = sys.version_info[0]
370+
print("The python version is %d.%d." % (major_ver, sys.version_info[1]))
344371
if major_ver > 2:
345-
print ("The python version is %d.%d. But python 2.x is required. (Version 2.7 is well tested)\n"
346-
"Download it here: https://www.python.org/" % (major_ver, sys.version_info[1]))
347372
return False
348-
349373
return True
350374

351375

352376
def main():
353377
workpath = os.path.dirname(os.path.realpath(__file__))
354378

355-
if not _check_python_version():
356-
exit()
357-
358379
parser = OptionParser()
359380
parser.add_option('-r', '--remove-download',
360381
action="store", type="string", dest='remove_downloaded', default=None,
@@ -373,11 +394,15 @@ def main():
373394
print("=======================================================")
374395
print("==> Prepare to download external libraries!")
375396
external_path = os.path.join(workpath, 'external')
376-
installer = CocosZipInstaller(workpath, os.path.join(workpath, 'external', 'config.json'), os.path.join(workpath, 'external', 'version.json'), "prebuilt_libs_version")
377-
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+
378402

379403
# -------------- main --------------
380404
if __name__ == '__main__':
405+
python_2 = _is_python_version_2()
381406
try:
382407
main()
383408
except Exception as e:

install-deps-linux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ sudo apt-get update
1414
# run 32bit applicatio: needed for lua relase mode as luajit has 32bit version
1515
# https://askubuntu.com/questions/454253/how-to-run-32-bit-app-in-ubuntu-64-bit
1616
sudo dpkg --add-architecture i386
17-
DEPENDS='libc6:i386 libncurses5:i386 libstdc++6:i386'
17+
# DEPENDS='libc6:i386 libncurses5:i386 libstdc++6:i386'
1818

1919

2020
DEPENDS+=' libx11-dev'

templates/cpp-template-default/proj.android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ buildscript {
77
}
88

99
dependencies {
10-
classpath 'com.android.tools.build:gradle:3.1.0'
10+
classpath 'com.android.tools.build:gradle:3.4.0'
1111

1212
// NOTE: Do not place your application dependencies here; they belong
1313
// in the individual module build.gradle files

templates/lua-template-default/frameworks/runtime-src/proj.android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ buildscript {
77
}
88

99
dependencies {
10-
classpath 'com.android.tools.build:gradle:3.1.0'
10+
classpath 'com.android.tools.build:gradle:3.4.0'
1111

1212
// NOTE: Do not place your application dependencies here; they belong
1313
// in the individual module build.gradle files

tests/cpp-empty-test/proj.android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ buildscript {
77
}
88

99
dependencies {
10-
classpath 'com.android.tools.build:gradle:3.1.0'
10+
classpath 'com.android.tools.build:gradle:3.4.0'
1111

1212
// NOTE: Do not place your application dependencies here; they belong
1313
// in the individual module build.gradle files

0 commit comments

Comments
 (0)