blob: bf4f5af0db94e0a58ec5a8623a83cce56b965408 [file] [log] [blame]
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//base/android/linker/config.gni")
import("//build/config/android/config.gni")
import("//build/config/android/linker_version_script.gni")
import("//build/config/compiler/compiler.gni")
import("//device/vr/buildflags/buildflags.gni")
# These variables control whether app bundles use the same native libraries as
# the APK, or bundle-specific versions. The bundle-specific versions may
# diverge when code is moved from the base library into dynamic feature
# modules. The variables can be removed when the bundle-specific lib
# configuration has stabilized.
bundle_library_suffix = "_base"
bundle_pak_asset_type = "bundle"
# This template contains all common configuration for native shared libraries,
# including libchrome, monochrome, standalone webview (also called monochrome),
# and libchromefortest (used by chrome_public_test_apk).
#
# Variables:
# export_symbol_whitelist: Optional. If set, a pre-determined list of additional
# methods are exposed by the resulting library.
# is_monochrome: Optional. If set, the library is for use in monochrome.
# is_webview: If true, the library is for webview, and browser-specific
# config is skipped.
template("chrome_common_shared_library") {
_is_monochrome = defined(invoker.is_monochrome) && invoker.is_monochrome
_is_webview = defined(invoker.is_webview) && invoker.is_webview
_export_java_symbols = _is_monochrome || _is_webview
_linker_script = "$target_gen_dir/${target_name}_linker_script.txt"
_linker_script_target = "${target_name}_linker_script"
# Create a custom linker script based on JNI and feature module requirements.
generate_linker_version_script(_linker_script_target) {
linker_script = _linker_script
export_java_symbols = _export_java_symbols
if (defined(invoker.export_symbol_whitelist)) {
export_symbol_whitelist_file =
"//chrome/android/feature_module_exports.lst"
}
}
shared_library(target_name) {
forward_variables_from(invoker, "*", [ "export_symbol_whitelist" ])
if (!_is_webview) {
deps += [ "//chrome:chrome_android_core" ]
}
public_configs = extra_chrome_shared_library_configs
deps += extra_chrome_shared_library_deps
# Use a dynamically-generated linker script.
configs -= [ "//build/config/android:hide_all_but_jni_onload" ]
deps += [ ":$_linker_script_target" ]
inputs = [
"$_linker_script",
]
if (!defined(ldflags)) {
ldflags = []
}
ldflags += [ "-Wl,--version-script=" +
rebase_path(_linker_script, root_build_dir) ]
# Handle VR JNI regisration and dependencies.
if (!_is_webview && enable_vr) {
if (_export_java_symbols) {
# NOTE: While this is file is named *_monochrome.cc, it just contains
# an empty vr::RegisterJni() function that returns true.
sources += [ "../browser/android/vr/register_jni_monochrome.cc" ]
} else {
sources += [ "../browser/android/vr/register_jni.cc" ]
deps += [
"//chrome/browser/android/vr:jni_registration($default_toolchain)",
]
}
}
# Compress relocations if needed.
if ((_is_monochrome || _is_webview || chromium_linker_supported) &&
use_lld) {
configs += [ "//build/config/android:lld_pack_relocations" ]
}
if ((_is_monochrome || _is_webview || chromium_linker_supported) &&
target_cpu != "mipsel" && target_cpu != "mips64el") {
# By default, the static linker will create ELF executables with both
# SysV and GNU hash tables. Now that the chromium linker supports the GNU
# format, which is considerably smaller, ensure that the SysV one is
# never compiled in the final library (http://crbug.com/742525#c28). GNU
# hash support was added in Android M. Also not supported on MIPS
# architecture (http://crbug.com/811306).
ldflags += [ "-Wl,--hash-style=gnu" ]
}
# See crbug.com/705088.
if (target_cpu == "arm" && is_asan) {
ldflags += [ "-Wl,--long-plt" ]
}
}
}