Commit 9b5e9e3c authored by Eric Stevenson's avatar Eric Stevenson Committed by Commit Bot

Trichrome: Remove webview deps from trichrome_chrome_apk.

These were pulled in because trichrome uses monochrome
templates. Since Trichrome still shares the same native library
logic with monochrome it makes sense to continue using monochrome
templates, but using a variable |is_trichrome| to differentiate
trichrome from monochrome.

This CL removes Java deps, some Java resource deps, and webview's
locale pak files from TrichromeChrome.apk.

Validated CL changes by:
  * Building the 3 trichrome apks and their downstream variants
  * Installing/launching TrichromeChrome.apk
  * Manually inspecting the .build_config and "unzip -l" changes

      |     old (c)|     new (c)|    diff (c)|
 total|    24.8 MiB|    23.6 MiB|    -1.2 MiB|
   dex|     6.8 MiB|     6.4 MiB|  -392.1 KiB|
  arsc|     4.9 MiB|     4.8 MiB|  -101.8 KiB|
   xml|   344.9 KiB|   344.9 KiB|        -6 B|
   res|   912.3 KiB|   908.2 KiB|    -4.1 KiB|
native|   254.6 KiB|   254.6 KiB|        +0 B|
 asset|    11.1 MiB|    10.4 MiB|  -698.0 KiB|
  misc|   145.3 KiB|   142.4 KiB|    -2.9 KiB|

