mirror of
https://github.com/klzgrad/naiveproxy.git
synced 2024-11-24 14:26:09 +03:00
307 lines
11 KiB
Plaintext
307 lines
11 KiB
Plaintext
# Copyright 2015 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("//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/compiler/compiler.gni")
|
|
import("//chrome/common/features.gni")
|
|
import("//device/vr/buildflags/buildflags.gni")
|
|
import("//third_party/leakcanary/config.gni")
|
|
import("channel.gni")
|
|
|
|
declare_args() {
|
|
# Enable multidex in release builds.
|
|
multidex_in_release = false
|
|
}
|
|
|
|
default_chrome_public_jinja_variables = [
|
|
"channel=$android_channel",
|
|
"enable_arcore=$enable_arcore",
|
|
"enable_leakcanary=$enable_leakcanary",
|
|
"enable_vr=$enable_vr",
|
|
]
|
|
|
|
# A template used to declare any target that will implement a full Chromium
|
|
# or Chrome application, either as an APK, or an app bundle module.
|
|
#
|
|
# Variables:
|
|
# target_type: Either 'android_apk' or 'android_app_bundle_module'.
|
|
# apk_name: For APK target types, the final APK name without a suffix.
|
|
# module_name: For bundle module target types, the module's name without a
|
|
# suffix.
|
|
# is_base_module: For bundle module target types, true iff this is a base
|
|
# application module, instead of a feature module.
|
|
# android_manifest: Application manifest path.
|
|
# android_manifest_dep: Name of target generating the android_manifest.
|
|
# shared_libraries: List of native shared libraries targets to include in
|
|
# the final target (e.g. [ ":libchrome" ]).
|
|
# add_unwind_tables_in_apk: Optional. If true, add the unwind tables to the
|
|
# 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.
|
|
# 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.
|
|
# load_library_from_apk: Optional. If true, native libraries will be loaded
|
|
# 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.
|
|
#
|
|
template("chrome_public_common_apk_or_module_tmpl") {
|
|
assert(defined(invoker.target_type), "target_type is required!")
|
|
assert(
|
|
invoker.target_type == "android_apk" ||
|
|
invoker.target_type == "android_app_bundle_module",
|
|
"Invalid target_type definition, should be 'android_apk' or 'android_app_bundle_module'")
|
|
|
|
# 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
|
|
# library of the apk, to extract unwind tables.
|
|
if (defined(invoker.add_unwind_tables_in_apk) &&
|
|
invoker.add_unwind_tables_in_apk) {
|
|
_unwind_asset = "${target_name}_unwind_assets"
|
|
unwind_table_asset(_unwind_asset) {
|
|
if (defined(invoker.testonly)) {
|
|
testonly = invoker.testonly
|
|
}
|
|
|
|
library_target = invoker.shared_library_for_unwind_asset
|
|
deps = invoker.shared_libraries
|
|
}
|
|
}
|
|
|
|
if (!defined(invoker.target_type)) {
|
|
_target_type = "android_apk"
|
|
} else {
|
|
_target_type = invoker.target_type
|
|
}
|
|
|
|
_is_modern = defined(invoker.is_modern) && invoker.is_modern
|
|
assert(_is_modern || !_is_modern) # Mark as used.
|
|
|
|
if (defined(invoker.enable_multidex)) {
|
|
_enable_multidex = invoker.enable_multidex
|
|
} else {
|
|
_enable_multidex = is_java_debug || multidex_in_release
|
|
}
|
|
|
|
target(_target_type, target_name) {
|
|
forward_variables_from(invoker, "*")
|
|
exclude_xxxhdpi = true
|
|
|
|
# Use zh-TW strings for zh-HK (https://crbug.com/780847).
|
|
support_zh_hk = true
|
|
|
|
# Whitelist rationale in https://crbug.com/691733.
|
|
xxxhdpi_whitelist = [
|
|
"*shadow*", # Combination of gradient & transparency cause pixelation.
|
|
"*.9.*", # Most nine-patches contain shadows.
|
|
"*ic_file_download_white*", # Bottom edge seems misaligned.
|
|
"*ic_lock.*", # Bottom edge seems misaligned.
|
|
]
|
|
|
|
if (defined(shared_libraries) && 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)"
|
|
native_lib_version_rule = "//build/util:chrome_version_json"
|
|
}
|
|
if (!defined(aapt_locale_whitelist)) {
|
|
aapt_locale_whitelist = locales - android_chrome_omitted_locales
|
|
}
|
|
|
|
if (_enable_multidex) {
|
|
enable_multidex = true
|
|
if (_target_type == "android_apk") {
|
|
if (!defined(negative_main_dex_globs)) {
|
|
negative_main_dex_globs = [
|
|
"*ApplicationStatus*", # Doesn't work in non-browser process.
|
|
"*ChromeActivity*", # Pulls in the world, so ensure it doesn't slip in.
|
|
"*GoogleApiAvailability*", # Play Services only in browser process.
|
|
"*R\$*", # Should not use resources from non-browser process.
|
|
]
|
|
}
|
|
|
|
# Allow targets to append to the default list.
|
|
if (defined(extra_negative_main_dex_globs)) {
|
|
negative_main_dex_globs += extra_negative_main_dex_globs
|
|
}
|
|
}
|
|
}
|
|
if (!is_java_debug) {
|
|
proguard_enabled = true
|
|
if (!defined(proguard_configs)) {
|
|
proguard_configs = []
|
|
}
|
|
proguard_configs += [
|
|
"//chrome/android/java/proguard.flags",
|
|
"//base/android/proguard/chromium_apk.flags",
|
|
"//base/android/proguard/chromium_code.flags",
|
|
]
|
|
if (enable_proguard_obfuscation) {
|
|
proguard_configs +=
|
|
[ "//base/android/proguard/enable_obfuscation.flags" ]
|
|
} else {
|
|
proguard_configs +=
|
|
[ "//base/android/proguard/disable_all_obfuscation.flags" ]
|
|
}
|
|
}
|
|
|
|
if (!defined(use_chromium_linker)) {
|
|
use_chromium_linker = chromium_linker_supported
|
|
}
|
|
|
|
if (use_chromium_linker) {
|
|
if (!defined(load_library_from_apk)) {
|
|
# Whether native libraries should be loaded from within the apk.
|
|
# Only attempt loading the library from the APK for 64 bit devices
|
|
# until the number of 32 bit devices which don't support this
|
|
# approach falls to a minimal level - http://crbug.com/390618.
|
|
load_library_from_apk = chromium_linker_supported &&
|
|
(current_cpu == "arm64" || current_cpu == "x64")
|
|
}
|
|
}
|
|
if (_target_type == "android_apk") {
|
|
command_line_flags_file = "chrome-command-line"
|
|
}
|
|
product_version_resources_dep = "//chrome/android:product_version_resources"
|
|
|
|
if (defined(invoker.add_unwind_tables_in_apk) &&
|
|
invoker.add_unwind_tables_in_apk) {
|
|
deps += [ ":$_unwind_asset" ]
|
|
}
|
|
|
|
if (enable_vr && _target_type == "android_apk") {
|
|
deps += [ "//chrome/browser/android/vr:java" ]
|
|
}
|
|
}
|
|
}
|
|
|
|
# The equivalent of chrome_common_apk_or_module_tmpl for all builds of
|
|
# monochrome.
|
|
template("monochrome_public_common_apk_or_module_tmpl") {
|
|
if (defined(invoker.enable_multidex)) {
|
|
_enable_multidex = invoker.enable_multidex
|
|
} else {
|
|
_enable_multidex = is_java_debug || multidex_in_release
|
|
}
|
|
chrome_public_common_apk_or_module_tmpl(target_name) {
|
|
# Always build 64-bit //android_webview:monochrome because Chrome runs
|
|
# in 32-bit mode.
|
|
if (android_64bit_target_cpu) {
|
|
shared_libraries = [ "//android_webview:monochrome" ]
|
|
} else {
|
|
shared_libraries = [ "//chrome/android:monochrome" ]
|
|
}
|
|
if (android_64bit_target_cpu && build_apk_secondary_abi) {
|
|
secondary_abi_shared_libraries =
|
|
[ "//chrome/android:monochrome_secondary_abi_lib" ]
|
|
}
|
|
|
|
alternative_android_sdk_dep = webview_framework_dep
|
|
app_as_shared_lib = true
|
|
use_chromium_linker = false
|
|
requires_sdk_api_level_23 = true
|
|
|
|
# Webview supports all locales (has no omitted ones).
|
|
aapt_locale_whitelist = locales
|
|
|
|
if (!defined(invoker.target_type) || invoker.target_type == "android_apk") {
|
|
# Incremental install doesn't work for monochrome. See crbug.com/663492.
|
|
never_incremental = true
|
|
}
|
|
|
|
# Strip xml namespaces for monochrome. This should only be done for apks
|
|
# targeting API > 21 which for chrome is only Monochrome. This is due to
|
|
# how android public and private resource ids are namespaced.
|
|
no_xml_namespaces = true
|
|
|
|
# Configrations to make android load shared library from APK.
|
|
uncompress_shared_libraries = true
|
|
|
|
forward_variables_from(invoker, "*")
|
|
|
|
# Android N+ better supports multiple locales (https://crbug.com/780847).
|
|
support_zh_hk = false
|
|
|
|
if (!defined(deps)) {
|
|
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_pak_assets",
|
|
"//chrome/android/monochrome:monochrome_license_provider_java",
|
|
]
|
|
|
|
if (_enable_multidex && invoker.target_type == "android_apk" &&
|
|
!defined(invoker.negative_main_dex_globs)) {
|
|
# WebView pulls play services into the main dex.
|
|
negative_main_dex_globs = [
|
|
# TODO(agrieve): Add ApplicationStatus to this list. It's currently
|
|
# included because of ActivityWindowAndroid, but is never used at
|
|
# runtime by webview.
|
|
"*ChromeActivity*", # Pulls in the world, so ensure it doesn't slip in.
|
|
]
|
|
}
|
|
|
|
if (!is_java_debug) {
|
|
if (!defined(proguard_configs)) {
|
|
proguard_configs = []
|
|
}
|
|
proguard_configs += [ "//android_webview/apk/java/proguard.flags" ]
|
|
png_to_webp = true
|
|
}
|
|
|
|
# TODO(crbug.com/862719): Remove Java VR code from the monochrome base
|
|
# module once we can conditionally install the VR DFM.
|
|
if (enable_vr) {
|
|
deps += [ "//chrome/browser/android/vr:java" ]
|
|
}
|
|
|
|
if (invoker.target_type == "android_apk") {
|
|
if (enable_arcore) {
|
|
deps += [ "//third_party/arcore-android-sdk:libdynamite_client_java" ]
|
|
}
|
|
if (package_arcore) {
|
|
# We store this as a separate .so in the APK and only load as needed.
|
|
if (android_64bit_target_cpu && build_apk_secondary_abi) {
|
|
secondary_abi_loadable_modules = [ "//third_party/arcore-android-sdk/libraries/android_arm/libarcore_sdk_c_minimal.so" ]
|
|
} else if (android_64bit_target_cpu && !build_apk_secondary_abi) {
|
|
loadable_modules = [ "//third_party/arcore-android-sdk/libraries/android_arm64/libarcore_sdk_c_minimal.so" ]
|
|
} else {
|
|
loadable_modules = [ "//third_party/arcore-android-sdk/libraries/android_arm/libarcore_sdk_c_minimal.so" ]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
# 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"
|
|
}
|
|
}
|