mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-01-18 20:11:20 +00:00
util/android, get_apk_versions: try to find 'aapt' in $PATH as well
Some Linux distro provide android build-tools in packages, we should also try to find 'aapt' in $PATH if it cannot be found in $ANDROID_HOME.
This commit is contained in:
parent
7ce1044eff
commit
57a8e62be9
@ -10,13 +10,13 @@ sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
||||
|
||||
from wlauto.exceptions import WAError, ToolError
|
||||
from wlauto.utils.doc import format_simple_table
|
||||
from wlauto.utils.misc import check_output, get_null, which
|
||||
|
||||
|
||||
def get_aapt_path():
|
||||
"""Return the full path to aapt tool."""
|
||||
sdk_path = os.getenv('ANDROID_HOME')
|
||||
if not sdk_path:
|
||||
raise ToolError('Please make sure you have Android SDK installed and have ANDROID_HOME set.')
|
||||
if sdk_path:
|
||||
build_tools_directory = os.path.join(sdk_path, 'build-tools')
|
||||
versions = os.listdir(build_tools_directory)
|
||||
for version in reversed(sorted(versions)):
|
||||
@ -26,6 +26,13 @@ def get_aapt_path():
|
||||
return aapt_path
|
||||
else:
|
||||
raise ToolError('aapt not found. Please make sure at least one Android platform is installed.')
|
||||
else:
|
||||
logging.debug("ANDROID_HOME is not set, try to find in $PATH.")
|
||||
aapt_path = which('aapt')
|
||||
if aapt_path:
|
||||
logging.debug('Using aapt from {}'.format(aapt_path))
|
||||
return aapt_path
|
||||
raise ToolError('Please make sure you have Android SDK installed and have ANDROID_HOME set.')
|
||||
|
||||
|
||||
def get_apks(path):
|
||||
|
@ -27,7 +27,7 @@ import re
|
||||
|
||||
from wlauto.exceptions import DeviceError, ConfigError, HostError, WAError
|
||||
from wlauto.utils.misc import (check_output, escape_single_quotes,
|
||||
escape_double_quotes, get_null,
|
||||
escape_double_quotes, get_null, which,
|
||||
CalledProcessErrorWithStderr, ABI_MAP)
|
||||
|
||||
|
||||
@ -458,9 +458,7 @@ def _initialize_without_android_home(env):
|
||||
def _init_common(env):
|
||||
logger.debug('ANDROID_HOME: {}'.format(env.android_home))
|
||||
build_tools_directory = os.path.join(env.android_home, 'build-tools')
|
||||
if not os.path.isdir(build_tools_directory):
|
||||
msg = 'ANDROID_HOME ({}) does not appear to have valid Android SDK install (cannot find build-tools)'
|
||||
raise HostError(msg.format(env.android_home))
|
||||
if os.path.isdir(build_tools_directory):
|
||||
versions = os.listdir(build_tools_directory)
|
||||
for version in reversed(sorted(versions)):
|
||||
aapt_path = os.path.join(build_tools_directory, version, 'aapt')
|
||||
@ -470,7 +468,16 @@ def _init_common(env):
|
||||
break
|
||||
else:
|
||||
raise HostError('aapt not found. Please make sure at least one Android platform is installed.')
|
||||
|
||||
else:
|
||||
# User may already installed 'aapt' from package provided by distro's
|
||||
# Try finding in $PATH
|
||||
aapt_path = which('aapt')
|
||||
if aapt_path:
|
||||
logger.debug('Using aapt from {}'.format(aapt_path))
|
||||
env.aapt = aapt_path
|
||||
else:
|
||||
msg = 'ANDROID_HOME ({}) does not appear to have valid Android SDK install (cannot find build-tools)'
|
||||
raise HostError(msg.format(env.android_home))
|
||||
|
||||
def _check_env():
|
||||
global android_home, platform_tools, adb, aapt # pylint: disable=W0603
|
||||
|
Loading…
x
Reference in New Issue
Block a user