Skip to content

Commit 5fb2bee

Browse files
committed
Merge commit 'cd7446f17956d73041f9b33b37b4c747c6bc1993' into scgamex-v3
* commit 'cd7446f17956d73041f9b33b37b4c747c6bc1993': Create pch for all platforms V3 (cocos2d#20705) Fix mac build V3 (cocos2d#20703) Setup github actions for V3 (cocos2d#20701) Support python 2 and 3 (cocos2d#20698) Update CCPlatformConfig.h (cocos2d#20693) # Conflicts: # cocos/audio/mac/CDAudioManager.m # cocos/audio/mac/CDXMacOSXSupport.h # cocos/scripting/js-bindings/CMakeLists.txt
2 parents 885fcb4 + cd7446f commit 5fb2bee

File tree

7 files changed

+83
-59
lines changed

7 files changed

+83
-59
lines changed

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()

cocos/CMakeLists.txt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,8 @@ if(XCODE OR VS)
162162
cocos_mark_code_files("cocos2d")
163163
endif()
164164

165-
if(WINDOWS)
166-
# precompiled header. Compilation time speedup ~4x.
167-
target_sources(cocos2d PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/precheader.cpp")
168-
set_target_properties(cocos2d PROPERTIES COMPILE_FLAGS "/Yuprecheader.h /FIprecheader.h")
169-
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/precheader.cpp" PROPERTIES COMPILE_FLAGS "/Ycprecheader.h")
170-
# compile c as c++. needed for precompiled header
171-
set_source_files_properties(${COCOS_SPINE_SRC} base/ccFPSImages.c PROPERTIES LANGUAGE CXX)
165+
if(${CMAKE_VERSION} VERSION_GREATER "3.16.0")
166+
message("CMake 3.16 target_precompile_headers")
167+
target_precompile_headers(cocos2d PRIVATE
168+
"$<$<COMPILE_LANGUAGE:CXX>:cocos2d.h>")
172169
endif()

cocos/platform/CCPlatformConfig.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ THE SOFTWARE.
5858
#define CC_TARGET_PLATFORM CC_PLATFORM_UNKNOWN
5959

6060
// Apple: Mac and iOS
61-
#if defined(__APPLE__) && !defined(ANDROID) // exclude android for binding generator.
61+
#if defined(__APPLE__) && !defined(__ANDROID__) // exclude android for binding generator.
6262
#include <TargetConditionals.h>
6363
#if TARGET_OS_IPHONE // TARGET_OS_IPHONE includes TARGET_OS_IOS TARGET_OS_TV and TARGET_OS_WATCH. see TargetConditionals.h
6464
#undef CC_TARGET_PLATFORM
@@ -72,7 +72,7 @@ THE SOFTWARE.
7272
#endif
7373

7474
// android
75-
#if defined(ANDROID)
75+
#if defined(__ANDROID__)
7676
#undef CC_TARGET_PLATFORM
7777
#define CC_TARGET_PLATFORM CC_PLATFORM_ANDROID
7878
#endif

download-deps.py

Lines changed: 63 additions & 35 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,7 +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-
ret = raw_input(prompt)
115+
if(python_2):
116+
ret = raw_input(prompt)
117+
else:
118+
ret = input(prompt)
111119
ret.rstrip(" \t")
112120
return ret
113121

@@ -117,27 +125,39 @@ def download_file(self):
117125
os.remove(self._filename)
118126
except OSError:
119127
pass
120-
print("==> Ready to download '%s' from '%s'" % (self._filename, self._url))
121-
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
122134
try:
123-
u = urllib2.urlopen(self._url)
124-
except urllib2.HTTPError as e:
135+
u = urllib.urlopen(self._url)
136+
except Exception as e:
125137
if e.code == 404:
126-
print("==> Error: Could not find the file from url: '%s'" % (self._url))
127-
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()))
128142
sys.exit(1)
129143

130144
f = open(self._filename, 'wb')
131145
meta = u.info()
132-
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+
133152
file_size = 0
134153
if content_len and len(content_len) > 0:
135154
file_size = int(content_len[0])
136155
else:
137156
# github server may not reponse a header information which contains `Content-Length`,
138157
# therefore, the size needs to be written hardcode here. While server doesn't return
139158
# `Content-Length`, use it instead
140-
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)
141161
file_size = self._zip_file_size
142162

143163
print("==> Start to download, please wait ...")
@@ -162,9 +182,11 @@ def download_file(self):
162182
speed = block_size_per_second / (new_time - old_time) / 1000.0
163183
if file_size != 0:
164184
percent = file_size_dl * 100. / file_size
165-
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)
166187
else:
167-
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)
168190
print(status),
169191
sys.stdout.flush()
170192
print("\r"),
@@ -221,7 +243,8 @@ def unpack_zipfile(self, extract_dir):
221243
print("==> Extraction done!")
222244

