deploy_chrome: Default to deploying everything we can find.

The default mode is now to deploy everything we know of that exists.
This mode suits the development workflow better, since developers don't
need to specify extra flags.

BUG=None
TEST=unit tests.  Ran with --gs-path and --staging-only.

Change-Id: I8d54daed6c084aee4822d2ee19a4d443f48bee87
Reviewed-on: https://gerrit.chromium.org/gerrit/42561
Reviewed-by: David James <davidjames@chromium.org>
Commit-Queue: Ryan Cui <rcui@chromium.org>
Tested-by: Ryan Cui <rcui@chromium.org>
diff --git a/scripts/deploy_chrome.py b/scripts/deploy_chrome.py
index 50191c4..cedec2a 100644
--- a/scripts/deploy_chrome.py
+++ b/scripts/deploy_chrome.py
@@ -230,10 +230,15 @@
 
   group = optparse.OptionGroup(parser, 'Advanced Options')
   group.add_option('-l', '--local-pkg-path', type='path',
-                    help='path to local chrome prebuilt package to deploy.')
-  group.add_option('--staging-flags', default={}, type='gyp_defines',
-                    help=('Extra flags to control staging.  Valid flags '
-                          'are - %s' % ', '.join(chrome_util.STAGING_FLAGS)))
+                    help='Path to local chrome prebuilt package to deploy.')
+  group.add_option('--strict', action='store_true', default=False,
+                    help='Stage artifacts based on the GYP_DEFINES environment '
+                         'variable and --staging-flags, if set.')
+  group.add_option('--staging-flags', default=None, type='gyp_defines',
+                    help=('Requires --strict to be set.  Extra flags to '
+                          'control staging.  Valid flags are - %s'
+                          % ', '.join(chrome_util.STAGING_FLAGS)))
+
   parser.add_option_group(group)
 
   # Path of an empty directory to stage chrome artifacts to.  Defaults to a
@@ -247,7 +252,7 @@
   # GYP_DEFINES that Chrome was built with.  Influences which files are staged
   # when --build-dir is set.  Defaults to reading from the GYP_DEFINES
   # enviroment variable.
-  parser.add_option('--gyp-defines', default={}, type='gyp_defines',
+  parser.add_option('--gyp-defines', default=None, type='gyp_defines',
                     help=optparse.SUPPRESS_HELP)
   return parser
 
@@ -259,7 +264,7 @@
 
   if not any([options.gs_path, options.local_pkg_path, options.build_dir]):
     parser.error('Need to specify either --gs-path, --local-pkg-path, or '
-                 '--build_dir')
+                 '--build-dir')
   if options.build_dir and any([options.gs_path, options.local_pkg_path]):
     parser.error('Cannot specify both --build_dir and '
                  '--gs-path/--local-pkg-patch')
@@ -267,6 +272,11 @@
     parser.error('Cannot specify both --gs-path and --local-pkg-path')
   if not (options.staging_only or options.to):
     parser.error('Need to specify --to')
+  if (options.strict or options.staging_flags) and not options.build_dir:
+    parser.error('--strict and --staging-flags require --build-dir to be '
+                 'set.')
+  if options.staging_flags and not options.strict:
+    parser.error('--strict requires --staging-flags to be set.')
 
   return options, args
 
@@ -280,15 +290,15 @@
   if options.local_pkg_path and not os.path.isfile(options.local_pkg_path):
     cros_build_lib.Die('%s is not a file.', options.local_pkg_path)
 
-  if options.build_dir and not options.gyp_defines:
+  if options.build_dir and options.strict and not options.gyp_defines:
     gyp_env = os.getenv('GYP_DEFINES', None)
     if gyp_env is not None:
       options.gyp_defines = chrome_util.ProcessGypDefines(gyp_env)
       logging.info('GYP_DEFINES taken from environment: %s',
                    options.gyp_defines)
     else:
-      cros_build_lib.Die('When --build-dir is set, the GYP_DEFINES environment '
-                         'variable must be set.')
+      cros_build_lib.Die('When --build-dir and --strict is set, the '
+                         'GYP_DEFINES environment variable must be set.')
 
 
 def _FetchChromePackage(cache_dir, tempdir, gs_path):