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)
|
ndkVer = ndkVer.substring(0, ndkVer.length() - 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Collect ndk dirs */
|
|
||||||
def ndkRoot = Paths.get("${System.env.ANDROID_NDK}")
|
|
||||||
def ndkDirs = []
|
def ndkDirs = []
|
||||||
if (Files.exists(ndkRoot)) {
|
def sdkRoot = Paths.get("${System.env.ANDROID_SDK_ROOT}")
|
||||||
ndkRoot = ndkRoot.toAbsolutePath().toString()
|
|
||||||
ndkDirs.add(ndkRoot)
|
|
||||||
}
|
|
||||||
|
|
||||||
def sdkRoot = Paths.get("${System.env.ANDROID_SDK}")
|
|
||||||
if (Files.exists(sdkRoot)) {
|
if (Files.exists(sdkRoot)) {
|
||||||
File dir = new File(sdkRoot.toAbsolutePath().toString() + '/ndk')
|
File dir = new File(sdkRoot.toAbsolutePath().toString() + '/ndk')
|
||||||
if (dir.isDirectory()) {
|
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)) {
|
if(Files.exists(sdkRoot)) {
|
||||||
def verList = []
|
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:
|
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
|
* AXIS_CONSOLE_ROOT: used to run axis console tools
|
||||||
* ANDROID_NDK: used to build android native codes
|
* 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
|
* 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:
|
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'
|
AXIS_CONSOLE_ROOT = 'AXIS_CONSOLE_ROOT'
|
||||||
|
|
||||||
ANDROID_NDK = 'ANDROID_NDK'
|
ANDROID_NDK = 'ANDROID_NDK'
|
||||||
ANDROID_SDK = 'ANDROID_SDK'
|
ANDROID_SDK_ROOT = 'ANDROID_SDK_ROOT'
|
||||||
|
|
||||||
def _check_python_version():
|
def _check_python_version():
|
||||||
major_ver = sys.version_info[0]
|
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('\n# Add environment variable %s for axis\n' % key)
|
||||||
file.write('export %s="%s"\n' % (key, value))
|
file.write('export %s="%s"\n' % (key, value))
|
||||||
file.write('export PATH=$%s:$PATH\n' % key)
|
file.write('export PATH=$%s:$PATH\n' % key)
|
||||||
if key == ANDROID_SDK:
|
if key == ANDROID_SDK_ROOT:
|
||||||
file.write(
|
file.write(
|
||||||
'export PATH=$%s/tools:$%s/platform-tools:$PATH\n' % (key, key))
|
'export PATH=$%s/tools:$%s/platform-tools:$PATH\n' % (key, key))
|
||||||
file.close()
|
file.close()
|
||||||
|
@ -296,7 +296,7 @@ class SetEnvVar(object):
|
||||||
# if sys_var == ANDROID_NDK:
|
# if sys_var == ANDROID_NDK:
|
||||||
# root.wm_title('Set ANDROID_NDK')
|
# root.wm_title('Set ANDROID_NDK')
|
||||||
# else:
|
# else:
|
||||||
# root.wm_title('Set ANDROID_SDK')
|
# root.wm_title('Set ANDROID_SDK_ROOT')
|
||||||
|
|
||||||
# def callback():
|
# def callback():
|
||||||
# self.tmp_input_value = tkFileDialog.askdirectory()
|
# 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.
|
# 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_content = 'Select path for Android SDK'
|
||||||
# label_help = """
|
# label_help = """
|
||||||
# The Android SDK is needed to develop games for Android.
|
# The Android SDK is needed to develop games for Android.
|
||||||
# For further information, go to:
|
# For further information, go to:
|
||||||
# https://developer.android.com/tools/sdk/ndk/index.html.
|
# 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()
|
# Tkinter.Label(root, text=label_help).pack()
|
||||||
|
@ -346,7 +346,7 @@ class SetEnvVar(object):
|
||||||
ret = False
|
ret = False
|
||||||
if var_name == ANDROID_NDK:
|
if var_name == ANDROID_NDK:
|
||||||
ret = self._is_ndk_root_valid(value)
|
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)
|
ret = self._is_android_sdk_root_valid(value)
|
||||||
else:
|
else:
|
||||||
ret = False
|
ret = False
|
||||||
|
@ -583,7 +583,7 @@ class SetEnvVar(object):
|
||||||
def _find_value_from_sys(self, var_name):
|
def _find_value_from_sys(self, var_name):
|
||||||
if var_name == ANDROID_NDK:
|
if var_name == ANDROID_NDK:
|
||||||
return self._get_ndkbuild_path()
|
return self._get_ndkbuild_path()
|
||||||
elif var_name == ANDROID_SDK:
|
elif var_name == ANDROID_SDK_ROOT:
|
||||||
return self._get_androidsdk_path()
|
return self._get_androidsdk_path()
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
@ -656,7 +656,7 @@ class SetEnvVar(object):
|
||||||
self.file_used_for_setup)
|
self.file_used_for_setup)
|
||||||
if(quiet) :
|
if(quiet) :
|
||||||
ndk_ret = self.set_variable(ANDROID_NDK, ndk_root)
|
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
|
# tip the backup file
|
||||||
if (self.backup_file is not None) and (os.path.exists(self.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})
|
project(${lib_name})
|
||||||
|
|
||||||
# CMake from android SDK set ANDROID_NDK instead of CMAKE_ANDROID_NDK
|
add_library(${target_name} ${CMAKE_ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c)
|
||||||
if(ANDROID_NDK)
|
set(cpufeatures_include_dir ${CMAKE_ANDROID_NDK}/sources/android/cpufeatures CACHE INTERNAL "cpufeatures include directory")
|
||||||
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
|
set_target_properties(${target_name} PROPERTIES
|
||||||
INTERFACE_INCLUDE_DIRECTORIES ${cpufeatures_include_dir})
|
INTERFACE_INCLUDE_DIRECTORIES ${cpufeatures_include_dir})
|
||||||
|
|
|
@ -53,7 +53,7 @@ class AndroidBuilder(object):
|
||||||
self.build_type = build_type
|
self.build_type = build_type
|
||||||
|
|
||||||
# check environment variable
|
# 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
|
self.ant_root = None
|
||||||
if os.path.exists(os.path.join(self.app_android_root, "gradle.properties")):
|
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")
|
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.package = compile_dep.android_package
|
||||||
self.activity = compile_dep.android_activity
|
self.activity = compile_dep.android_activity
|
||||||
apk_path = compile_dep.apk_path
|
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'))
|
adb_path = axis.CMDRunner.convert_path_to_cmd(os.path.join(sdk_root, 'platform-tools', 'adb'))
|
||||||
|
|
||||||
if not self._no_uninstall:
|
if not self._no_uninstall:
|
||||||
|
|
|
@ -238,7 +238,7 @@ class CCPluginRun(axis.CCPlugin):
|
||||||
if not self._platforms.is_android_active():
|
if not self._platforms.is_android_active():
|
||||||
return
|
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'))
|
adb_path = axis.CMDRunner.convert_path_to_cmd(os.path.join(sdk_root, 'platform-tools', 'adb'))
|
||||||
deploy_dep = dependencies['deploy']
|
deploy_dep = dependencies['deploy']
|
||||||
startapp = "%s shell am start -n \"%s/%s\"" % (adb_path, deploy_dep.package, deploy_dep.activity)
|
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"
|
NDK_VER = "23.2.8568313" # "r23c LTS"
|
||||||
|
|
||||||
# ANDROID_NDK = os.path.join(ROOT_DIR, "android-ndk-" + NDK_VER)
|
# ANDROID_NDK = os.path.join(ROOT_DIR, "android-ndk-" + NDK_VER)
|
||||||
ANDROID_SDK = os.path.join(ROOT_DIR, "android-sdk")
|
ANDROID_SDK_ROOT = os.path.join(ROOT_DIR, "android-sdk")
|
||||||
ANDROID_NDK = os.path.join(ANDROID_SDK, "ndk/" + NDK_VER)
|
ANDROID_NDK = os.path.join(ANDROID_SDK_ROOT, "ndk/" + NDK_VER)
|
||||||
SDK_MANAGER = os.path.join(ROOT_DIR, "cmdline-tools/bin/sdkmanager")
|
SDK_MANAGER = os.path.join(ROOT_DIR, "cmdline-tools/bin/sdkmanager")
|
||||||
SYSTEM = platform.system().lower()
|
SYSTEM = platform.system().lower()
|
||||||
if SYSTEM == "windows":
|
if SYSTEM == "windows":
|
||||||
|
@ -95,9 +95,9 @@ def install_android_cmdline_tools():
|
||||||
@retry(Exception, tries=5, delay=1, backoff=1)
|
@retry(Exception, tries=5, delay=1, backoff=1)
|
||||||
def install_android_sdk():
|
def install_android_sdk():
|
||||||
# list packages
|
# 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
|
cmd_base = SDK_MANAGER + switches
|
||||||
packages = [
|
packages = [
|
||||||
'platform-tools',
|
'platform-tools',
|
||||||
|
@ -115,17 +115,13 @@ def install_android_sdk():
|
||||||
def export_environment(ndk_only):
|
def export_environment(ndk_only):
|
||||||
with open(os.path.join(ROOT_DIR, "environment.sh"), "a") as myfile:
|
with open(os.path.join(ROOT_DIR, "environment.sh"), "a") as myfile:
|
||||||
if not ndk_only:
|
if not ndk_only:
|
||||||
myfile.write("export ANDROID_SDK=" + ANDROID_SDK + "\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_HOME=" + ANDROID_SDK + "\n")
|
myfile.write("export ANDROID_NDK=" + ANDROID_NDK + "\n") # for lua binding generator
|
||||||
myfile.write("export ANDROID_SDK_ROOT=" + ANDROID_SDK + "\n")
|
|
||||||
myfile.write("export ANDROID_NDK=" + ANDROID_NDK + "\n")
|
|
||||||
|
|
||||||
with open(os.path.join(ROOT_DIR, "environment.ps1"), "a") as myfile:
|
with open(os.path.join(ROOT_DIR, "environment.ps1"), "a") as myfile:
|
||||||
if not ndk_only:
|
if not ndk_only:
|
||||||
myfile.write("$env:ANDROID_SDK=\"" + ANDROID_SDK + "\"\n")
|
myfile.write("$env:ANDROID_SDK_ROOT=\"" + ANDROID_SDK_ROOT + "\"\n")
|
||||||
myfile.write("$env:ANDROID_HOME=\"" + ANDROID_SDK + "\"\n")
|
myfile.write("$env:ANDROID_NDK=\"" + ANDROID_NDK + "\"\n") # for lua binding generator
|
||||||
myfile.write("$env:ANDROID_SDK_ROOT=\"" + ANDROID_SDK + "\"\n")
|
|
||||||
myfile.write("$env:ANDROID_NDK=\"" + ANDROID_NDK + "\"\n")
|
|
||||||
|
|
||||||
def main(ndk_only):
|
def main(ndk_only):
|
||||||
install_android_cmdline_tools()
|
install_android_cmdline_tools()
|
||||||
|
|
Loading…
Reference in New Issue