Commit 068b9cb4 authored by mlamouri@chromium.org's avatar mlamouri@chromium.org

Make adb_install_apk.py saner for humans.

Scripts like that usually do not require a --option if this is a
mandatory singleton argument. Also, forgetting to pass the extension
sounds like something that the script could simply handle.

BUG=None

Review URL: https://codereview.chromium.org/286423002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275755 0039d316-1c4b-4281-b951-d872f2087c98
parent 98380336
...@@ -19,7 +19,7 @@ from pylib.utils import apk_helper ...@@ -19,7 +19,7 @@ from pylib.utils import apk_helper
def AddInstallAPKOption(option_parser): def AddInstallAPKOption(option_parser):
"""Adds apk option used to install the APK to the OptionParser.""" """Adds apk option used to install the APK to the OptionParser."""
option_parser.add_option('--apk', option_parser.add_option('--apk',
help=('The name of the apk containing the ' help=('DEPRECATED The name of the apk containing the'
' application (with the .apk extension).')) ' application (with the .apk extension).'))
option_parser.add_option('--apk_package', option_parser.add_option('--apk_package',
help=('The package name used by the apk containing ' help=('The package name used by the apk containing '
...@@ -40,10 +40,17 @@ def AddInstallAPKOption(option_parser): ...@@ -40,10 +40,17 @@ def AddInstallAPKOption(option_parser):
'Default is env var BUILDTYPE or Debug.') 'Default is env var BUILDTYPE or Debug.')
def ValidateInstallAPKOption(option_parser, options): def ValidateInstallAPKOption(option_parser, options, args):
"""Validates the apk option and potentially qualifies the path.""" """Validates the apk option and potentially qualifies the path."""
if not options.apk: if not options.apk:
option_parser.error('--apk is mandatory.') if len(args) > 1:
options.apk = args[1]
else:
option_parser.error('apk target not specified.')
if not options.apk.endswith('.apk'):
options.apk += '.apk'
if not os.path.exists(options.apk): if not os.path.exists(options.apk):
options.apk = os.path.join(constants.GetOutDirectory(), 'apks', options.apk = os.path.join(constants.GetOutDirectory(), 'apks',
options.apk) options.apk)
...@@ -51,12 +58,17 @@ def ValidateInstallAPKOption(option_parser, options): ...@@ -51,12 +58,17 @@ def ValidateInstallAPKOption(option_parser, options):
def main(argv): def main(argv):
parser = optparse.OptionParser() parser = optparse.OptionParser()
parser.set_usage("usage: %prog [options] target")
AddInstallAPKOption(parser) AddInstallAPKOption(parser)
options, args = parser.parse_args(argv) options, args = parser.parse_args(argv)
if len(args) > 1 and options.apk:
parser.error("Appending the apk as argument can't be used with --apk.")
elif len(args) > 2:
parser.error("Too many arguments.")
constants.SetBuildType(options.build_type) constants.SetBuildType(options.build_type)
ValidateInstallAPKOption(parser, options) ValidateInstallAPKOption(parser, options, args)
if len(args) > 1:
raise Exception('Error: Unknown argument:', args[1:])
devices = android_commands.GetAttachedDevices() devices = android_commands.GetAttachedDevices()
if not devices: if not devices:
......
...@@ -181,9 +181,10 @@ def InstallApk(options, test, print_step=False): ...@@ -181,9 +181,10 @@ def InstallApk(options, test, print_step=False):
if print_step: if print_step:
bb_annotations.PrintNamedStep('install_%s' % test.name.lower()) bb_annotations.PrintNamedStep('install_%s' % test.name.lower())
args = ['--apk', test.apk, '--apk_package', test.apk_package] args = ['--apk_package', test.apk_package]
if options.target == 'Release': if options.target == 'Release':
args.append('--release') args.append('--release')
args.append(test.apk)
RunCmd(['build/android/adb_install_apk.py'] + args, halt_on_failure=True) RunCmd(['build/android/adb_install_apk.py'] + args, halt_on_failure=True)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment