Index: build/android/adb_install_apk.py |
diff --git a/build/android/adb_install_apk.py b/build/android/adb_install_apk.py |
index a91510137925e766cf5166768f78679e7ed51c12..7a781eee62a0c0027a73a12f1a10be15c4fbf937 100755 |
--- a/build/android/adb_install_apk.py |
+++ b/build/android/adb_install_apk.py |
@@ -19,7 +19,7 @@ from pylib.utils import apk_helper |
def AddInstallAPKOption(option_parser): |
"""Adds apk option used to install the APK to the OptionParser.""" |
option_parser.add_option('--apk', |
- help=('The name of the apk containing the ' |
+ help=('DEPRECATED The name of the apk containing the' |
Nico
2015/07/23 17:14:15
I happened to look at this file today and see this
jbudorick
2015/07/23 17:28:49
I believe there are multiple reasons for doing thi
|
' application (with the .apk extension).')) |
option_parser.add_option('--apk_package', |
help=('The package name used by the apk containing ' |
@@ -40,10 +40,17 @@ def AddInstallAPKOption(option_parser): |
'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.""" |
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): |
options.apk = os.path.join(constants.GetOutDirectory(), 'apks', |
options.apk) |
@@ -51,12 +58,17 @@ def ValidateInstallAPKOption(option_parser, options): |
def main(argv): |
parser = optparse.OptionParser() |
+ parser.set_usage("usage: %prog [options] target") |
AddInstallAPKOption(parser) |
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) |
- ValidateInstallAPKOption(parser, options) |
- if len(args) > 1: |
- raise Exception('Error: Unknown argument:', args[1:]) |
+ ValidateInstallAPKOption(parser, options, args) |
devices = android_commands.GetAttachedDevices() |
if not devices: |