223245
def ask_to_delete_downloaded_zip_file(self):
224-
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)
225248
ret = ret.strip()
226249
if ret != 'yes' and ret != 'y' and ret != 'no' and ret != 'n':
227250
print("==> Saving the dependency libraries by default")
@@ -234,16 +257,17 @@ def download_zip_file(self):
234257
self.download_file_with_retry(5, 3)
235258
try:
236259
if not zipfile.is_zipfile(self._filename):
237-
raise UnrecognizedFormat("%s is not a zip file" % (self._filename))
260+
raise UnrecognizedFormat(
261+
"%s is not a zip file" % (self._filename))
238262
except UnrecognizedFormat as e:
239-
print("==> Unrecognized zip format from your local '%s' file!" % (self._filename))
263+
print("==> Unrecognized zip format from your local '%s' file!" %
264+
(self._filename))
240265
if os.path.isfile(self._filename):
241266
os.remove(self._filename)
242267
print("==> Download it from internet again, please wait...")
243268
self.download_zip_file()
244269

245270
def download_file_with_retry(self, times, delay):
246-
import urllib2
247271
times_count = 0
248272
while(times_count < times):
249273
times_count += 1
@@ -287,15 +311,17 @@ def fix_fmod_link(self, extract_dir):
287311
import platform
288312
if platform.system() != "Linux":
289313
return
290-
print("==> Fix fmod link ... ")
291-
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")
292317
if os.path.exists(fmod_path):
293318
os.unlink(os.path.join(fmod_path, "libfmod.so.6"))
294319
os.unlink(os.path.join(fmod_path, "libfmodL.so.6"))
295320
os.symlink("libfmod.so", os.path.join(fmod_path, "libfmod.so.6"))
296321
os.symlink("libfmodL.so", os.path.join(fmod_path, "libfmodL.so.6"))
297322
else:
298-
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)
299325

300326
def run(self, workpath, folder_for_extracting, remove_downloaded, force_update, download_only):
301327
if not force_update and not self.need_to_update():
@@ -315,13 +341,16 @@ def run(self, workpath, folder_for_extracting, remove_downloaded, force_update,
315341

316342
self.clean_external_folder(folder_for_extracting)
317343
print("==> Copying files...")
318-
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)
319346
if self._move_dirs is not None:
320347
for srcDir in self._move_dirs.keys():
321-
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)
322350
if os.path.exists(distDir):
323351
shutil.rmtree(distDir)
324-
shutil.move( os.path.join(folder_for_extracting, srcDir), distDir)
352+
shutil.move(os.path.join(
353+
folder_for_extracting, srcDir), distDir)
325354
self.fix_fmod_link(folder_for_extracting)
326355
print("==> Cleaning...")
327356
if os.path.exists(self._extracted_folder_name):
@@ -336,22 +365,17 @@ def run(self, workpath, folder_for_extracting, remove_downloaded, force_update,
336365
print("==> Download (%s) finish!" % self._filename)
337366

338367

339-
def _check_python_version():
368+
def _is_python_version_2():
340369
major_ver = sys.version_info[0]
370+
print("The python version is %d.%d." % (major_ver, sys.version_info[1]))
341371
if major_ver > 2:
342-
print ("The python version is %d.%d. But python 2.x is required. (Version 2.7 is well tested)\n"
343-
"Download it here: https://www.python.org/" % (major_ver, sys.version_info[1]))
344372
return False
345-
346373
return True
347374

348375

349376
def main():
350377
workpath = os.path.dirname(os.path.realpath(__file__))
351378

352-
if not _check_python_version():
353-
exit()
354-
355379
parser = OptionParser()
356380
parser.add_option('-r', '--remove-download',
357381
action="store", type="string", dest='remove_downloaded', default=None,
@@ -370,11 +394,15 @@ def main():
370394
print("=======================================================")
371395
print("==> Prepare to download external libraries!")
372396
external_path = os.path.join(workpath, 'external')
373-
installer = CocosZipInstaller(workpath, os.path.join(workpath, 'external', 'config.json'), os.path.join(workpath, 'external', 'version.json'), "prebuilt_libs_version")
374-
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+
375402

376403
# -------------- main --------------
377404
if __name__ == '__main__':
405+
python_2 = _is_python_version_2()
378406
try:
379407
main()
380408
except Exception as e:

tests/cpp-tests/CMakeLists.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -488,9 +488,8 @@ if(LINUX OR WINDOWS)
488488
cocos_copy_target_res(${APP_NAME} COPY_TO ${APP_RES_DIR} FOLDERS ${GAME_RES_FOLDER})
489489
endif()
490490

491-
if(WINDOWS)
492-
# precompiled header. Compilation time speedup ~4x.
493-
target_sources(${APP_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/Classes/precheader.cpp")
494-
set_target_properties(${APP_NAME} PROPERTIES COMPILE_FLAGS "/Yuprecheader.h /FIprecheader.h")
495-
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/Classes/precheader.cpp" PROPERTIES COMPILE_FLAGS "/Ycprecheader.h")
491+
if(${CMAKE_VERSION} VERSION_GREATER "3.16.0")
492+
message("CMake 3.16 target_precompile_headers")
493+
target_precompile_headers(${APP_NAME} PRIVATE
494+
"$<$<COMPILE_LANGUAGE:CXX>:precheader.h>")
496495
endif()

0 commit comments

Comments
 (0)