Merge pull request #898 from crazyhappygame/patch-2

Delete setup_android.py
This commit is contained in:
涓€绾跨伒|Deal 2022-10-06 08:56:49 +08:00 committed by GitHub
parent f72f18ce64
commit 1a0a70326c
3 changed files with 0 additions and 168 deletions

View File

@ -8,30 +8,6 @@ AX_ROOT="$DIR"/../..
HOST_NAME="" HOST_NAME=""
CURL="curl --retry 999 --retry-max-time 0" CURL="curl --retry 999 --retry-max-time 0"
function install_android_sdk()
{
echo "Installing android sdk,ndk ..."
# sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
# sudo python get-pip.py
# sudo python -m pip install retry
python -m pip install --upgrade pip
which python
which pip
python -V
pip -V
pip install retry
mkdir -p ~/.android/ && touch ~/.android/repositories.cfg # Ensure cmdline-tools works well
# cmdlinetools: commandlinetools-mac-7302050_latest.zip commandlinetools-win-7302050_latest.zip commandlinetools-linux-7302050_latest.zip
# platforms:android-30 build-tools:30.0.3
# full cmd: echo yes|cmdline-tools/bin/sdkmanager --verbose --sdk_root=sdk platform-tools "cmdline-tools;latest" "platforms;android-28" "build-tools;29.0.2" "ndk;19.2.5345600"
if [ "$BUILD_TARGET" == "android" ]\
|| [ "$BUILD_TARGET" == "android_lua" ] ; then
python $AX_ROOT/tools/unix-ci/setup_android.py
else
python $AX_ROOT/tools/unix-ci/setup_android.py --ndk_only
fi
}
function install_linux_environment() function install_linux_environment()
{ {
echo "Installing linux dependence packages ..." echo "Installing linux dependence packages ..."
@ -61,10 +37,6 @@ function install_environement()
if [ "$BUILD_TARGET" == "linux" ]; then if [ "$BUILD_TARGET" == "linux" ]; then
install_linux_environment install_linux_environment
fi fi
if [ "$BUILD_TARGET" == "android" ]; then
install_android_sdk
fi
fi fi
if [ "$GH_OS_NAME" == "osx" ]; then if [ "$GH_OS_NAME" == "osx" ]; then

View File

@ -29,7 +29,6 @@ function do_retry()
function build_linux() function build_linux()
{ {
# source ../environment.sh
cd $AX_ROOT cd $AX_ROOT
set -x set -x
cmake . -G "Unix Makefiles" -Bbuild -DCMAKE_BUILD_TYPE=Release -DAX_ENABLE_EXT_IMGUI=ON cmake . -G "Unix Makefiles" -Bbuild -DCMAKE_BUILD_TYPE=Release -DAX_ENABLE_EXT_IMGUI=ON
@ -81,7 +80,6 @@ function build_android()
# Build all samples # Build all samples
echo "Building Android samples ..." echo "Building Android samples ..."
source ../environment.sh
# build fairygui_tests # build fairygui_tests
pushd $AX_ROOT/tests/fairygui-tests/proj.android pushd $AX_ROOT/tests/fairygui-tests/proj.android

View File

@ -1,138 +0,0 @@
#!/usr/bin/env python
'''
aaa
'''
import os
import urllib
import zipfile
import platform
import sys
import subprocess
import tempfile
import argparse
import ssl
try:
ssl._create_default_https_context = ssl._create_unverified_context
print("==> setup_android.py set ssl context ok")
except Exception:
pass
from retry import retry
if(sys.version_info.major >= 3):
import urllib.request
DIR_PATH = os.path.dirname(os.path.realpath(__file__))
COCOS2D_X = os.path.abspath(os.path.join(DIR_PATH, "../.."))
# ROOT_DIR/cocos2d-x
ROOT_DIR = os.path.abspath(os.path.join(COCOS2D_X, ".."))
# cmdlinetools download page: https://developer.android.com/studio#command-tools
# commandlinetools-win-8512546_latest.zip
CMDLINETOOLS_REV = "8512546"
NDK_VER = "23.2.8568313" # "r23c LTS"
# ANDROID_NDK = os.path.join(ROOT_DIR, "android-ndk-" + NDK_VER)
ANDROID_SDK_ROOT = os.path.join(ROOT_DIR, "android-sdk")
ANDROID_NDK = os.path.join(ANDROID_SDK_ROOT, "ndk/" + NDK_VER)
SDK_MANAGER = os.path.join(ROOT_DIR, "cmdline-tools/bin/sdkmanager")
SYSTEM = platform.system().lower()
if SYSTEM == "windows":
SDK_MANAGER = SDK_MANAGER + ".bat"
def run(command):
print("=" * 80)
print(command)
subprocess.check_call(command.split())
def run_with_yes(command):
print("=" * 80)
print("yes|" + command)
f = tempfile.TemporaryFile("w")
repeat_yes = 50
f.write("y\n" * repeat_yes)
f.seek(0)
subprocess.check_call(command.split(), stdin=f)
def unzip(zip_file, directory):
print("=" * 80)
print("Unzip: " + zip_file + " to " + directory)
if SYSTEM == "windows":
zipfile.ZipFile(zip_file).extractall(directory)
else:
# module zipfile ignore priviliges i.e. +x
cmd = "unzip -d " + directory + " " + zip_file
subprocess.check_output(cmd.split())
def download(url, zip_file):
print("=" * 80)
print("Download: " + url + ", file: " + zip_file)
try:
os.remove(zip_file)
except OSError:
pass
if(sys.version_info.major >= 3):
urllib.request.urlretrieve(url, zip_file)
else:
urllib.urlretrieve(url, zip_file)
@retry(Exception, tries=5, delay=1, backoff=1)
def install_android_cmdline_tools():
file_plat = platform.system().lower()
if file_plat == "darwin":
file_plat = "mac"
file_name = "commandlinetools-{system}-{rev}_latest.zip".format(system=file_plat, rev=CMDLINETOOLS_REV)
url = "https://dl.google.com/android/repository/" + file_name
zip_file = os.path.abspath(os.path.join(ROOT_DIR, file_name)) # folder is cmdline-tools
download(url, zip_file)
unzip(zip_file, os.path.join(ROOT_DIR, ""))
@retry(Exception, tries=5, delay=1, backoff=1)
def install_android_sdk():
# list packages
run_with_yes(SDK_MANAGER + " --list --sdk_root=" + ANDROID_SDK_ROOT)
switches = " --verbose --sdk_root=" + ANDROID_SDK_ROOT + " "
cmd_base = SDK_MANAGER + switches
packages = [
'platform-tools',
'cmdline-tools;latest',
'platforms;android-33',
'build-tools;30.0.3', # match with AGP 7.2.0: https://developer.android.com/studio/releases/gradle-plugin
'cmake;3.22.1',
'ndk;' + NDK_VER
]
run_with_yes(cmd_base + " ".join(packages))
# run_with_yes(cmd_base + " --install ndk;" + NDK_VER)
def export_environment(ndk_only):
with open(os.path.join(ROOT_DIR, "environment.sh"), "a") as myfile:
if not ndk_only:
myfile.write("export ANDROID_SDK_ROOT=" + ANDROID_SDK_ROOT + "\n") # refer to: https://developer.android.google.cn/studio/command-line/variables
myfile.write("export ANDROID_HOME=" + ANDROID_SDK_ROOT + "\n") # github action has ANDROID_HOME=/usr/local/lib/android/sdk
myfile.write("export ANDROID_NDK=" + ANDROID_NDK + "\n") # for lua binding generator
with open(os.path.join(ROOT_DIR, "environment.ps1"), "a") as myfile:
if not ndk_only:
myfile.write("$env:ANDROID_SDK_ROOT=\"" + ANDROID_SDK_ROOT + "\"\n")
myfile.write("$env:ANDROID_HOME=\"" + ANDROID_SDK_ROOT + "\"\n")
myfile.write("$env:ANDROID_NDK=\"" + ANDROID_NDK + "\"\n") # for lua binding generator
def main(ndk_only):
install_android_cmdline_tools()
install_android_sdk()
export_environment(ndk_only)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Install android sdk/ndk')
parser.add_argument("--ndk_only", help="Install ndk only", action="store_true")
args = parser.parse_args()
main(args.ndk_only)