Bug: 932253
Change-Id: Iedb427aa5ec05ad3bc905ac61b23f615349d579e
Reviewed-on: https://chromium-review.googlesource.com/c/1481019
Commit-Queue: Eric Stevenson <estevenson@chromium.org>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#634385}
parent 69d311c4
......@@ -1068,12 +1068,17 @@ if (current_toolchain == default_toolchain) {
#
# Variables:
# is_monochrome: If true, generate Monochrome targets rather than Chrome.
# is_trichrome: Optionally generated Trichrome targets that use monochrome
# library targets but don't include webview resources.
# is_bundle: If true, generate resources for bundles rather than APK.
template("resource_packaging") {
_is_monochrome = invoker.is_monochrome
_is_bundle = invoker.is_bundle
_is_trichrome = defined(invoker.is_trichrome) && invoker.is_trichrome
if (_is_monochrome) {
if (_is_trichrome) {
_type = "trichrome_chrome"
} else if (_is_monochrome) {
_type = "monochrome"
} else {
_type = "chrome"
......@@ -1086,11 +1091,16 @@ if (current_toolchain == default_toolchain) {
_variant = "${_type}_${_output_type}"
if (enable_resource_whitelist_generation) {
if (_is_trichrome || _is_monochrome) {
_lib = "monochrome"
} else {
_lib = "chrome"
}
_resource_whitelist_target = "${_variant}_resource_whitelist"
_resource_whitelist_file =
"$target_gen_dir/${_variant}_resource_whitelist.txt"
if (_is_monochrome) {
if (_is_trichrome || _is_monochrome) {
_target_prefix = ""
} else {
_target_prefix = "lib"
......@@ -1100,8 +1110,8 @@ if (current_toolchain == default_toolchain) {
} else {
_suffix = ""
}
_lib_path = "/lib.unstripped/lib" + _type + _suffix + shlib_extension
_lib_target = _target_prefix + _type + _suffix
_lib_path = "/lib.unstripped/lib" + _lib + _suffix + shlib_extension
_lib_target = _target_prefix + _lib + _suffix
generate_resource_whitelist(_resource_whitelist_target) {
_fat_lib_toolchain = ""
......@@ -1260,6 +1270,11 @@ if (current_toolchain == default_toolchain) {
is_monochrome = true
is_bundle = false
}
resource_packaging("trichrome_chrome_apk_pak_assets") {
is_monochrome = false
is_trichrome = true
is_bundle = false
}
resource_packaging("chrome_bundle_pak_assets") {
is_monochrome = false
is_bundle = true
......@@ -1546,12 +1561,12 @@ android_library("monochrome_java") {
template("monochrome_public_apk_or_module_tmpl") {
_android_manifest =
"$target_gen_dir/manifest/${target_name}/AndroidManifest.xml"
_is_trichrome =
defined(invoker.use_trichrome_library) && invoker.use_trichrome_library
# Generate the manifest here in the template, to avoid a growing collection
# of manually-instantiated manifests.
jinja_template("${target_name}__android_manifest") {
_is_trichrome =
defined(invoker.use_trichrome_library) && invoker.use_trichrome_library
includes = [ "java/AndroidManifest.xml" ]
variables = chrome_public_jinja_variables
if (_is_trichrome) {
......@@ -1602,7 +1617,7 @@ template("monochrome_public_apk_or_module_tmpl") {
android_manifest = _android_manifest
android_manifest_dep = ":${target_name}__android_manifest"
if (public_android_sdk) {
if (public_android_sdk && !_is_trichrome) {
# Resource whitelist used when generating R.java files and causes
# only the webview subset of resources to be marked as non-final.
shared_resources_whitelist_target = "//android_webview:system_webview_apk"
......@@ -1613,16 +1628,18 @@ template("monochrome_public_apk_or_module_tmpl") {
}
deps = [
":monochrome_java",
"//android_webview:platform_service_bridge_upstream_implementation_java",
"//base:base_java",
"//chrome/android:app_hooks_java",
"//chrome/android:chrome_java",
]
if (!_is_trichrome) {
deps += [
":monochrome_java",
"//android_webview:platform_service_bridge_upstream_implementation_java",
]
}
add_unwind_tables_in_apk =
_add_unwind_tables_in_chrome_public_apk &&
(!defined(use_trichrome_library) || !use_trichrome_library)
_add_unwind_tables_in_chrome_public_apk && !_is_trichrome
version_name = chrome_version_name
}
......
......@@ -50,6 +50,10 @@ default_chrome_public_jinja_variables = [
# final APK or bundle.
# is_modern: If true, indicates this corresponds to a chrome_modern_XXX
# target that can only run on Android L-M.
# is_monochrome: Indicates that this target contains chrome and webview
# packaged together and can only run on Android N+.
# is_trichrome: Indicates this target relies on a trichrome static library
# target and can only run on Android P+.
# png_to_webp: Optional. If true, convert image resources to webp format.
# requires Android K+, since these were not supported by Android properly
# before 4.3.0.
......@@ -57,7 +61,6 @@ default_chrome_public_jinja_variables = [
# directly from the APK (and stored zipaligned and uncompressed). This
# requires either the Chromium linker, or Android M+.
# version_name: Application version name (e.g. "Developer Build").
# is_modern: Optional. true iff this is a chrome_modern derived build.
#
# Plus all other variables accepted by android_apk() or
# android_app_bundle_module(), depending on the target type.
......@@ -69,6 +72,9 @@ template("chrome_public_common_apk_or_module_tmpl") {
invoker.target_type == "android_app_bundle_module" ||
invoker.target_type == "instrumentation_test_apk",
"Invalid target_type definition, should be 'android_apk' or 'android_app_bundle_module'")
assert(!(defined(invoker.is_trichrome) && invoker.is_trichrome) ||
!(defined(invoker.is_monochrome) && invoker.is_monochrome),
"Cannot be both trichrome and monochrome!")
# Adds unwind table asset to the chrome apk for the given library target. This
# is not part of generic apk assets target since it depends on the main shared
......@@ -96,10 +102,8 @@ template("chrome_public_common_apk_or_module_tmpl") {
assert(_is_modern || !_is_modern) # Mark as used.
_is_monochrome = defined(invoker.is_monochrome) && invoker.is_monochrome
_use_trichrome_library =
defined(invoker.use_trichrome_library) && invoker.use_trichrome_library
assert(_use_trichrome_library || !_use_trichrome_library) # Mark as used.
_is_trichrome = defined(invoker.is_trichrome) && invoker.is_trichrome
assert(_is_trichrome || !_is_trichrome) # Mark as used.
if (defined(invoker.enable_multidex)) {
_enable_multidex = invoker.enable_multidex
......@@ -145,7 +149,7 @@ template("chrome_public_common_apk_or_module_tmpl") {
}
}
if (!_is_monochrome) {
if (!_is_monochrome && !_is_trichrome) {
deps += [
"//third_party/crashpad/crashpad/handler:crashpad_handler_named_as_so",
]
......@@ -237,7 +241,7 @@ template("chrome_public_common_apk_or_module_tmpl") {
}
if (!defined(version_code)) {
if (_use_trichrome_library) {
if (_is_trichrome) {
version_code = trichrome_version_code
} else if (_is_monochrome) {
version_code = monochrome_version_code
......@@ -252,7 +256,12 @@ template("chrome_public_common_apk_or_module_tmpl") {
}
# The equivalent of chrome_common_apk_or_module_tmpl for all builds of
# monochrome.
# monochrome and trichrome chrome.
# Variables:
# use_trichrome_library: Specifies that this target depends on a trichrome
# static library target to provide certain shared library deps, and that
# this target should not package webview deps.
template("monochrome_public_common_apk_or_module_tmpl") {
if (defined(invoker.enable_multidex)) {
_enable_multidex = invoker.enable_multidex
......@@ -260,11 +269,11 @@ template("monochrome_public_common_apk_or_module_tmpl") {
_enable_multidex = is_java_debug || multidex_in_release
}
chrome_public_common_apk_or_module_tmpl(target_name) {
is_monochrome = true
use_trichrome_library =
is_trichrome =
defined(invoker.use_trichrome_library) && invoker.use_trichrome_library
is_monochrome = !is_trichrome
if (!use_trichrome_library) {
if (!is_trichrome) {
if (invoker.target_type == "android_app_bundle_module") {
_suffix = bundle_library_suffix
} else {
......@@ -303,10 +312,15 @@ template("monochrome_public_common_apk_or_module_tmpl") {
}
}
alternative_android_sdk_dep = webview_framework_dep
app_as_shared_lib = true
if (is_monochrome) {
alternative_android_sdk_dep = webview_framework_dep
app_as_shared_lib = true
min_sdk_version = 24
}
if (is_trichrome) {
min_sdk_version = 28
}
use_chromium_linker = false
min_sdk_version = 24
# Resources config for blocklisting resource names from obfuscation
resources_config_path = "//android_webview/aapt2.config"
......@@ -335,18 +349,28 @@ template("monochrome_public_common_apk_or_module_tmpl") {
deps = []
}
deps += [
"//android_webview:monochrome_webview_assets",
"//android_webview/apk:webview_license_activity_java",
"//android_webview/glue",
"//chrome/android:chrome_public_non_pak_assets",
"//chrome/android/monochrome:monochrome_license_provider_java",
"//components/crash/android:handler_java",
]
_pak_prefix = "chrome"
if (is_monochrome) {
deps += [
"//android_webview:monochrome_webview_assets",
"//android_webview/apk:webview_license_activity_java",
"//android_webview/glue",
"//chrome/android:monochrome_java",
"//chrome/android/monochrome:monochrome_license_provider_java",
]
_pak_prefix = "monochrome"
} else if (is_trichrome) {
_pak_prefix = "trichrome_chrome"
}
if (invoker.target_type == "android_app_bundle_module") {
deps +=
[ "//chrome/android:monochrome_${bundle_pak_asset_type}_pak_assets" ]
deps += [
"//chrome/android:${_pak_prefix}_${bundle_pak_asset_type}_pak_assets",
]
} else {
deps += [ "//chrome/android:monochrome_apk_pak_assets" ]
deps += [ "//chrome/android:${_pak_prefix}_apk_pak_assets" ]
}
if (_enable_multidex && invoker.target_type == "android_apk" &&
......@@ -364,7 +388,9 @@ template("monochrome_public_common_apk_or_module_tmpl") {
if (!defined(proguard_configs)) {
proguard_configs = []
}
proguard_configs += [ "//android_webview/apk/java/proguard.flags" ]
if (is_monochrome) {
proguard_configs += [ "//android_webview/apk/java/proguard.flags" ]
}
png_to_webp = true
}
......
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