mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-31 02:00:45 +00:00
utils/android: Update to discover android tools from PATH
Allow falling back to detecting the required android tools from PATH.
This commit is contained in:
parent
bae741dc81
commit
b52462440c
@ -641,6 +641,7 @@ class _AndroidEnvironment(object):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.android_home = None
|
self.android_home = None
|
||||||
self.platform_tools = None
|
self.platform_tools = None
|
||||||
|
self.build_tools = None
|
||||||
self.adb = None
|
self.adb = None
|
||||||
self.aapt = None
|
self.aapt = None
|
||||||
self.fastboot = None
|
self.fastboot = None
|
||||||
@ -668,25 +669,35 @@ def _initialize_without_android_home(env):
|
|||||||
_init_common(env)
|
_init_common(env)
|
||||||
return env
|
return env
|
||||||
|
|
||||||
|
|
||||||
def _init_common(env):
|
def _init_common(env):
|
||||||
|
_discover_build_tools(env)
|
||||||
|
_discover_aapt(env)
|
||||||
|
|
||||||
|
def _discover_build_tools(env):
|
||||||
logger.debug('ANDROID_HOME: {}'.format(env.android_home))
|
logger.debug('ANDROID_HOME: {}'.format(env.android_home))
|
||||||
build_tools_directory = os.path.join(env.android_home, 'build-tools')
|
build_tools_directory = os.path.join(env.android_home, 'build-tools')
|
||||||
if not os.path.isdir(build_tools_directory):
|
if not os.path.isdir(build_tools_directory):
|
||||||
msg = '''ANDROID_HOME ({}) does not appear to have valid Android SDK install
|
msg = '''ANDROID_HOME ({}) does not appear to have valid Android SDK install
|
||||||
(cannot find build-tools)'''
|
(cannot find build-tools)'''
|
||||||
raise HostError(msg.format(env.android_home))
|
raise HostError(msg.format(env.android_home))
|
||||||
versions = os.listdir(build_tools_directory)
|
env.build_tools = build_tools_directory
|
||||||
for version in reversed(sorted(versions)):
|
|
||||||
aapt_path = os.path.join(build_tools_directory, version, 'aapt')
|
|
||||||
if os.path.isfile(aapt_path):
|
|
||||||
logger.debug('Using aapt for version {}'.format(version))
|
|
||||||
env.aapt = aapt_path
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
raise HostError('aapt not found. Please make sure at least one Android '
|
|
||||||
'platform is installed.')
|
|
||||||
|
|
||||||
|
def _discover_aapt(env):
|
||||||
|
if env.build_tools:
|
||||||
|
versions = os.listdir(env.build_tools)
|
||||||
|
for version in reversed(sorted(versions)):
|
||||||
|
aapt_path = os.path.join(env.build_tools, version, 'aapt')
|
||||||
|
if os.path.isfile(aapt_path):
|
||||||
|
logger.debug('Using aapt for version {}'.format(version))
|
||||||
|
env.aapt = aapt_path
|
||||||
|
break
|
||||||
|
|
||||||
|
if not env.aapt:
|
||||||
|
env.aapt = which(aapt)
|
||||||
|
|
||||||
|
if not env.aapt:
|
||||||
|
raise HostError('aapt not found. Please make sure it is avaliable in PATH'
|
||||||
|
' or at least one Android platform is installed')
|
||||||
|
|
||||||
def _check_env():
|
def _check_env():
|
||||||
global android_home, platform_tools, adb, aapt # pylint: disable=W0603
|
global android_home, platform_tools, adb, aapt # pylint: disable=W0603
|
||||||
|
Loading…
x
Reference in New Issue
Block a user