Commit e3f8f96d authored by David 'Digit' Turner's avatar David 'Digit' Turner Committed by Commit Bot

android: Allow generation of system and sytem_compressed bundles.

Each bundle wrapper script now supports the new --build-mode=MODE
parameter for its 'build-bundle-apks' command. This is used to
specify the type of APKs archive to generate.

This allows generating APKS containing a system image APK, or
even a compressed systetm image APK and its installation stub.

Note that '--universal' is no longer supported, use
'--build-mode=universal' instead for the same result.

+ Add the build mode to the MD5 input strings, to ensure that
  the bundle is properly rebuilt if the mode changes. This didn't
  work previously when switching between default and universal
  builds.

BUG=NONE
R=agrieve@chromium.org, tiborg@chromium.org, benmason@chromium.org

Change-Id: Iddc6925e01ca849ffde6f6b43a902d9fd29401d2
Reviewed-on: https://chromium-review.googlesource.com/c/1489233
Commit-Queue: David Turner <digit@chromium.org>
Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#635546}
parent 210b6994
......@@ -100,7 +100,7 @@ def _GenerateBundleApks(info,
output_path,
minimal=False,
minimal_sdk_version=None,
universal=False):
mode=None):
"""Generate an .apks archive from a bundle on demand.
Args:
......@@ -108,8 +108,7 @@ def _GenerateBundleApks(info,
output_path: Path of output .apks archive.
minimal: Create the minimal set of apks possible (english-only).
minimal_sdk_version: When minimal=True, use this sdkVersion.
universal: Whether to create a single APK that contains the contents of all
modules.
mode: Build mode, either None, or one of app_bundle_utils.BUILD_APKS_MODES.
"""
app_bundle_utils.GenerateBundleApks(
info.bundle_path,
......@@ -118,7 +117,7 @@ def _GenerateBundleApks(info,
info.keystore_path,
info.keystore_password,
info.keystore_alias,
universal=universal,
mode=mode,
minimal=minimal,
minimal_sdk_version=minimal_sdk_version)
......@@ -1454,10 +1453,14 @@ class _BuildBundleApks(_Command):
group.add_argument(
'--sdk-version',
help='Implies --minimal. The sdkVersion to build the .apks for.')
group.add_argument('--universal', action='store_true',
help='Build .apks archive containing single APK with '
'contents of all splits. NOTE: Won\'t add modules '
'with <dist:fusing dist:include="false"/> flag.')
group.add_argument(
'--build-mode',
choices=app_bundle_utils.BUILD_APKS_MODES,
help='Specify which type of APKs archive to build. "default" '
'generates regular splits, "universal" generates an archive with a '
'single universal APK, "system" generates an archive with a system '
'image APK, while "system_compressed" generates a compressed system '
'APK, with an additional stub APK for the system image.')
def Run(self):
_GenerateBundleApks(
......@@ -1465,7 +1468,7 @@ class _BuildBundleApks(_Command):
self.args.output_apks,
minimal=self.args.sdk_version is not None or self.args.minimal,
minimal_sdk_version=self.args.sdk_version,
universal=self.args.universal)
mode=self.args.build_mode)
# Shared commands for regular APKs and app bundles.
......
......@@ -16,6 +16,8 @@ from util import build_utils
from util import md5_check
import bundletool
# List of valid modes for GenerateBundleApks()
BUILD_APKS_MODES = ('default', 'universal', 'system', 'system_compressed')
_ALL_ABIS = ['armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64']
......@@ -48,7 +50,7 @@ def GenerateBundleApks(bundle_path,
keystore_path,
keystore_password,
keystore_alias,
universal=False,
mode=None,
minimal=False,
minimal_sdk_version=None,
check_for_noop=True):
......@@ -62,8 +64,7 @@ def GenerateBundleApks(bundle_path,
keystore_path: Path to keystore.
keystore_password: Keystore password, as a string.
keystore_alias: Keystore signing key alias.
universal: Whether to create a single APK that contains the contents of all
modules.
mode: Build mode, which must be either None or one of BUILD_APKS_MODES.
minimal: Create the minimal set of apks possible (english-only).
minimal_sdk_version: When minimal=True, use this sdkVersion.
check_for_noop: Use md5_check to short-circuit when inputs have not changed.
......@@ -90,8 +91,11 @@ def GenerateBundleApks(bundle_path,
json.dump(device_spec, spec_file)
spec_file.flush()
cmd_args += ['--device-spec=' + spec_file.name]
if universal:
cmd_args += ['--mode=universal']
if mode is not None:
if mode not in BUILD_APKS_MODES:
raise Exception('Invalid mode parameter %s (should be in %s)' %
(mode, BUILD_APKS_MODES))
cmd_args += ['--mode=' + mode]
bundletool.RunBundleTool(cmd_args)
if check_for_noop:
......@@ -109,6 +113,9 @@ def GenerateBundleApks(bundle_path,
bundletool.BUNDLETOOL_VERSION,
device_spec,
]
if mode is not None:
input_strings.append(mode)
md5_check.CallAndRecordIfStale(
rebuild,
input_paths=input_paths,
......
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