Commit 003524e4 authored by Clark DuVall's avatar Clark DuVall Committed by Commit Bot

Handle shared libs and loadable modules in chrome DFM

This changes the approach for including shared libs from DFMs a bit.
Instead of adding the native deps to the main lib, this change instead
keeps the native code in partitioned libs which are added to the base
module. This allows the DFMs folded into the chrome DFM to function as
much as possible like they would normally, and also saves us from
loading native code from the DFMs if it's not needed.

This change also adds loadable modules from DFMs into the base module if
the chrome module is enabled.

Bug: 1126301
Change-Id: Iff5466b62a1adbbf0bce730df66e7116759d5df5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2416725Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808202}
parent a485e012
...@@ -2115,6 +2115,7 @@ template("monochrome_public_apk_or_module_tmpl") { ...@@ -2115,6 +2115,7 @@ template("monochrome_public_apk_or_module_tmpl") {
"include_64_bit_webview", "include_64_bit_webview",
"is_64_bit_browser", "is_64_bit_browser",
"is_base_module", "is_base_module",
"module_descs",
"resource_ids_provider_dep", "resource_ids_provider_dep",
"static_library_provider", "static_library_provider",
"static_library_synchronized_proguard", "static_library_synchronized_proguard",
...@@ -2757,6 +2758,9 @@ template("monochrome_or_trichrome_public_bundle_tmpl") { ...@@ -2757,6 +2758,9 @@ template("monochrome_or_trichrome_public_bundle_tmpl") {
target_type = "android_app_bundle_module" target_type = "android_app_bundle_module"
is_base_module = true is_base_module = true
version_code = _version_code version_code = _version_code
if (enable_chrome_module) {
module_descs = _module_descs
}
if (!_is_trichrome || if (!_is_trichrome ||
!defined(invoker.static_library_synchronized_proguard) || !defined(invoker.static_library_synchronized_proguard) ||
...@@ -2787,12 +2791,6 @@ template("monochrome_or_trichrome_public_bundle_tmpl") { ...@@ -2787,12 +2791,6 @@ template("monochrome_or_trichrome_public_bundle_tmpl") {
version_code = _version_code version_code = _version_code
if (enable_chrome_module) { if (enable_chrome_module) {
chrome_deps = [ "//chrome/android:app_hooks_java" ] chrome_deps = [ "//chrome/android:app_hooks_java" ]
if (enable_arcore) {
chrome_deps += [
"//chrome/browser/android/vr:ar_java",
"//third_party/arcore-android-sdk-client:com_google_ar_core_java",
]
}
if (!_is_trichrome) { if (!_is_trichrome) {
chrome_deps += [ "//chrome/android:monochrome_java" ] chrome_deps += [ "//chrome/android:monochrome_java" ]
} }
......
...@@ -8,7 +8,6 @@ import("//build/config/android/linker_version_script.gni") ...@@ -8,7 +8,6 @@ import("//build/config/android/linker_version_script.gni")
import("//build/config/compiler/compiler.gni") import("//build/config/compiler/compiler.gni")
import("//build/partitioned_shared_library.gni") import("//build/partitioned_shared_library.gni")
import("//chrome/android/modules/buildflags.gni") import("//chrome/android/modules/buildflags.gni")
import("//chrome/android/modules/chrome_bundle_tmpl.gni")
import("//device/vr/buildflags/buildflags.gni") import("//device/vr/buildflags/buildflags.gni")
# TODO(cjgrant): Remove these variables once downstream stops using them. # TODO(cjgrant): Remove these variables once downstream stops using them.
...@@ -40,14 +39,9 @@ template("chrome_common_shared_library") { ...@@ -40,14 +39,9 @@ template("chrome_common_shared_library") {
# When _collect_inputs_only && !(!_is_webview && enable_vr). # When _collect_inputs_only && !(!_is_webview && enable_vr).
not_needed([ "_export_java_symbols" ]) not_needed([ "_export_java_symbols" ])
# TODO(crbug.com/1126301): Fix symbol table warnings from deps using
# -fsymbol-partition when they are merged into the main lib.
# Whether to merge all module deps into the main library.
_merge_modules = _is_monochrome && enable_chrome_module
# Create a partitioned libraries if the build config supports it, and the # Create a partitioned libraries if the build config supports it, and the
# invoker has supplied module descriptors. # invoker has supplied module descriptors.
_generate_partitions = !_merge_modules && defined(invoker.module_descs) && _generate_partitions = defined(invoker.module_descs) &&
use_native_partitions && !_collect_inputs_only use_native_partitions && !_collect_inputs_only
_module_descs = [] _module_descs = []
if (defined(invoker.module_descs)) { if (defined(invoker.module_descs)) {
...@@ -127,7 +121,7 @@ template("chrome_common_shared_library") { ...@@ -127,7 +121,7 @@ template("chrome_common_shared_library") {
deps += _module_desc.native_deps deps += _module_desc.native_deps
} }
} }
} else if (_collect_inputs_only || _merge_modules) { } else if (_collect_inputs_only) {
foreach(_module_desc, _module_descs) { foreach(_module_desc, _module_descs) {
if (defined(_module_desc.native_deps)) { if (defined(_module_desc.native_deps)) {
deps += _module_desc.native_deps deps += _module_desc.native_deps
......
...@@ -12,6 +12,7 @@ import("//build/config/locales.gni") ...@@ -12,6 +12,7 @@ import("//build/config/locales.gni")
import("//build/util/version.gni") import("//build/util/version.gni")
import("//chrome/android/chrome_common_shared_library.gni") import("//chrome/android/chrome_common_shared_library.gni")
import("//chrome/android/features/dev_ui/dev_ui_module.gni") import("//chrome/android/features/dev_ui/dev_ui_module.gni")
import("//chrome/android/modules/chrome_bundle_tmpl.gni")
import("//chrome/common/features.gni") import("//chrome/common/features.gni")
import("//device/vr/buildflags/buildflags.gni") import("//device/vr/buildflags/buildflags.gni")
import("//weblayer/variables.gni") import("//weblayer/variables.gni")
...@@ -416,10 +417,42 @@ template("chrome_public_common_apk_or_module_tmpl") { ...@@ -416,10 +417,42 @@ template("chrome_public_common_apk_or_module_tmpl") {
# static library target to provide certain shared library deps, and that # static library target to provide certain shared library deps, and that
# this target should not package webview deps. # this target should not package webview deps.
template("monochrome_public_common_apk_or_module_tmpl") { template("monochrome_public_common_apk_or_module_tmpl") {
_is_bundle_module = defined(invoker.target_type) &&
invoker.target_type == "android_app_bundle_module"
_enable_chrome_module =
_is_bundle_module && invoker.is_base_module && enable_chrome_module
# If the chrome module is enabled, collect shared libraries from all other
# DFMs and add them as loadable modules to the base module.
if (_enable_chrome_module) {
_module_descs = []
if (defined(invoker.module_descs)) {
_module_descs = invoker.module_descs
}
_chrome_module_shared_lib_deps = []
_chrome_module_loadable_modules = []
_arch = ""
_toolchain = ""
if (android_64bit_target_cpu) {
if (invoker.is_64_bit_browser) {
_arch = "_64"
} else {
_toolchain = "($android_secondary_abi_toolchain)"
}
}
_base_target_name = "libmonochrome${_arch}"
foreach(_module_desc, _module_descs) {
if (defined(_module_desc.native_deps) && _module_desc.native_deps != []) {
_lib_target = "//chrome/android:${_base_target_name}_${_module_desc.name}${_toolchain}"
_chrome_module_shared_lib_deps += [ _lib_target ]
_lib_out_dir = get_label_info(_lib_target, "root_out_dir")
_chrome_module_loadable_modules += [ "${_lib_out_dir}/${_base_target_name}_${_module_desc.name}_partition.so" ]
}
}
}
chrome_public_common_apk_or_module_tmpl(target_name) { chrome_public_common_apk_or_module_tmpl(target_name) {
_overrides = { _overrides = {
_is_bundle_module = defined(invoker.target_type) &&
invoker.target_type == "android_app_bundle_module"
if (_is_bundle_module) { if (_is_bundle_module) {
assert( assert(
defined(invoker.is_base_module), defined(invoker.is_base_module),
...@@ -500,6 +533,37 @@ template("monochrome_public_common_apk_or_module_tmpl") { ...@@ -500,6 +533,37 @@ template("monochrome_public_common_apk_or_module_tmpl") {
} }
} }
# Add all loadable modules and shared libraries from DFMs.
if (_enable_chrome_module) {
if (!defined(data_deps)) {
data_deps = []
}
data_deps += _chrome_module_shared_lib_deps
_loadable_modules_32_bit = []
_loadable_modules_64_bit = []
foreach(_module_desc, _module_descs) {
if (defined(_module_desc.loadable_modules_32_bit)) {
_loadable_modules_32_bit += _module_desc.loadable_modules_32_bit
}
if (defined(_module_desc.loadable_modules_64_bit)) {
_loadable_modules_64_bit += _module_desc.loadable_modules_64_bit
}
}
if (android_64bit_target_cpu) {
if (invoker.is_64_bit_browser) {
loadable_modules +=
_loadable_modules_64_bit + _chrome_module_loadable_modules
} else {
secondary_abi_loadable_modules +=
_loadable_modules_32_bit + _chrome_module_loadable_modules
}
} else {
loadable_modules +=
_loadable_modules_32_bit + _chrome_module_loadable_modules
}
}
if (is_monochrome) { if (is_monochrome) {
product_config_java_packages = [ product_config_java_packages = [
"org.chromium.chrome.browser", "org.chromium.chrome.browser",
......
...@@ -73,6 +73,12 @@ template("chrome_bundle") { ...@@ -73,6 +73,12 @@ template("chrome_bundle") {
android_manifest_dep = android_manifest_dep =
"${invoker.base_module_target}__android_manifest__split" "${invoker.base_module_target}__android_manifest__split"
java_deps = [ "//chrome/android:chrome_all_java" ] + _java_deps java_deps = [ "//chrome/android:chrome_all_java" ] + _java_deps
if (enable_arcore) {
java_deps += [
"//chrome/browser/android/vr:ar_java",
"//third_party/arcore-android-sdk-client:com_google_ar_core_java",
]
}
pak_deps = _pak_deps pak_deps = _pak_deps
paks = _paks paks = _paks
if (defined(invoker.chrome_deps)) { if (defined(invoker.chrome_deps)) {
......
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