Commit 581a4f1f authored by Christopher Grant's avatar Christopher Grant Committed by Commit Bot

Android: Prepare Monochrome/Trichrome config for Monochrome32

This change should be a no-op in terms of build output, and has been
tested by diffing APK/AAB output (other than a correction in
Trichrome6432, a currently unused config).

The change prepares to support 32-bit only Monochrome and Trichrome
configs on 64-bit build configurations. The following is happening here:

- Support all four version number variations.

- Make any target that builds on both 32 and 64-bit explicit about it's
  configuration.  Eg. "monochrome" on 64-bit implies a 32-bit browser,
  with a 64-bit Webview companion library.

- Refactor logic for readability.

Bug: 1027573
Change-Id: Ia37a9011717e7c2269cc9b87e817e1e9fd6ef888
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1940355Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Commit-Queue: Christopher Grant <cjgrant@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721809}
parent 0be2084e
......@@ -49,6 +49,12 @@ if (public_android_sdk) {
deps = upstream_only_webview_deps
apk_name = "TrichromeWebView"
use_trichrome_library = true
if (android_64bit_target_cpu) {
is_64_bit_browser = false
include_64_bit_webview = true
}
uncompress_dex = true
if (trichrome_synchronized_proguard) {
static_library_provider = "//chrome/android:trichrome_library_apk"
......@@ -60,12 +66,14 @@ if (public_android_sdk) {
android_manifest = trichrome_webview_64_32_android_manifest
android_manifest_dep =
"//android_webview/nonembedded:trichrome_webview_64_32_manifest"
use_trichrome_library = true
is_64_bit_browser = true
include_32_bit_webview = true
min_sdk_version = 29
deps = upstream_only_webview_deps
apk_name = "TrichromeWebView6432"
use_trichrome_library = true
uncompress_dex = true
if (trichrome_synchronized_proguard) {
static_library_provider = "//chrome/android:trichrome_library_apk"
......
......@@ -141,13 +141,15 @@ jinja_template("trichrome_webview_manifest") {
]
}
jinja_template("trichrome_webview_64_32_manifest") {
input = "java/AndroidManifest.xml"
output = trichrome_webview_64_32_android_manifest
variables = trichrome_jinja_variables + [
"use32bitAbi=",
"trichrome_version=$trichrome_64_32_version_code",
"manifest_package=$system_webview_package_name",
"library=libmonochrome_64.so",
]
if (android_64bit_target_cpu) {
jinja_template("trichrome_webview_64_32_manifest") {
input = "java/AndroidManifest.xml"
output = trichrome_webview_64_32_android_manifest
variables = trichrome_jinja_variables + [
"use32bitAbi=",
"trichrome_version=$trichrome_64_32_version_code",
"manifest_package=$system_webview_package_name",
"library=libmonochrome_64.so",
]
}
}
......@@ -22,7 +22,13 @@ declare_args() {
template("system_webview_apk_tmpl") {
android_apk(target_name) {
forward_variables_from(invoker, "*")
forward_variables_from(invoker,
"*",
[
"is_64_bit_browser",
"include_32_bit_webview",
"include_64_bit_webview",
])
deps += [
"//android_webview:locale_pak_assets",
......@@ -51,18 +57,36 @@ template("system_webview_apk_tmpl") {
_use_trichrome_library =
defined(use_trichrome_library) && use_trichrome_library
_is_64_bit_browser = defined(is_64_bit_browser) && is_64_bit_browser
assert(_is_64_bit_browser || !_is_64_bit_browser) # Mark used.
# TODO(https://crbug.com/1027573): Remove this when all targets are explicit
# about their configuration.
if (android_64bit_target_cpu && _use_trichrome_library) {
_is_64_bit_browser =
defined(invoker.is_64_bit_browser) && invoker.is_64_bit_browser
if (_is_64_bit_browser) {
_include_32_bit_webview = !defined(invoker.include_32_bit_webview) ||
invoker.include_32_bit_webview
} else {
_include_64_bit_webview = !defined(invoker.include_64_bit_webview) ||
invoker.include_64_bit_webview
}
}
if (!_use_trichrome_library) {
deps += [ "//android_webview:monochrome_webview_assets" ]
}
# Flag whether additional deps and libs should be included for each ABI.
_include_primary_support = false
_include_secondary_support = false
if (!_use_trichrome_library) {
shared_libraries = [ "//android_webview:libwebviewchromium" ]
_include_primary_support = true
shared_resources = true
if (build_apk_secondary_abi && android_64bit_target_cpu) {
secondary_abi_shared_libraries = [ "//android_webview:libwebviewchromium($android_secondary_abi_toolchain)" ]
_include_secondary_support = true
}
} else {
uncompress_shared_libraries = true
......@@ -73,14 +97,15 @@ template("system_webview_apk_tmpl") {
if (android_64bit_target_cpu) {
if (_is_64_bit_browser) {
native_lib_placeholders = [ "libdummy.so" ]
if (build_apk_secondary_abi) {
if (_include_32_bit_webview && build_apk_secondary_abi) {
secondary_abi_shared_libraries = [ "//android_webview:monochrome_64($android_secondary_abi_toolchain)" ]
deps += [ "//android_webview:v8_snapshot_secondary_abi_assets" ]
_include_secondary_support = true
}
} else {
shared_libraries = [ "//android_webview:monochrome" ]
if (build_apk_secondary_abi) {
secondary_native_lib_placeholders = [ "libdummy.so" ]
if (_include_64_bit_webview) {
shared_libraries = [ "//android_webview:monochrome" ]
_include_primary_support = true
if (use_v8_context_snapshot) {
deps +=
[ "//tools/v8_context_snapshot:v8_context_snapshot_assets" ]
......@@ -88,30 +113,27 @@ template("system_webview_apk_tmpl") {
deps += [ "//v8:v8_external_startup_data_assets" ]
}
}
if (build_apk_secondary_abi) {
secondary_native_lib_placeholders = [ "libdummy.so" ]
}
}
} else if (_is_64_bit_browser) {
shared_libraries = [ "//android_webview:monochrome_64" ]
} else {
native_lib_placeholders = [ "libdummy.so" ]
}
}
if (!_use_trichrome_library ||
android_64bit_target_cpu != _is_64_bit_browser) {
if (_include_primary_support) {
deps += [
"//third_party/crashpad/crashpad/handler:crashpad_handler_trampoline",
]
loadable_modules = [ "$root_out_dir/libcrashpad_handler_trampoline.so" ]
}
if (build_apk_secondary_abi && android_64bit_target_cpu) {
if (!_use_trichrome_library || _is_64_bit_browser) {
_trampoline = "//third_party/crashpad/crashpad/handler:crashpad_handler_trampoline($android_secondary_abi_toolchain)"
deps += [ _trampoline ]
_secondary_out_dir = get_label_info(_trampoline, "root_out_dir")
secondary_abi_loadable_modules =
[ "$_secondary_out_dir/libcrashpad_handler_trampoline.so" ]
}
if (_include_secondary_support) {
_trampoline = "//third_party/crashpad/crashpad/handler:crashpad_handler_trampoline($android_secondary_abi_toolchain)"
deps += [ _trampoline ]
_secondary_out_dir = get_label_info(_trampoline, "root_out_dir")
secondary_abi_loadable_modules =
[ "$_secondary_out_dir/libcrashpad_handler_trampoline.so" ]
}
if (!_use_trichrome_library || android_64bit_target_cpu) {
......@@ -160,8 +182,20 @@ template("system_webview_apk_tmpl") {
if (!defined(version_code)) {
if (_use_trichrome_library) {
if (_is_64_bit_browser) {
version_code = trichrome_64_32_version_code
if (android_64bit_target_cpu) {
if (_is_64_bit_browser) {
if (_include_32_bit_webview) {
version_code = trichrome_64_32_version_code
} else {
version_code = trichrome_64_version_code
}
} else {
if (_include_64_bit_webview) {
version_code = trichrome_32_64_version_code
} else {
version_code = trichrome_32_version_code
}
}
} else {
version_code = trichrome_version_code
}
......
......@@ -44,15 +44,19 @@ if (is_mac) {
"monochrome_version_code = \"@MONOCHROME_VERSION_CODE@\" " +
"trichrome_version_code = \"@TRICHROME_VERSION_CODE@\" " +
"trichrome_64_32_version_code = \"@TRICHROME_64_32_VERSION_CODE@\" " +
"notouch_chrome_version_code = \"@NOTOUCH_CHROME_VERSION_CODE@\" " +
"webview_stable_version_code = \"@WEBVIEW_STABLE_VERSION_CODE@\" " +
"webview_beta_version_code = \"@WEBVIEW_BETA_VERSION_CODE@\" " +
"webview_dev_version_code = \"@WEBVIEW_DEV_VERSION_CODE@\" "
if (target_cpu == "arm64" || target_cpu == "x64") {
_version_dictionary_template +=
"monochrome_32_version_code = \"@MONOCHROME_32_VERSION_CODE@\" " +
"monochrome_32_64_version_code = \"@MONOCHROME_32_64_VERSION_CODE@\" " +
"monochrome_64_32_version_code = \"@MONOCHROME_64_32_VERSION_CODE@\" " +
"monochrome_64_version_code = \"@MONOCHROME_64_VERSION_CODE@\" " +
"trichrome_32_version_code = \"@TRICHROME_32_VERSION_CODE@\" " +
"trichrome_32_64_version_code = \"@TRICHROME_32_64_VERSION_CODE@\" " +
"trichrome_64_32_version_code = \"@TRICHROME_64_32_VERSION_CODE@\" " +
"trichrome_64_version_code = \"@TRICHROME_64_VERSION_CODE@\" "
}
......@@ -103,13 +107,16 @@ if (is_mac) {
[
"chrome_modern_version_code",
"chrome_version_code",
"monochrome_version_code",
"monochrome_32_version_code",
"monochrome_32_64_version_code",
"monochrome_64_32_version_code",
"monochrome_64_version_code",
"monochrome_version_code",
"notouch_chrome_version_code",
"trichrome_version_code",
"trichrome_32_version_code",
"trichrome_32_64_version_code",
"trichrome_64_32_version_code",
"trichrome_64_version_code",
"trichrome_version_code",
"webview_beta_version_code",
"webview_dev_version_code",
"webview_stable_version_code",
......@@ -123,7 +130,6 @@ if (is_mac) {
"ChromeModern: $chrome_modern_version_code",
"Monochrome: $monochrome_version_code",
"TrichromeChrome: $trichrome_version_code",
"MonochromeFP: $notouch_chrome_version_code",
"AndroidWebviewStable: $webview_stable_version_code",
"AndroidWebviewBeta: $webview_beta_version_code",
"AndroidWebviewDev: $webview_dev_version_code",
......@@ -131,8 +137,12 @@ if (is_mac) {
if (target_cpu == "arm64" || target_cpu == "x64") {
lines_to_write += [
"Monochrome32: $monochrome_32_version_code",
"Monochrome3264: $monochrome_32_64_version_code",
"Monochrome6432: $monochrome_64_32_version_code",
"Monochrome64: $monochrome_64_version_code",
"TrichromeChrome32: $trichrome_32_version_code",
"TrichromeChrome3264: $trichrome_32_64_version_code",
"TrichromeChrome6432: $trichrome_64_32_version_code",
"TrichromeChrome64: $trichrome_64_version_code",
]
......
This diff is collapsed.
......@@ -173,7 +173,9 @@ template("chrome_public_common_apk_or_module_tmpl") {
short_resource_paths = true
if (defined(shared_libraries) && shared_libraries != []) {
if ((defined(shared_libraries) && shared_libraries != []) ||
(defined(secondary_abi_shared_libraries) &&
secondary_abi_shared_libraries != [])) {
_native_lib_file =
rebase_path("$root_gen_dir/CHROME_VERSION.json", root_out_dir)
native_lib_version_arg = "@FileArg($_native_lib_file:full-quoted)"
......@@ -328,6 +330,20 @@ template("monochrome_public_common_apk_or_module_tmpl") {
"//chrome/android:chrome_public_non_pak_assets",
]
# TODO(https://crbug.com/1027573): Remove this when all targets are explicit
# about their configuration.
if (android_64bit_target_cpu) {
_is_64_bit_browser =
defined(invoker.is_64_bit_browser) && invoker.is_64_bit_browser
if (_is_64_bit_browser) {
_include_32_bit_webview = defined(invoker.include_32_bit_webview) &&
invoker.include_32_bit_webview
} else {
_include_64_bit_webview = !defined(invoker.include_64_bit_webview) ||
invoker.include_64_bit_webview
}
}
if (is_monochrome) {
product_config_java_packages = [
"org.chromium.chrome.browser",
......@@ -338,24 +354,36 @@ template("monochrome_public_common_apk_or_module_tmpl") {
product_config_java_packages += [ weblayer_product_config_java_package ]
}
# Flag whether additional deps and libs should be included for each ABI.
_include_primary_support = false
_include_secondary_support = false
if (android_64bit_target_cpu) {
# Build //android_webview:monochrome with the opposite bitness that
# Chrome runs in.
if (defined(invoker.is_64_bit_browser) && invoker.is_64_bit_browser) {
if (_is_64_bit_browser) {
_include_primary_support = true
shared_libraries = [ "//chrome/android:libmonochrome_64" ]
if (build_apk_secondary_abi && invoker.include_32_bit_webview) {
if (_include_32_bit_webview && build_apk_secondary_abi) {
secondary_abi_shared_libraries = [ "//android_webview:monochrome_64($android_secondary_abi_toolchain)" ]
_include_secondary_support = true
}
} else {
shared_libraries = [ "//android_webview:monochrome" ]
if (_include_64_bit_webview) {
shared_libraries = [ "//android_webview:monochrome" ]
_include_primary_support = true
}
if (build_apk_secondary_abi) {
secondary_abi_shared_libraries =
[ "//chrome/android:monochrome_secondary_abi_lib" ]
_include_secondary_support = true
}
}
} else {
shared_libraries = [ "//chrome/android:libmonochrome" ]
_include_primary_support = true
}
shared_library_for_unwind_asset = "monochrome"
_deps += [
......@@ -363,18 +391,21 @@ template("monochrome_public_common_apk_or_module_tmpl") {
"//android_webview/nonembedded:nonembedded_java",
"//android_webview/glue",
"//chrome/android:monochrome_java",
"//third_party/crashpad/crashpad/handler:crashpad_handler_trampoline",
]
loadable_modules += [ "$root_out_dir/libcrashpad_handler_trampoline.so" ]
if (webview_devui_show_icon) {
_deps +=
[ "//android_webview/nonembedded:devui_launcher_icon_resources" ]
}
if (android_64bit_target_cpu && build_apk_secondary_abi &&
(!defined(invoker.is_64_bit_browser) || !invoker.is_64_bit_browser ||
invoker.include_32_bit_webview)) {
if (_include_primary_support) {
_deps += [
"//third_party/crashpad/crashpad/handler:crashpad_handler_trampoline",
]
loadable_modules +=
[ "$root_out_dir/libcrashpad_handler_trampoline.so" ]
}
if (_include_secondary_support) {
_trampoline = "//third_party/crashpad/crashpad/handler:crashpad_handler_trampoline($android_secondary_abi_toolchain)"
_deps += [ _trampoline ]
_secondary_out_dir = get_label_info(_trampoline, "root_out_dir")
......@@ -391,12 +422,22 @@ template("monochrome_public_common_apk_or_module_tmpl") {
# bitnesses. This allows the "32-bit" and "64-bit" versions of Chrome to
# depend on their respective versions of the shared library APK even
# though they're functionally the same.
native_lib_placeholders = [ "libdummy.so" ]
if (android_64bit_target_cpu && build_apk_secondary_abi &&
(!defined(invoker.is_64_bit_browser) || !invoker.is_64_bit_browser ||
invoker.include_32_bit_webview)) {
secondary_native_lib_placeholders = [ "libdummy.so" ]
if (android_64bit_target_cpu) {
if (_is_64_bit_browser) {
native_lib_placeholders = [ "libdummy.so" ]
if (_include_32_bit_webview) {
secondary_native_lib_placeholders = [ "libdummy.so" ]
}
} else {
secondary_native_lib_placeholders = [ "libdummy.so" ]
if (_include_64_bit_webview) {
native_lib_placeholders = [ "libdummy.so" ]
}
}
} else {
native_lib_placeholders = [ "libdummy.so" ]
}
_pak_prefix = "trichrome_chrome"
}
......@@ -423,6 +464,7 @@ template("monochrome_public_common_apk_or_module_tmpl") {
"*",
[
"include_32_bit_webview",
"include_64_bit_webview",
"is_64_bit_browser",
])
......
......@@ -49,21 +49,34 @@ template("chrome_bundle") {
_package_id -= 1
}
# TODO(https://crbug.com/1027573): Remove this when all targets are explicit
# about their configuration.
if (defined(invoker.include_32_bit_webview)) {
not_needed(invoker, [ "include_32_bit_webview" ])
}
if (android_64bit_target_cpu) {
_is_64_bit_browser =
defined(invoker.is_64_bit_browser) && invoker.is_64_bit_browser
if (_is_64_bit_browser) {
_include_32_bit_webview = defined(invoker.include_32_bit_webview) &&
invoker.include_32_bit_webview
} else {
_include_64_bit_webview = !defined(invoker.include_64_bit_webview) ||
invoker.include_64_bit_webview
}
}
# Determine whether the bundle has native libraries for both the primary and
# the secondary ABI. This is the case if we package WebView with the
# complementary ABI of the browser.
_is_64_bit_browser =
defined(invoker.is_64_bit_browser) && invoker.is_64_bit_browser
_include_32_bit_webview =
defined(invoker.include_32_bit_webview) && invoker.include_32_bit_webview
_is_multi_abi = false
if (_is_64_bit_browser) {
_is_multi_abi = _include_32_bit_webview
if (android_64bit_target_cpu) {
if (_is_64_bit_browser) {
_is_multi_abi = _include_32_bit_webview
} else {
_is_multi_abi = _include_64_bit_webview
}
} else {
assert(!_include_32_bit_webview)
# WebView is included with 64bit ABI if |android_64bit_target_cpu| is true.
_is_multi_abi = android_64bit_target_cpu
_is_multi_abi = false
}
android_app_bundle(target_name) {
......
......@@ -40,6 +40,20 @@ trichrome_synchronized_proguard =
enable_trichrome_synchronized_proguard && !is_java_debug
template("trichrome_library_apk_tmpl") {
# TODO(https://crbug.com/1027573): Remove this when all targets are explicit
# about their configuration.
if (android_64bit_target_cpu) {
_is_64_bit_browser =
defined(invoker.is_64_bit_browser) && invoker.is_64_bit_browser
if (_is_64_bit_browser) {
_include_32_bit_webview = defined(invoker.include_32_bit_webview) &&
invoker.include_32_bit_webview
} else {
_include_64_bit_webview = !defined(invoker.include_64_bit_webview) ||
invoker.include_64_bit_webview
}
}
android_apk(target_name) {
forward_variables_from(invoker,
[
......@@ -80,8 +94,20 @@ template("trichrome_library_apk_tmpl") {
uncompress_dex = true
version_name = chrome_version_name
if (defined(invoker.is_64_bit_browser) && invoker.is_64_bit_browser) {
version_code = trichrome_64_32_version_code
if (android_64bit_target_cpu) {
if (_is_64_bit_browser) {
if (_include_32_bit_webview) {
version_code = trichrome_64_32_version_code
} else {
version_code = trichrome_64_version_code
}
} else {
if (_include_64_bit_webview) {
version_code = trichrome_32_64_version_code
} else {
version_code = trichrome_32_version_code
}
}
} else {
version_code = trichrome_version_code
}
......@@ -106,59 +132,66 @@ template("trichrome_library_apk_tmpl") {
native_lib_version_arg = "@FileArg($_native_lib_file:full-quoted)"
native_lib_version_rule = "//build/util:chrome_version_json"
# Flag whether additional deps and libs should be included for each ABI.
_include_primary_support = false
_include_secondary_support = false
if (android_64bit_target_cpu) {
# Include the actual browser-bitness libmonochrome library, dependencies
# (crashpad and linker), and an opposite-bitness placeholder library to
# ensure that the library is treated as multiarch and gets its Java code
# precompiled for both architectures.
if (defined(invoker.is_64_bit_browser) && invoker.is_64_bit_browser) {
if (_is_64_bit_browser) {
shared_libraries = [ "//chrome/android:libmonochrome_64" ]
deps += [
"//chrome/android:chrome_public_v8_assets",
"//third_party/crashpad/crashpad/handler:crashpad_handler_trampoline",
]
loadable_modules = [ "$root_out_dir/libcrashpad_handler_trampoline.so" ]
if (defined(invoker.include_32_bit_webview) &&
invoker.include_32_bit_webview && build_apk_secondary_abi) {
_include_primary_support = true
if (_include_32_bit_webview && build_apk_secondary_abi) {
# TODO(cjgrant): This dummy lib shouldn't be conditional on build_apk_secondary_abi.
secondary_native_lib_placeholders = [ "libdummy.so" ]
}
} else {
native_lib_placeholders = [ "libdummy.so" ]
if (_include_64_bit_webview) {
native_lib_placeholders = [ "libdummy.so" ]
}
if (build_apk_secondary_abi) {
secondary_abi_shared_libraries =
[ "//chrome/android:monochrome_secondary_abi_lib" ]
_trampoline = "//third_party/crashpad/crashpad/handler:crashpad_handler_trampoline($android_secondary_abi_toolchain)"
deps += [ _trampoline ]
_secondary_out_dir = get_label_info(_trampoline, "root_out_dir")
secondary_abi_loadable_modules =
[ "$_secondary_out_dir/libcrashpad_handler_trampoline.so" ]
if (chromium_linker_supported) {
deps += [ "//base/android/linker:chromium_android_linker($android_secondary_abi_toolchain)" ]
secondary_abi_loadable_modules +=
[ "$_secondary_out_dir/libchromium_android_linker.so" ]
}
_include_secondary_support = true
}
deps += [ "//android_webview:v8_snapshot_secondary_abi_assets" ]
}
} else {
if (defined(invoker.is_64_bit_browser) && invoker.is_64_bit_browser) {
native_lib_placeholders = [ "libdummy.so" ]
} else {
shared_libraries = [ "//chrome/android:libmonochrome" ]
deps += [
"//chrome/android:chrome_public_v8_assets",
"//third_party/crashpad/crashpad/handler:crashpad_handler_trampoline",
]
loadable_modules = [ "$root_out_dir/libcrashpad_handler_trampoline.so" ]
shared_libraries = [ "//chrome/android:libmonochrome" ]
_include_primary_support = true
}
if (chromium_linker_supported) {
deps += [ "//base/android/linker:chromium_android_linker" ]
loadable_modules += [ "$root_out_dir/libchromium_android_linker.so" ]
}
if (_include_primary_support) {
deps += [
"//chrome/android:chrome_public_v8_assets",
"//third_party/crashpad/crashpad/handler:crashpad_handler_trampoline",
]
loadable_modules = [ "$root_out_dir/libcrashpad_handler_trampoline.so" ]
if (chromium_linker_supported) {
deps += [ "//base/android/linker:chromium_android_linker" ]
loadable_modules += [ "$root_out_dir/libchromium_android_linker.so" ]
}
}
if (_include_secondary_support) {
_trampoline =
"//third_party/crashpad/crashpad/handler:" +
"crashpad_handler_trampoline($android_secondary_abi_toolchain)"
deps += [
"//android_webview:v8_snapshot_secondary_abi_assets",
_trampoline,
]
_secondary_out_dir = get_label_info(_trampoline, "root_out_dir")
secondary_abi_loadable_modules =
[ "$_secondary_out_dir/libcrashpad_handler_trampoline.so" ]
if (chromium_linker_supported) {
deps += [ "//base/android/linker:chromium_android_linker" +
"($android_secondary_abi_toolchain)" ]
secondary_abi_loadable_modules +=
[ "$_secondary_out_dir/libchromium_android_linker.so" ]
}
}
......
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