Commit aaf0add8 authored by Christopher Grant's avatar Christopher Grant Committed by Commit Bot

Reland "Introduce bundle-specific native libraries"

This is a reland of 50ab16b8

Original change's description:
> Introduce bundle-specific native libraries
> 
> This will allow native code to be stripped out of the main library
> when it moves to a Dynamic Feature Module.  For now, the libraries will
> be identical.
> 
> BUG=874584
> 
> Change-Id: I8a54e6402a3686939dd14b509c614da99b0ff913
> Reviewed-on: https://chromium-review.googlesource.com/c/1332248
> Reviewed-by: Yaron Friedman <yfriedman@chromium.org>
> Reviewed-by: David Turner <digit@chromium.org>
> Reviewed-by: Tibor Goldschwendt <tiborg@chromium.org>
> Commit-Queue: Christopher Grant <cjgrant@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#608519}

Bug: 874584
Change-Id: I197543b47e1613f93164ebd6f9a4c9d84743e284
Reviewed-on: https://chromium-review.googlesource.com/c/1344875
Commit-Queue: Christopher Grant <cjgrant@chromium.org>
Reviewed-by: default avataragrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610456}
parent f72ca071
...@@ -8,9 +8,9 @@ import("//build/config/android/linker_version_script.gni") ...@@ -8,9 +8,9 @@ import("//build/config/android/linker_version_script.gni")
import("//build/config/android/rules.gni") import("//build/config/android/rules.gni")
import("//build/util/process_version.gni") import("//build/util/process_version.gni")
import("//chrome/android/chrome_public_apk_tmpl.gni") import("//chrome/android/chrome_public_apk_tmpl.gni")
import("//chrome/android/feed/feed_java_sources.gni")
import("//chrome/android/monochrome_android_manifest_jinja_variables.gni") import("//chrome/android/monochrome_android_manifest_jinja_variables.gni")
import("//chrome/chrome_paks.gni") import("//chrome/chrome_paks.gni")
import("//chrome/android/feed/feed_java_sources.gni")
import("//chrome/common/features.gni") import("//chrome/common/features.gni")
import("//chrome/process_version_rc_template.gni") # For branding_file_path. import("//chrome/process_version_rc_template.gni") # For branding_file_path.
import("//device/vr/buildflags/buildflags.gni") import("//device/vr/buildflags/buildflags.gni")
...@@ -1078,14 +1078,27 @@ template("chrome_shared_library") { ...@@ -1078,14 +1078,27 @@ template("chrome_shared_library") {
} }
} }
chrome_shared_library("libchrome") { # This template creates a native library for Chrome's APK or bundle.
sources = [ template("libchrome_apk_or_bundle_tmpl") {
"../browser/android/chrome_entry_point.cc", chrome_shared_library(target_name) {
chrome_jni_registration_header, forward_variables_from(invoker, "*")
] sources = [
deps = [ "../browser/android/chrome_entry_point.cc",
":chrome_jni_registration($default_toolchain)", chrome_jni_registration_header,
] ]
deps = [
":chrome_jni_registration($default_toolchain)",
]
}
}
# Chrome APK's native library.
libchrome_apk_or_bundle_tmpl("libchrome") {
}
# Chrome bundle's base module native library. This is currently the same as the
# APK version, but will diverge when code moves into feature modules.
libchrome_apk_or_bundle_tmpl("libchrome_base") {
} }
chrome_shared_library("libchromefortest") { chrome_shared_library("libchromefortest") {
...@@ -1135,22 +1148,20 @@ if (current_toolchain == default_toolchain) { ...@@ -1135,22 +1148,20 @@ if (current_toolchain == default_toolchain) {
# is_monochrome: If true, generate Monochrome targets rather than Chrome. # is_monochrome: If true, generate Monochrome targets rather than Chrome.
# is_bundle: If true, generate resources for bundles rather than APK. # is_bundle: If true, generate resources for bundles rather than APK.
template("resource_packaging") { template("resource_packaging") {
not_needed([ "target_name" ])
_is_monochrome = invoker.is_monochrome _is_monochrome = invoker.is_monochrome
_is_bundle = invoker.is_bundle _is_bundle = invoker.is_bundle
if (_is_monochrome) { if (_is_monochrome) {
_prefix = "monochrome" _type = "monochrome"
} else { } else {
_prefix = "chrome" _type = "chrome"
} }
if (_is_bundle) { if (_is_bundle) {
_output_type = "bundle" _output_type = "bundle"
} else { } else {
_output_type = "apk" _output_type = "apk"
} }
_variant = "${_prefix}_${_output_type}" _variant = "${_type}_${_output_type}"
if (enable_resource_whitelist_generation) { if (enable_resource_whitelist_generation) {
_resource_whitelist_target = "${_variant}_resource_whitelist" _resource_whitelist_target = "${_variant}_resource_whitelist"
...@@ -1158,10 +1169,17 @@ if (current_toolchain == default_toolchain) { ...@@ -1158,10 +1169,17 @@ if (current_toolchain == default_toolchain) {
"$target_gen_dir/${_variant}_resource_whitelist.txt" "$target_gen_dir/${_variant}_resource_whitelist.txt"
if (_is_monochrome) { if (_is_monochrome) {
_target = "monochrome" _target_prefix = ""
} else {
_target_prefix = "lib"
}
if (_is_bundle) {
_suffix = "_base"
} else { } else {
_target = "libchrome" _suffix = ""
} }
_lib_path = "/lib.unstripped/lib" + _type + _suffix + shlib_extension
_lib_target = _target_prefix + _type + _suffix
generate_resource_whitelist(_resource_whitelist_target) { generate_resource_whitelist(_resource_whitelist_target) {
_fat_lib_toolchain = "" _fat_lib_toolchain = ""
...@@ -1175,11 +1193,10 @@ if (current_toolchain == default_toolchain) { ...@@ -1175,11 +1193,10 @@ if (current_toolchain == default_toolchain) {
} }
} }
deps = [ deps = [
":${_target}($_fat_lib_toolchain)", ":${_lib_target}($_fat_lib_toolchain)",
] ]
input = get_label_info(deps[0], "root_out_dir") + input = get_label_info(deps[0], "root_out_dir") + _lib_path
"/lib.unstripped/lib${_prefix}$shlib_extension"
output = _resource_whitelist_file output = _resource_whitelist_file
} }
...@@ -1191,10 +1208,13 @@ if (current_toolchain == default_toolchain) { ...@@ -1191,10 +1208,13 @@ if (current_toolchain == default_toolchain) {
_locale_whitelist_target = "${_variant}_locale_whitelist" _locale_whitelist_target = "${_variant}_locale_whitelist"
_locale_whitelist_file = _locale_whitelist_file =
"$target_gen_dir/${_variant}_locale_whitelist.txt" "$target_gen_dir/${_variant}_locale_whitelist.txt"
_system_webview_locale_resource_id_list = _system_webview_locale_whitelist_target =
"$target_gen_dir/system_webview_locale_resource_id_list.txt" "${_variant}_system_webview_locale_resource_whitelist"
_system_webview_locale_whitelist_file =
"$target_gen_dir/" +
"${_variant}_system_webview_locale_resource_id_list.txt"
action("system_webview_locale_resource_id_list") { action(_system_webview_locale_whitelist_target) {
script = "//tools/grit/pak_util.py" script = "//tools/grit/pak_util.py"
_system_webview_en_US_locale_pak = _system_webview_en_US_locale_pak =
...@@ -1205,7 +1225,7 @@ if (current_toolchain == default_toolchain) { ...@@ -1205,7 +1225,7 @@ if (current_toolchain == default_toolchain) {
] ]
outputs = [ outputs = [
_system_webview_locale_resource_id_list, _system_webview_locale_whitelist_file,
] ]
deps = [ deps = [
...@@ -1215,8 +1235,7 @@ if (current_toolchain == default_toolchain) { ...@@ -1215,8 +1235,7 @@ if (current_toolchain == default_toolchain) {
args = [ args = [
"list-id", "list-id",
"--output", "--output",
rebase_path(_system_webview_locale_resource_id_list, rebase_path(_system_webview_locale_whitelist_file, root_build_dir),
root_build_dir),
rebase_path(_system_webview_en_US_locale_pak, root_build_dir), rebase_path(_system_webview_en_US_locale_pak, root_build_dir),
] ]
} }
...@@ -1226,7 +1245,7 @@ if (current_toolchain == default_toolchain) { ...@@ -1226,7 +1245,7 @@ if (current_toolchain == default_toolchain) {
inputs = [ inputs = [
_resource_whitelist_file, _resource_whitelist_file,
_system_webview_locale_resource_id_list, _system_webview_locale_whitelist_file,
] ]
outputs = [ outputs = [
...@@ -1234,8 +1253,8 @@ if (current_toolchain == default_toolchain) { ...@@ -1234,8 +1253,8 @@ if (current_toolchain == default_toolchain) {
] ]
deps = [ deps = [
":${_resource_whitelist_target}", ":$_resource_whitelist_target",
":system_webview_locale_resource_id_list", ":$_system_webview_locale_whitelist_target",
"//android_webview:system_webview_pak_whitelist", "//android_webview:system_webview_pak_whitelist",
] ]
...@@ -1243,8 +1262,7 @@ if (current_toolchain == default_toolchain) { ...@@ -1243,8 +1262,7 @@ if (current_toolchain == default_toolchain) {
"--input", "--input",
rebase_path(_resource_whitelist_file, root_build_dir), rebase_path(_resource_whitelist_file, root_build_dir),
"--filter", "--filter",
rebase_path(_system_webview_locale_resource_id_list, rebase_path(_system_webview_locale_whitelist_file, root_build_dir),
root_build_dir),
"--output", "--output",
rebase_path(_locale_whitelist_file, root_build_dir), rebase_path(_locale_whitelist_file, root_build_dir),
] ]
...@@ -1253,7 +1271,7 @@ if (current_toolchain == default_toolchain) { ...@@ -1253,7 +1271,7 @@ if (current_toolchain == default_toolchain) {
} }
chrome_paks("${_variant}_paks") { chrome_paks("${_variant}_paks") {
output_dir = "$target_gen_dir/$target_name" output_dir = "$target_gen_dir/${_variant}_paks"
deps = [] deps = []
if (_is_monochrome) { if (_is_monochrome) {
...@@ -1267,7 +1285,7 @@ if (current_toolchain == default_toolchain) { ...@@ -1267,7 +1285,7 @@ if (current_toolchain == default_toolchain) {
deps += [ ":${_resource_whitelist_target}" ] deps += [ ":${_resource_whitelist_target}" ]
if (_is_monochrome) { if (_is_monochrome) {
locale_whitelist = _locale_whitelist_file locale_whitelist = _locale_whitelist_file
deps += [ ":${_variant}_locale_whitelist" ] deps += [ ":$_locale_whitelist_target" ]
} }
} }
} }
...@@ -1290,7 +1308,8 @@ if (current_toolchain == default_toolchain) { ...@@ -1290,7 +1308,8 @@ if (current_toolchain == default_toolchain) {
} }
# This target explicitly includes locale paks via deps. # This target explicitly includes locale paks via deps.
android_assets("${_variant}_pak_assets") { android_assets(target_name) {
assert("${_variant}_pak_assets" == target_name)
sources = [ sources = [
"$target_gen_dir/${_variant}_paks/chrome_100_percent.pak", "$target_gen_dir/${_variant}_paks/chrome_100_percent.pak",
"$target_gen_dir/${_variant}_paks/resources.pak", "$target_gen_dir/${_variant}_paks/resources.pak",
...@@ -1307,14 +1326,24 @@ if (current_toolchain == default_toolchain) { ...@@ -1307,14 +1326,24 @@ if (current_toolchain == default_toolchain) {
} }
} }
resource_packaging("") { # Resource packaging varies with Monochrome and bundles because the pak
# resource whitelist is derived from the native library.
resource_packaging("chrome_apk_pak_assets") {
is_monochrome = false is_monochrome = false
is_bundle = false is_bundle = false
} }
resource_packaging("") { resource_packaging("monochrome_apk_pak_assets") {
is_monochrome = true is_monochrome = true
is_bundle = false is_bundle = false
} }
resource_packaging("chrome_bundle_pak_assets") {
is_monochrome = false
is_bundle = true
}
resource_packaging("monochrome_bundle_pak_assets") {
is_monochrome = true
is_bundle = true
}
# TODO(cjgrant): Remove this temporary alias after downstream renaming lands. # TODO(cjgrant): Remove this temporary alias after downstream renaming lands.
java_group("chrome_public_pak_assets") { java_group("chrome_public_pak_assets") {
...@@ -1332,17 +1361,29 @@ if (current_toolchain == default_toolchain) { ...@@ -1332,17 +1361,29 @@ if (current_toolchain == default_toolchain) {
# for 64-bit APK. # for 64-bit APK.
if (!android_64bit_target_cpu || if (!android_64bit_target_cpu ||
current_toolchain == android_secondary_abi_toolchain) { current_toolchain == android_secondary_abi_toolchain) {
chrome_common_shared_library("monochrome") { # Monochrome equivalent of Chrome's APK or bundle library template.
sources = [ template("libmonochrome_apk_or_bundle_tmpl") {
"../browser/android/monochrome_entry_point.cc", chrome_common_shared_library(target_name) {
] forward_variables_from(invoker, "*")
deps = [ sources = [
"//android_webview:common", "../browser/android/monochrome_entry_point.cc",
] ]
deps = [
"//android_webview:common",
]
export_java_symbols = true export_java_symbols = true
enable_compressed_relocations = use_lld enable_compressed_relocations = use_lld
use_gnu_hash_style = true use_gnu_hash_style = true
}
}
# Monochrome APK native library.
libmonochrome_apk_or_bundle_tmpl("monochrome") {
}
# Monochrome bundle native library.
libmonochrome_apk_or_bundle_tmpl("monochrome_base") {
} }
} else { } else {
group("monochrome_secondary_abi_lib") { group("monochrome_secondary_abi_lib") {
...@@ -1350,6 +1391,11 @@ if (!android_64bit_target_cpu || ...@@ -1350,6 +1391,11 @@ if (!android_64bit_target_cpu ||
":monochrome($android_secondary_abi_toolchain)", ":monochrome($android_secondary_abi_toolchain)",
] ]
} }
group("monochrome_base_secondary_abi_lib") {
public_deps = [
":monochrome_base($android_secondary_abi_toolchain)",
]
}
} }
# Java libraries that go into each public chrome APK and base module. The chrome # Java libraries that go into each public chrome APK and base module. The chrome
...@@ -1382,7 +1428,6 @@ _chrome_public_shared_deps = [ ...@@ -1382,7 +1428,6 @@ _chrome_public_shared_deps = [
":chrome_public_apk_resources", ":chrome_public_apk_resources",
":chrome_public_base_module_java", ":chrome_public_base_module_java",
":chrome_public_non_pak_assets", ":chrome_public_non_pak_assets",
":chrome_apk_pak_assets",
] ]
generate_jni("test_support_jni_headers") { generate_jni("test_support_jni_headers") {
...@@ -1466,10 +1511,18 @@ template("chrome_public_apk_or_module_tmpl") { ...@@ -1466,10 +1511,18 @@ template("chrome_public_apk_or_module_tmpl") {
android_manifest_dep = ":chrome_public_android_manifest" android_manifest_dep = ":chrome_public_android_manifest"
} }
shared_libraries = [ ":libchrome" ] if (invoker.target_type == "android_app_bundle_module") {
deps += [ ":chrome_bundle_pak_assets" ]
_suffix = "_base"
} else {
deps += [ ":chrome_apk_pak_assets" ]
_suffix = ""
}
shared_libraries = [ ":libchrome${_suffix}" ]
add_unwind_tables_in_apk = _add_unwind_tables_in_chrome_public_apk add_unwind_tables_in_apk = _add_unwind_tables_in_chrome_public_apk
if (_add_unwind_tables_in_chrome_public_apk) { if (_add_unwind_tables_in_chrome_public_apk) {
shared_library_for_unwind_asset = "chrome" shared_library_for_unwind_asset = "chrome${_suffix}"
} }
# Android supports webp transparent resources properly since API level 18, # Android supports webp transparent resources properly since API level 18,
...@@ -1722,6 +1775,7 @@ template("chrome_test_apk_tmpl") { ...@@ -1722,6 +1775,7 @@ template("chrome_test_apk_tmpl") {
} }
deps = _chrome_public_shared_deps + invoker.deps + [ deps = _chrome_public_shared_deps + invoker.deps + [
":chrome_apk_pak_assets",
":chrome_public_base_module_java_for_test", ":chrome_public_base_module_java_for_test",
"//third_party/android_support_test_runner:runner_java", "//third_party/android_support_test_runner:runner_java",
"//third_party/android_tools:android_test_base_java", "//third_party/android_tools:android_test_base_java",
......
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
import("//base/android/linker/config.gni") import("//base/android/linker/config.gni")
import("//base/android/proguard/proguard.gni") import("//base/android/proguard/proguard.gni")
import("//build/config/android/rules.gni")
import("//build/config/locales.gni")
import("//build/config/android/extract_unwind_tables.gni") import("//build/config/android/extract_unwind_tables.gni")
import("//build/config/android/rules.gni")
import("//build/config/compiler/compiler.gni") import("//build/config/compiler/compiler.gni")
import("//build/config/locales.gni")
import("//chrome/common/features.gni") import("//chrome/common/features.gni")
import("//device/vr/buildflags/buildflags.gni") import("//device/vr/buildflags/buildflags.gni")
import("channel.gni") import("channel.gni")
...@@ -220,14 +220,25 @@ template("monochrome_public_common_apk_or_module_tmpl") { ...@@ -220,14 +220,25 @@ template("monochrome_public_common_apk_or_module_tmpl") {
!invoker.use_trichrome_library) { !invoker.use_trichrome_library) {
# Always build 64-bit //android_webview:monochrome because Chrome runs # Always build 64-bit //android_webview:monochrome because Chrome runs
# in 32-bit mode. # in 32-bit mode.
if (invoker.target_type == "android_app_bundle_module") {
_suffix = "_base"
} else {
_suffix = ""
}
if (android_64bit_target_cpu) { if (android_64bit_target_cpu) {
shared_libraries = [ "//android_webview:monochrome" ] shared_libraries = [ "//android_webview:monochrome" ]
if (invoker.add_unwind_tables_in_apk) {
shared_library_for_unwind_asset = "monochrome"
}
if (build_apk_secondary_abi) {
secondary_abi_shared_libraries =
[ "//chrome/android:monochrome${_suffix}_secondary_abi_lib" ]
}
} else { } else {
shared_libraries = [ "//chrome/android:monochrome" ] shared_libraries = [ "//chrome/android:monochrome${_suffix}" ]
} if (invoker.add_unwind_tables_in_apk) {
if (android_64bit_target_cpu && build_apk_secondary_abi) { shared_library_for_unwind_asset = "monochrome${_suffix}"
secondary_abi_shared_libraries = }
[ "//chrome/android:monochrome_secondary_abi_lib" ]
} }
} else { } else {
# Include a 32-bit placeholder library to ensure that Chrome runs in # Include a 32-bit placeholder library to ensure that Chrome runs in
...@@ -239,9 +250,6 @@ template("monochrome_public_common_apk_or_module_tmpl") { ...@@ -239,9 +250,6 @@ template("monochrome_public_common_apk_or_module_tmpl") {
native_lib_placeholders = [ "libdummy.so" ] native_lib_placeholders = [ "libdummy.so" ]
} }
} }
if (invoker.add_unwind_tables_in_apk) {
shared_library_for_unwind_asset = "monochrome"
}
alternative_android_sdk_dep = webview_framework_dep alternative_android_sdk_dep = webview_framework_dep
app_as_shared_lib = true app_as_shared_lib = true
...@@ -282,9 +290,13 @@ template("monochrome_public_common_apk_or_module_tmpl") { ...@@ -282,9 +290,13 @@ template("monochrome_public_common_apk_or_module_tmpl") {
"//android_webview/apk:webview_license_activity_java", "//android_webview/apk:webview_license_activity_java",
"//android_webview/glue", "//android_webview/glue",
"//chrome/android:chrome_public_non_pak_assets", "//chrome/android:chrome_public_non_pak_assets",
"//chrome/android:monochrome_apk_pak_assets",
"//chrome/android/monochrome:monochrome_license_provider_java", "//chrome/android/monochrome:monochrome_license_provider_java",
] ]
if (invoker.target_type == "android_app_bundle_module") {
deps += [ "//chrome/android:monochrome_bundle_pak_assets" ]
} else {
deps += [ "//chrome/android:monochrome_apk_pak_assets" ]
}
if (_enable_multidex && invoker.target_type == "android_apk" && if (_enable_multidex && invoker.target_type == "android_apk" &&
!defined(invoker.negative_main_dex_globs)) { !defined(invoker.negative_main_dex_globs)) {
...@@ -328,21 +340,3 @@ template("monochrome_public_common_apk_or_module_tmpl") { ...@@ -328,21 +340,3 @@ template("monochrome_public_common_apk_or_module_tmpl") {
} }
} }
} }
# These empty templates are still being called from the clank/ BUILD.gn
# scripts. Remove them when they have been fixed to call the
# xxx_common_apk_or_module_tmpl templates above.
template("chrome_public_apk_tmpl") {
chrome_public_common_apk_or_module_tmpl(target_name) {
forward_variables_from(invoker, "*")
target_type = "android_apk"
}
}
template("monochrome_public_apk_tmpl") {
monochrome_public_common_apk_or_module_tmpl(target_name) {
forward_variables_from(invoker, "*")
target_type = "android_apk"
}
}
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