diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000000..d1d1f80ab020 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,97 @@ +# This is a basic workflow to help you get started with Actions + +name: CI + +on: + push: + branches: [ v4, v3 ] + pull_request: + branches: [ v4, v3 ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + ubuntu-18_04: + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + - run: python download-deps.py --r no + - run: echo -e "y" | bash build/install-deps-linux.sh + - run: cmake -B b -S . + - run: cmake --build b + + ubuntu-20_04: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - run: python download-deps.py --r no + - run: echo -e "y" | bash build/install-deps-linux.sh + - run: cmake -B b -S . + - run: cmake --build b + + windows-2019: + runs-on: windows-2019 + steps: + - uses: actions/checkout@v2 + - run: python download-deps.py --r no + - run: cmake -B b -S . -G "Visual Studio 16 2019" -A Win32 + - run: cmake --build b + + windows-2022: + runs-on: windows-2022 + steps: + - uses: actions/checkout@v2 + - run: python download-deps.py --r no + - run: cmake -B b -S . -G "Visual Studio 17 2022" -A Win32 + - run: cmake --build b + + macos-10_15: + runs-on: macos-10.15 + steps: + - uses: actions/checkout@v2 + - run: python download-deps.py --r no + - run: cmake -B b -S . + - run: cmake --build b + + macos-11: + runs-on: macos-11 + steps: + - uses: actions/checkout@v2 + - run: python download-deps.py --r no + - run: cmake -B b -S . + - run: cmake --build b + + macos-10_15_ios: + runs-on: macos-10.15 + steps: + - uses: actions/checkout@v2 + - run: python download-deps.py --r no + - run: cmake -B b -S . -GXcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator + - run: cmake --build b --config Release --target cpp-tests -- -quiet + + macos-11_ios: + runs-on: macos-11 + steps: + - uses: actions/checkout@v2 + - run: python download-deps.py --r no + - run: cmake -B b -S . -GXcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator + - run: cmake --build b --config Release --target cpp-tests -- -quiet -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)" + + windows-2019-android: + runs-on: windows-2019 + steps: + - uses: actions/checkout@v2 + - run: python download-deps.py --r no + - run: ./gradlew assembleRelease -PPROP_BUILD_TYPE=cmake --info + shell: bash + working-directory: tests/cpp-tests/proj.android + + ubuntu-20_04-android: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - run: python download-deps.py --r no + - run: ./gradlew assembleRelease -PPROP_BUILD_TYPE=cmake --info + shell: bash + working-directory: tests/cpp-tests/proj.android diff --git a/build/install-deps-linux.sh b/build/install-deps-linux.sh index cf6bab4dae32..eb86ba7ae986 100755 --- a/build/install-deps-linux.sh +++ b/build/install-deps-linux.sh @@ -17,7 +17,7 @@ DEPENDS+=' libglu1-mesa-dev' DEPENDS+=' libgl2ps-dev' DEPENDS+=' libxi-dev' DEPENDS+=' libzip-dev' -DEPENDS+=' libpng12-dev' +DEPENDS+=' libpng-dev' DEPENDS+=' libcurl4-gnutls-dev' DEPENDS+=' libfontconfig1-dev' DEPENDS+=' libsqlite3-dev' @@ -25,5 +25,6 @@ DEPENDS+=' libglew-dev' DEPENDS+=' libssl-dev' DEPENDS+=' libgtk-3-dev' DEPENDS+=' binutils' +DEPENDS+=' xorg-dev' sudo apt-get install --force-yes --yes $DEPENDS > /dev/null diff --git a/cmake/Modules/CocosBuildHelpers.cmake b/cmake/Modules/CocosBuildHelpers.cmake index f88058e3626b..f9d46060b682 100644 --- a/cmake/Modules/CocosBuildHelpers.cmake +++ b/cmake/Modules/CocosBuildHelpers.cmake @@ -269,7 +269,7 @@ endmacro() # custom Xcode property for iOS target macro(cocos_config_target_xcode_property cocos_target) if(IOS) - set_xcode_property(${cocos_target} IPHONEOS_DEPLOYMENT_TARGET "8.0") + set_xcode_property(${cocos_target} IPHONEOS_DEPLOYMENT_TARGET "9.0") set_xcode_property(${cocos_target} ENABLE_BITCODE "NO") set_xcode_property(${cocos_target} ONLY_ACTIVE_ARCH "YES") endif() diff --git a/cmake/Modules/CocosConfigDefine.cmake b/cmake/Modules/CocosConfigDefine.cmake index 024ed3be5158..bc7b41a8239c 100644 --- a/cmake/Modules/CocosConfigDefine.cmake +++ b/cmake/Modules/CocosConfigDefine.cmake @@ -17,14 +17,13 @@ set(PLATFORM_FOLDER linux) endif() elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - if(IOS) - set(APPLE TRUE) - set(PLATFORM_FOLDER ios) - else() - set(APPLE TRUE) - set(MACOSX TRUE) - set(PLATFORM_FOLDER mac) - endif() + set(APPLE TRUE) + set(MACOSX TRUE) + set(PLATFORM_FOLDER mac) + elseif(${CMAKE_SYSTEM_NAME} MATCHES "iOS") + set(APPLE TRUE) + set(IOS TRUE) + set(PLATFORM_FOLDER ios) else() message(FATAL_ERROR "Unsupported platform, CMake will exit") return() diff --git a/download-deps.py b/download-deps.py index ef0c2477659b..07afedb174b9 100755 --- a/download-deps.py +++ b/download-deps.py @@ -1,5 +1,6 @@ #!/usr/bin/env python -#coding=utf-8 + +# coding=utf-8 # # ./download-deps.py # @@ -42,14 +43,12 @@ import sys import traceback import distutils -import fileinput import json from optparse import OptionParser from time import time from time import sleep from sys import stdout -from distutils.errors import DistutilsError from distutils.dir_util import copy_tree, remove_tree @@ -92,10 +91,16 @@ def __init__(self, workpath, config_path, version_path, remote_version_key=None) except: self._move_dirs = None self._filename = self._current_version + '.zip' - self._url = data["repo_parent"] + self._repo_name + '/archive/' + self._filename + self._url = data["repo_parent"] + \ + self._repo_name + '/archive/' + self._filename self._zip_file_size = int(data["zip_file_size"]) # 'v' letter was swallowed by github, so we need to substring it from the 2nd letter - self._extracted_folder_name = os.path.join(self._workpath, self._repo_name + '-' + self._current_version[1:]) + if self._current_version[0] == 'v': + self._extracted_folder_name = os.path.join( + self._workpath, self._repo_name + '-' + self._current_version[1:]) + else: + self._extracted_folder_name = os.path.join( + self._workpath, self._repo_name + '-' + self._current_version) try: data = self.load_json_file(version_path) @@ -107,10 +112,10 @@ def __init__(self, workpath, config_path, version_path, remote_version_key=None) print("==> version file doesn't exist") def get_input_value(self, prompt): - if sys.version_info[0] > 2: - ret = input(prompt) - else: + if(python_2): ret = raw_input(prompt) + else: + ret = input(prompt) ret.rstrip(" \t") return ret @@ -120,19 +125,30 @@ def download_file(self): os.remove(self._filename) except OSError: pass - print("==> Ready to download '%s' from '%s'" % (self._filename, self._url)) - import urllib2 + print("==> Ready to download '%s' from '%s'" % + (self._filename, self._url)) + if(python_2): + import urllib2 as urllib + else: + import urllib.request as urllib try: - u = urllib2.urlopen(self._url) - except urllib2.HTTPError as e: + u = urllib.urlopen(self._url) + except Exception as e: if e.code == 404: - print("==> Error: Could not find the file from url: '%s'" % (self._url)) - print("==> Http request failed, error code: " + str(e.code) + ", reason: " + e.read()) + print("==> Error: Could not find the file from url: '%s'" % + (self._url)) + print("==> Http request failed, error code: " + + str(e.code) + ", reason: " + str(e.read())) sys.exit(1) f = open(self._filename, 'wb') meta = u.info() - content_len = meta.getheaders("Content-Length") + content_len = 0 + if(python_2): + content_len = meta.getheaders("Content-Length") + else: + content_len = meta['Content-Length'] + file_size = 0 if content_len and len(content_len) > 0: file_size = int(content_len[0]) @@ -140,7 +156,8 @@ def download_file(self): # github server may not reponse a header information which contains `Content-Length`, # therefore, the size needs to be written hardcode here. While server doesn't return # `Content-Length`, use it instead - print("==> WARNING: Couldn't grab the file size from remote, use 'zip_file_size' section in '%s'" % self._config_path) + print("==> WARNING: Couldn't grab the file size from remote, use 'zip_file_size' section in '%s'" % + self._config_path) file_size = self._zip_file_size print("==> Start to download, please wait ...") @@ -165,9 +182,11 @@ def download_file(self): speed = block_size_per_second / (new_time - old_time) / 1000.0 if file_size != 0: percent = file_size_dl * 100. / file_size - status = r"Downloaded: %6dK / Total: %dK, Percent: %3.2f%%, Speed: %6.2f KB/S " % (file_size_dl / 1000, file_size / 1000, percent, speed) + status = r"Downloaded: %6dK / Total: %dK, Percent: %3.2f%%, Speed: %6.2f KB/S " % ( + file_size_dl / 1000, file_size / 1000, percent, speed) else: - status = r"Downloaded: %6dK, Speed: %6.2f KB/S " % (file_size_dl / 1000, speed) + status = r"Downloaded: %6dK, Speed: %6.2f KB/S " % ( + file_size_dl / 1000, speed) print(status), sys.stdout.flush() print("\r"), @@ -224,7 +243,8 @@ def unpack_zipfile(self, extract_dir): print("==> Extraction done!") def ask_to_delete_downloaded_zip_file(self): - ret = self.get_input_value("==> Would you like to save '%s'? So you don't have to download it later. [Yes/no]: " % self._filename) + ret = self.get_input_value( + "==> Would you like to save '%s'? So you don't have to download it later. [Yes/no]: " % self._filename) ret = ret.strip() if ret != 'yes' and ret != 'y' and ret != 'no' and ret != 'n': print("==> Saving the dependency libraries by default") @@ -237,16 +257,17 @@ def download_zip_file(self): self.download_file_with_retry(5, 3) try: if not zipfile.is_zipfile(self._filename): - raise UnrecognizedFormat("%s is not a zip file" % (self._filename)) + raise UnrecognizedFormat( + "%s is not a zip file" % (self._filename)) except UnrecognizedFormat as e: - print("==> Unrecognized zip format from your local '%s' file!" % (self._filename)) + print("==> Unrecognized zip format from your local '%s' file!" % + (self._filename)) if os.path.isfile(self._filename): os.remove(self._filename) print("==> Download it from internet again, please wait...") self.download_zip_file() def download_file_with_retry(self, times, delay): - import urllib2 times_count = 0 while(times_count < times): times_count += 1 @@ -290,15 +311,17 @@ def fix_fmod_link(self, extract_dir): import platform if platform.system() != "Linux": return - print("==> Fix fmod link ... ") - fmod_path = os.path.join(extract_dir, "linux-specific/fmod/prebuilt/64-bit") + print("==> Fix fmod link ... ") + fmod_path = os.path.join( + extract_dir, "linux-specific/fmod/prebuilt/64-bit") if os.path.exists(fmod_path): os.unlink(os.path.join(fmod_path, "libfmod.so.6")) os.unlink(os.path.join(fmod_path, "libfmodL.so.6")) os.symlink("libfmod.so", os.path.join(fmod_path, "libfmod.so.6")) os.symlink("libfmodL.so", os.path.join(fmod_path, "libfmodL.so.6")) else: - print("==> fmod directory not found `%s`, failed to fix fmod link!"%fmod_path) + print( + "==> fmod directory not found `%s`, failed to fix fmod link!" % fmod_path) def run(self, workpath, folder_for_extracting, remove_downloaded, force_update, download_only): 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, self.clean_external_folder(folder_for_extracting) print("==> Copying files...") - distutils.dir_util.copy_tree(self._extracted_folder_name, folder_for_extracting) + distutils.dir_util.copy_tree( + self._extracted_folder_name, folder_for_extracting) if self._move_dirs is not None: for srcDir in self._move_dirs.keys(): - distDir = os.path.join( os.path.join(workpath, self._move_dirs[srcDir]), srcDir) + distDir = os.path.join(os.path.join( + workpath, self._move_dirs[srcDir]), srcDir) if os.path.exists(distDir): shutil.rmtree(distDir) - shutil.move( os.path.join(folder_for_extracting, srcDir), distDir) + shutil.move(os.path.join( + folder_for_extracting, srcDir), distDir) self.fix_fmod_link(folder_for_extracting) print("==> Cleaning...") if os.path.exists(self._extracted_folder_name): @@ -339,6 +365,14 @@ def run(self, workpath, folder_for_extracting, remove_downloaded, force_update, print("==> Download (%s) finish!" % self._filename) +def _is_python_version_2(): + major_ver = sys.version_info[0] + print("The python version is %d.%d." % (major_ver, sys.version_info[1])) + if major_ver > 2: + return False + return True + + def main(): workpath = os.path.dirname(os.path.realpath(__file__)) @@ -360,11 +394,15 @@ def main(): print("=======================================================") print("==> Prepare to download external libraries!") external_path = os.path.join(workpath, 'external') - installer = CocosZipInstaller(workpath, os.path.join(workpath, 'external', 'config.json'), os.path.join(workpath, 'external', 'version.json'), "prebuilt_libs_version") - installer.run(workpath, external_path, opts.remove_downloaded, opts.force_update, opts.download_only) + installer = CocosZipInstaller(workpath, os.path.join(workpath, 'external', 'config.json'), os.path.join( + workpath, 'external', 'version.json'), "prebuilt_libs_version") + installer.run(workpath, external_path, opts.remove_downloaded, + opts.force_update, opts.download_only) + # -------------- main -------------- if __name__ == '__main__': + python_2 = _is_python_version_2() try: main() except Exception as e: