mirror of https://github.com/axmolengine/axmol.git
Improve android setup tools
- Rename ANDROID_SDK to ANDROID_SDK_ROOT, refer to: https://developer.android.google.cn/studio/command-line/variables - CMake: Use ndk in sdk_root/ndk/xxx/
This commit is contained in:
parent
f152c8edf3
commit
f40c44755f
|
@ -103,15 +103,8 @@ class axistools {
|
|||
ndkVer = ndkVer.substring(0, ndkVer.length() - 1)
|
||||
}
|
||||
|
||||
/* Collect ndk dirs */
|
||||
def ndkRoot = Paths.get("${System.env.ANDROID_NDK}")
|
||||
def ndkDirs = []
|
||||
if (Files.exists(ndkRoot)) {
|
||||
ndkRoot = ndkRoot.toAbsolutePath().toString()
|
||||
ndkDirs.add(ndkRoot)
|
||||
}
|
||||
|
||||
def sdkRoot = Paths.get("${System.env.ANDROID_SDK}")
|
||||
def sdkRoot = Paths.get("${System.env.ANDROID_SDK_ROOT}")
|
||||
if (Files.exists(sdkRoot)) {
|
||||
File dir = new File(sdkRoot.toAbsolutePath().toString() + '/ndk')
|
||||
if (dir.isDirectory()) {
|
||||
|
@ -159,7 +152,7 @@ class axistools {
|
|||
}
|
||||
}
|
||||
|
||||
def sdkRoot = Paths.get("${System.env.ANDROID_SDK}")
|
||||
def sdkRoot = Paths.get("${System.env.ANDROID_SDK_ROOT}")
|
||||
|
||||
if(Files.exists(sdkRoot)) {
|
||||
def verList = []
|
||||
|
|
18
setup.py
18
setup.py
|
@ -29,7 +29,7 @@ THE SOFTWARE.
|
|||
This script will install environment variables needed to by axis. It will set these envrironment variables:
|
||||
* AXIS_CONSOLE_ROOT: used to run axis console tools
|
||||
* ANDROID_NDK: used to build android native codes
|
||||
* ANDROID_SDK: used to generate applicatoin on Android through commands
|
||||
* ANDROID_SDK_ROOT: used to generate applicatoin on Android through commands
|
||||
* AXIS_ROOT: path where axis is installed
|
||||
|
||||
On Max OS X, when start a shell, it will read these files and execute commands in sequence:
|
||||
|
@ -67,7 +67,7 @@ AXIS_ROOT = 'AXIS_ROOT'
|
|||
AXIS_CONSOLE_ROOT = 'AXIS_CONSOLE_ROOT'
|
||||
|
||||
ANDROID_NDK = 'ANDROID_NDK'
|
||||
ANDROID_SDK = 'ANDROID_SDK'
|
||||
ANDROID_SDK_ROOT = 'ANDROID_SDK_ROOT'
|
||||
|
||||
def _check_python_version():
|
||||
major_ver = sys.version_info[0]
|
||||
|
@ -194,7 +194,7 @@ class SetEnvVar(object):
|
|||
file.write('\n# Add environment variable %s for axis\n' % key)
|
||||
file.write('export %s="%s"\n' % (key, value))
|
||||
file.write('export PATH=$%s:$PATH\n' % key)
|
||||
if key == ANDROID_SDK:
|
||||
if key == ANDROID_SDK_ROOT:
|
||||
file.write(
|
||||
'export PATH=$%s/tools:$%s/platform-tools:$PATH\n' % (key, key))
|
||||
file.close()
|
||||
|
@ -296,7 +296,7 @@ class SetEnvVar(object):
|
|||
# if sys_var == ANDROID_NDK:
|
||||
# root.wm_title('Set ANDROID_NDK')
|
||||
# else:
|
||||
# root.wm_title('Set ANDROID_SDK')
|
||||
# root.wm_title('Set ANDROID_SDK_ROOT')
|
||||
|
||||
# def callback():
|
||||
# self.tmp_input_value = tkFileDialog.askdirectory()
|
||||
|
@ -312,14 +312,14 @@ class SetEnvVar(object):
|
|||
# You can safely skip this step now. You can set the ANDROID_NDK later.
|
||||
# """
|
||||
|
||||
# if sys_var == ANDROID_SDK:
|
||||
# if sys_var == ANDROID_SDK_ROOT:
|
||||
# label_content = 'Select path for Android SDK'
|
||||
# label_help = """
|
||||
# The Android SDK is needed to develop games for Android.
|
||||
# For further information, go to:
|
||||
# https://developer.android.com/tools/sdk/ndk/index.html.
|
||||
|
||||
# You can safely skip this step now. You can set the ANDROID_SDK later.
|
||||
# You can safely skip this step now. You can set the ANDROID_SDK_ROOT later.
|
||||
# """
|
||||
|
||||
# Tkinter.Label(root, text=label_help).pack()
|
||||
|
@ -346,7 +346,7 @@ class SetEnvVar(object):
|
|||
ret = False
|
||||
if var_name == ANDROID_NDK:
|
||||
ret = self._is_ndk_root_valid(value)
|
||||
elif var_name == ANDROID_SDK:
|
||||
elif var_name == ANDROID_SDK_ROOT:
|
||||
ret = self._is_android_sdk_root_valid(value)
|
||||
else:
|
||||
ret = False
|
||||
|
@ -583,7 +583,7 @@ class SetEnvVar(object):
|
|||
def _find_value_from_sys(self, var_name):
|
||||
if var_name == ANDROID_NDK:
|
||||
return self._get_ndkbuild_path()
|
||||
elif var_name == ANDROID_SDK:
|
||||
elif var_name == ANDROID_SDK_ROOT:
|
||||
return self._get_androidsdk_path()
|
||||
else:
|
||||
return None
|
||||
|
@ -656,7 +656,7 @@ class SetEnvVar(object):
|
|||
self.file_used_for_setup)
|
||||
if(quiet) :
|
||||
ndk_ret = self.set_variable(ANDROID_NDK, ndk_root)
|
||||
sdk_ret = self.set_variable(ANDROID_SDK, android_sdk_root)
|
||||
sdk_ret = self.set_variable(ANDROID_SDK_ROOT, android_sdk_root)
|
||||
|
||||
# tip the backup file
|
||||
if (self.backup_file is not None) and (os.path.exists(self.backup_file)):
|
||||
|
|
|
@ -4,14 +4,8 @@ set(target_name ${lib_name})
|
|||
|
||||
project(${lib_name})
|
||||
|
||||
# CMake from android SDK set ANDROID_NDK instead of CMAKE_ANDROID_NDK
|
||||
if(ANDROID_NDK)
|
||||
add_library(${target_name} ${ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c)
|
||||
set(cpufeatures_include_dir ${ANDROID_NDK}/sources/android/cpufeatures CACHE INTERNAL "cpufeatures include directory")
|
||||
else()
|
||||
add_library(${target_name} ${CMAKE_ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c)
|
||||
set(cpufeatures_include_dir ${CMAKE_ANDROID_NDK}/sources/android/cpufeatures CACHE INTERNAL "cpufeatures include directory")
|
||||
endif()
|
||||
|
||||
set_target_properties(${target_name} PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${cpufeatures_include_dir})
|
||||
|
|
|
@ -53,7 +53,7 @@ class AndroidBuilder(object):
|
|||
self.build_type = build_type
|
||||
|
||||
# check environment variable
|
||||
self.sdk_root = axis.check_environment_variable('ANDROID_SDK')
|
||||
self.sdk_root = axis.check_environment_variable('ANDROID_SDK_ROOT')
|
||||
self.ant_root = None
|
||||
if os.path.exists(os.path.join(self.app_android_root, "gradle.properties")):
|
||||
self.sign_prop_file = os.path.join(self.app_android_root, "gradle.properties")
|
||||
|
|
|
@ -160,7 +160,7 @@ class CCPluginDeploy(axis.CCPlugin):
|
|||
self.package = compile_dep.android_package
|
||||
self.activity = compile_dep.android_activity
|
||||
apk_path = compile_dep.apk_path
|
||||
sdk_root = axis.check_environment_variable('ANDROID_SDK')
|
||||
sdk_root = axis.check_environment_variable('ANDROID_SDK_ROOT')
|
||||
adb_path = axis.CMDRunner.convert_path_to_cmd(os.path.join(sdk_root, 'platform-tools', 'adb'))
|
||||
|
||||
if not self._no_uninstall:
|
||||
|
|
|
@ -238,7 +238,7 @@ class CCPluginRun(axis.CCPlugin):
|
|||
if not self._platforms.is_android_active():
|
||||
return
|
||||
|
||||
sdk_root = axis.check_environment_variable('ANDROID_SDK')
|
||||
sdk_root = axis.check_environment_variable('ANDROID_SDK_ROOT')
|
||||
adb_path = axis.CMDRunner.convert_path_to_cmd(os.path.join(sdk_root, 'platform-tools', 'adb'))
|
||||
deploy_dep = dependencies['deploy']
|
||||
startapp = "%s shell am start -n \"%s/%s\"" % (adb_path, deploy_dep.package, deploy_dep.activity)
|
||||
|
|
|
@ -33,8 +33,8 @@ CMDLINETOOLS_REV = "8512546"
|
|||
NDK_VER = "23.2.8568313" # "r23c LTS"
|
||||
|
||||
# ANDROID_NDK = os.path.join(ROOT_DIR, "android-ndk-" + NDK_VER)
|
||||
ANDROID_SDK = os.path.join(ROOT_DIR, "android-sdk")
|
||||
ANDROID_NDK = os.path.join(ANDROID_SDK, "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":
|
||||
|
@ -95,9 +95,9 @@ def install_android_cmdline_tools():
|
|||
@retry(Exception, tries=5, delay=1, backoff=1)
|
||||
def install_android_sdk():
|
||||
# list packages
|
||||
run_with_yes(SDK_MANAGER + " --list --sdk_root=" + ANDROID_SDK)
|
||||
run_with_yes(SDK_MANAGER + " --list --sdk_root=" + ANDROID_SDK_ROOT)
|
||||
|
||||
switches = " --verbose --sdk_root=" + ANDROID_SDK + " "
|
||||
switches = " --verbose --sdk_root=" + ANDROID_SDK_ROOT + " "
|
||||
cmd_base = SDK_MANAGER + switches
|
||||
packages = [
|
||||
'platform-tools',
|
||||
|
@ -115,17 +115,13 @@ def install_android_sdk():
|
|||
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=" + ANDROID_SDK + "\n")
|
||||
myfile.write("export ANDROID_HOME=" + ANDROID_SDK + "\n")
|
||||
myfile.write("export ANDROID_SDK_ROOT=" + ANDROID_SDK + "\n")
|
||||
myfile.write("export ANDROID_NDK=" + ANDROID_NDK + "\n")
|
||||
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_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=\"" + ANDROID_SDK + "\"\n")
|
||||
myfile.write("$env:ANDROID_HOME=\"" + ANDROID_SDK + "\"\n")
|
||||
myfile.write("$env:ANDROID_SDK_ROOT=\"" + ANDROID_SDK + "\"\n")
|
||||
myfile.write("$env:ANDROID_NDK=\"" + ANDROID_NDK + "\"\n")
|
||||
myfile.write("$env:ANDROID_SDK_ROOT=\"" + ANDROID_SDK_ROOT + "\"\n")
|
||||
myfile.write("$env:ANDROID_NDK=\"" + ANDROID_NDK + "\"\n") # for lua binding generator
|
||||
|
||||
def main(ndk_only):
|
||||
install_android_cmdline_tools()
|
||||
|
|
Loading…
Reference in New Issue