Commit 6f5c7ddb authored by Samuel Huang's avatar Samuel Huang Committed by Commit Bot

[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/+/2197339Reviewed-by: default avatarEgor Pasko <pasko@chromium.org>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Commit-Queue: Samuel Huang <huangs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#768784}
parent 926b5cca
...@@ -1276,6 +1276,7 @@ class _InstallCommand(_Command): ...@@ -1276,6 +1276,7 @@ class _InstallCommand(_Command):
description = 'Installs the APK or bundle to one or more devices.' description = 'Installs the APK or bundle to one or more devices.'
needs_apk_helper = True needs_apk_helper = True
supports_incremental = True supports_incremental = True
default_modules = []
def _RegisterExtraArgs(self, group): def _RegisterExtraArgs(self, group):
if self.is_bundle: if self.is_bundle:
...@@ -1283,24 +1284,33 @@ class _InstallCommand(_Command): ...@@ -1283,24 +1284,33 @@ class _InstallCommand(_Command):
'-m', '-m',
'--module', '--module',
action='append', action='append',
help='Module to install. Can be specified multiple times. ' + default=self.default_modules,
'One of them has to be \'{}\''.format(BASE_MODULE)) help='Module to install. Can be specified multiple times.')
group.add_argument( group.add_argument(
'-f', '-f',
'--fake', '--fake',
action='append', action='append',
default=[],
help='Fake bundle module install. Can be specified multiple times. ' help='Fake bundle module install. Can be specified multiple times. '
'Requires \'-m {0}\' to be given, and \'-f {0}\' is illegal.'.format( 'Requires \'-m {0}\' to be given, and \'-f {0}\' is illegal.'.format(
BASE_MODULE)) 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): def Run(self):
if self.additional_apk_helpers: if self.additional_apk_helpers:
for additional_apk_helper in self.additional_apk_helpers: for additional_apk_helper in self.additional_apk_helpers:
_InstallApk(self.devices, additional_apk_helper, None) _InstallApk(self.devices, additional_apk_helper, None)
if self.is_bundle: 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, _InstallBundle(self.devices, self.apk_helper, self.args.package_name,
self.args.command_line_flags_file, self.args.module, self.args.command_line_flags_file, modules, self.args.fake)
self.args.fake)
else: else:
_InstallApk(self.devices, self.apk_helper, self.install_dict) _InstallApk(self.devices, self.apk_helper, self.install_dict)
...@@ -1862,7 +1872,7 @@ def RunForBundle(output_directory, bundle_path, bundle_apks_path, ...@@ -1862,7 +1872,7 @@ def RunForBundle(output_directory, bundle_path, bundle_apks_path,
additional_apk_paths, aapt2_path, keystore_path, additional_apk_paths, aapt2_path, keystore_path,
keystore_password, keystore_alias, package_name, keystore_password, keystore_alias, package_name,
command_line_flags_file, proguard_mapping_path, target_cpu, 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. """Entry point for generated app bundle wrapper scripts.
Args: Args:
...@@ -1882,6 +1892,8 @@ def RunForBundle(output_directory, bundle_path, bundle_apks_path, ...@@ -1882,6 +1892,8 @@ def RunForBundle(output_directory, bundle_path, bundle_apks_path,
target_cpu: Chromium target CPU name, used by the 'gdb' command. 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_locales: List of Chromium locales that should be included in
system image APKs. system image APKs.
default_modules: List of modules that are installed in addition to those
given by the '-m' switch.
""" """
constants.SetOutputDirectory(output_directory) constants.SetOutputDirectory(output_directory)
devil_chromium.Initialize(output_directory=output_directory) devil_chromium.Initialize(output_directory=output_directory)
...@@ -1893,6 +1905,7 @@ def RunForBundle(output_directory, bundle_path, bundle_apks_path, ...@@ -1893,6 +1905,7 @@ def RunForBundle(output_directory, bundle_path, bundle_apks_path,
keystore_password=keystore_password, keystore_password=keystore_password,
keystore_alias=keystore_alias, keystore_alias=keystore_alias,
system_image_locales=system_image_locales) system_image_locales=system_image_locales)
_InstallCommand.default_modules = default_modules
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.set_defaults( parser.set_defaults(
......
...@@ -45,13 +45,13 @@ def main(): ...@@ -45,13 +45,13 @@ def main():
command_line_flags_file=${FLAGS_FILE}, command_line_flags_file=${FLAGS_FILE},
proguard_mapping_path=resolve(${MAPPING_PATH}), proguard_mapping_path=resolve(${MAPPING_PATH}),
target_cpu=${TARGET_CPU}, target_cpu=${TARGET_CPU},
system_image_locales=${SYSTEM_IMAGE_LOCALES}) system_image_locales=${SYSTEM_IMAGE_LOCALES},
default_modules=${DEFAULT_MODULES})
if __name__ == '__main__': if __name__ == '__main__':
sys.exit(main()) sys.exit(main())
""") """)
def main(args): def main(args):
args = build_utils.ExpandFileArgs(args) args = build_utils.ExpandFileArgs(args)
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
...@@ -74,6 +74,7 @@ def main(args): ...@@ -74,6 +74,7 @@ def main(args):
parser.add_argument('--proguard-mapping-path') parser.add_argument('--proguard-mapping-path')
parser.add_argument('--target-cpu') parser.add_argument('--target-cpu')
parser.add_argument('--system-image-locales') parser.add_argument('--system-image-locales')
parser.add_argument('--default-modules', nargs='*', default=[])
args = parser.parse_args(args) args = parser.parse_args(args)
def relativize(path): def relativize(path):
...@@ -114,6 +115,8 @@ def main(args): ...@@ -114,6 +115,8 @@ def main(args):
repr(args.target_cpu), repr(args.target_cpu),
'SYSTEM_IMAGE_LOCALES': 'SYSTEM_IMAGE_LOCALES':
repr(build_utils.ParseGnList(args.system_image_locales)), repr(build_utils.ParseGnList(args.system_image_locales)),
'DEFAULT_MODULES':
repr(args.default_modules),
} }
script.write(SCRIPT_TEMPLATE.substitute(script_dict)) script.write(SCRIPT_TEMPLATE.substitute(script_dict))
os.chmod(args.script_output_path, 0750) os.chmod(args.script_output_path, 0750)
......
...@@ -4443,6 +4443,10 @@ if (enable_java_templates) { ...@@ -4443,6 +4443,10 @@ if (enable_java_templates) {
# verify_native_libs_and_assets: (optional): If true, will verify the list # verify_native_libs_and_assets: (optional): If true, will verify the list
# of included native libraries and assets is consistent with an # of included native libraries and assets is consistent with an
# expectation file. # 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: # Example:
# android_app_bundle("chrome_public_bundle") { # android_app_bundle("chrome_public_bundle") {
# base_module_target = "//chrome/android:chrome_public_apk" # base_module_target = "//chrome/android:chrome_public_apk"
...@@ -4911,6 +4915,9 @@ if (enable_java_templates) { ...@@ -4911,6 +4915,9 @@ if (enable_java_templates) {
"--key-name", "--key-name",
_keystore_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)) { if (defined(invoker.system_image_locale_allowlist)) {
args += [ args += [
"--system-image-locales=${invoker.system_image_locale_allowlist}", "--system-image-locales=${invoker.system_image_locale_allowlist}",
......
...@@ -99,6 +99,11 @@ template("chrome_bundle") { ...@@ -99,6 +99,11 @@ template("chrome_bundle") {
system_image_locale_allowlist = android_apk_locales system_image_locale_allowlist = android_apk_locales
is_multi_abi = _is_multi_abi 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. # NOTE: Only sign bundle for official builds since this is very slow.
if (enable_chrome_android_internal && use_signing_keys && if (enable_chrome_android_internal && use_signing_keys &&
is_official_build) { is_official_build) {
......
...@@ -801,6 +801,12 @@ installing it as a true split. We therefore recommend that you always test both ...@@ -801,6 +801,12 @@ installing it as a true split. We therefore recommend that you always test both
install methods. 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 #### Deferred install
......
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