0

[Bundles] Make bundle wrapper test scripts install '-m dev_ui' by default.

Bundle wrapper test scripts calls such as
  /out/Debug/bin/monochrome_public_bundle install
  /out/Debug/bin/trichrome_chrome_google_bundle run

use the '-m' flag to include DFMs. In particular, the switch for the
DevUI DFM is '-m dev_ui' (and '-f dev_ui' for fake install).

However, most developers who use these test scripts don't care about
this detail. This CL makes the DevUI DFM installed by default when
these build scripts are used, to simplify development. The master list
|default_modules_for_testing| is in chrome_bundle_tmpl.gni, and
currently on has "dev_ui".

To make it still possible to test install flows of DevUI DFM, this CL
also adds the new flag '--no-module' to exclude non-base DFMs that are
installed by default (currently only {dev_ui}). Fake installs, e.g.,
'-f dev_ui', also excludes the default install.

Bug: 1081812, 987040
Change-Id: Icf87515382cc6d0b3d52fc3fa1914c7a4830b6cd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2197339
Reviewed-by: Egor Pasko <pasko@chromium.org>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Commit-Queue: Samuel Huang <huangs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#768784}
This commit is contained in:
Samuel Huang
2020-05-14 17:10:52 +00:00
committed by Commit Bot
parent 926b5cca60
commit 6f5c7ddb8a
5 changed files with 41 additions and 7 deletions

@ -1276,6 +1276,7 @@ class _InstallCommand(_Command):
description = 'Installs the APK or bundle to one or more devices.'
needs_apk_helper = True
supports_incremental = True
default_modules = []
def _RegisterExtraArgs(self, group):
if self.is_bundle:
@ -1283,24 +1284,33 @@ class _InstallCommand(_Command):
'-m',
'--module',
action='append',
help='Module to install. Can be specified multiple times. ' +
'One of them has to be \'{}\''.format(BASE_MODULE))
default=self.default_modules,
help='Module to install. Can be specified multiple times.')
group.add_argument(
'-f',
'--fake',
action='append',
default=[],
help='Fake bundle module install. Can be specified multiple times. '
'Requires \'-m {0}\' to be given, and \'-f {0}\' is illegal.'.format(
BASE_MODULE))
# Add even if |self.default_modules| is empty, for consistency.
group.add_argument('--no-module',
action='append',
choices=self.default_modules,
default=[],
help='Module to exclude from default install.')
def Run(self):
if self.additional_apk_helpers:
for additional_apk_helper in self.additional_apk_helpers:
_InstallApk(self.devices, additional_apk_helper, None)
if self.is_bundle:
modules = list(
set(self.args.module) - set(self.args.no_module) -
set(self.args.fake))
_InstallBundle(self.devices, self.apk_helper, self.args.package_name,
self.args.command_line_flags_file, self.args.module,
self.args.fake)
self.args.command_line_flags_file, modules, self.args.fake)
else:
_InstallApk(self.devices, self.apk_helper, self.install_dict)
@ -1862,7 +1872,7 @@ def RunForBundle(output_directory, bundle_path, bundle_apks_path,
additional_apk_paths, aapt2_path, keystore_path,
keystore_password, keystore_alias, package_name,
command_line_flags_file, proguard_mapping_path, target_cpu,
system_image_locales):
system_image_locales, default_modules):
"""Entry point for generated app bundle wrapper scripts.
Args:
@ -1882,6 +1892,8 @@ def RunForBundle(output_directory, bundle_path, bundle_apks_path,
target_cpu: Chromium target CPU name, used by the 'gdb' command.
system_image_locales: List of Chromium locales that should be included in
system image APKs.
default_modules: List of modules that are installed in addition to those
given by the '-m' switch.
"""
constants.SetOutputDirectory(output_directory)
devil_chromium.Initialize(output_directory=output_directory)
@ -1893,6 +1905,7 @@ def RunForBundle(output_directory, bundle_path, bundle_apks_path,
keystore_password=keystore_password,
keystore_alias=keystore_alias,
system_image_locales=system_image_locales)
_InstallCommand.default_modules = default_modules
parser = argparse.ArgumentParser()
parser.set_defaults(

@ -45,13 +45,13 @@ def main():
command_line_flags_file=${FLAGS_FILE},
proguard_mapping_path=resolve(${MAPPING_PATH}),
target_cpu=${TARGET_CPU},
system_image_locales=${SYSTEM_IMAGE_LOCALES})
system_image_locales=${SYSTEM_IMAGE_LOCALES},
default_modules=${DEFAULT_MODULES})
if __name__ == '__main__':
sys.exit(main())
""")
def main(args):
args = build_utils.ExpandFileArgs(args)
parser = argparse.ArgumentParser()
@ -74,6 +74,7 @@ def main(args):
parser.add_argument('--proguard-mapping-path')
parser.add_argument('--target-cpu')
parser.add_argument('--system-image-locales')
parser.add_argument('--default-modules', nargs='*', default=[])
args = parser.parse_args(args)
def relativize(path):
@ -114,6 +115,8 @@ def main(args):
repr(args.target_cpu),
'SYSTEM_IMAGE_LOCALES':
repr(build_utils.ParseGnList(args.system_image_locales)),
'DEFAULT_MODULES':
repr(args.default_modules),
}
script.write(SCRIPT_TEMPLATE.substitute(script_dict))
os.chmod(args.script_output_path, 0750)

@ -4443,6 +4443,10 @@ if (enable_java_templates) {
# verify_native_libs_and_assets: (optional): If true, will verify the list
# of included native libraries and assets is consistent with an
# expectation file.
#
# default_modules_for_testing: (optional): A list of DFM that the wrapper
# script should install. This is for local testing only, and does not
# affect the actual DFM in production.
# Example:
# android_app_bundle("chrome_public_bundle") {
# base_module_target = "//chrome/android:chrome_public_apk"
@ -4911,6 +4915,9 @@ if (enable_java_templates) {
"--key-name",
_keystore_name,
]
if (defined(invoker.default_modules_for_testing)) {
args += [ "--default-modules" ] + invoker.default_modules_for_testing
}
if (defined(invoker.system_image_locale_allowlist)) {
args += [
"--system-image-locales=${invoker.system_image_locale_allowlist}",

@ -99,6 +99,11 @@ template("chrome_bundle") {
system_image_locale_allowlist = android_apk_locales
is_multi_abi = _is_multi_abi
# List of DFMs that are installed by default by wrapper scripts, to make
# testing easier. This removes the need to manually specify, e.g.,
# "-m dev_ui" on every install or run.
default_modules_for_testing = [ "dev_ui" ]
# NOTE: Only sign bundle for official builds since this is very slow.
if (enable_chrome_android_internal && use_signing_keys &&
is_official_build) {

@ -801,6 +801,12 @@ installing it as a true split. We therefore recommend that you always test both
install methods.
***
*** note
To simplify development, the DevUI DFM (dev_ui) is installed by default, i.e.,
`-m dev_ui` is implied by default. This is overridden by:
* `--no-module dev_ui`, to test error from missing DevUI,
* `-f dev_ui`, for fake module install.
***
#### Deferred install