blob: 1b992ab353318525cce60d7a5c13e6d0714b7df3 [file] [log] [blame]
# Copyright 2018 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/android/abi.gni")
import("//build/config/android/channel.gni")
import("//build/config/android/config.gni")
import("//build/config/android/rules.gni")
import("//chrome/android/chrome_public_apk_tmpl.gni")
import("//chrome/android/modules/buildflags.gni")
import("//chrome/version.gni")
import("//device/vr/buildflags/buildflags.gni")
if (!defined(default_trichrome_certdigest)) {
default_trichrome_certdigest =
"32a2fc74d731105859e5a85df16d95f102d85b22099b8064c5d8915c61dad1e0"
}
declare_args() {
# The package name for the Trichrome static shared library on Android.
trichrome_library_package = "org.chromium.trichromelibrary"
# The SHA256 certificate digest for the Trichrome static shared library on
# Android. You can use "apksigner verify --print-certs" on the signed APK to
# calculate the correct digest.
trichrome_certdigest = default_trichrome_certdigest
# By default, Trichrome channels are compiled using separate package names.
# Set this to 'true' to compile Trichrome channels using the Stable channel's
# package name. This currently only affects builds with `android_channel =
# "beta"`.
use_stable_package_name_for_trichrome = false
}
trichrome_jinja_variables = [
"min_sdk_version=29",
"target_sdk_version=$android_sdk_version",
"trichrome_library=$trichrome_library_package",
"trichrome_certdigest=$trichrome_certdigest",
"use32bitAbi=android:use32bitAbi=\"true\"",
"zygote_preload_class=org.chromium.chrome.app.TrichromeZygotePreload",
]
template("trichrome_library_apk_tmpl") {
android_apk(target_name) {
forward_variables_from(invoker,
[
"android_manifest",
"android_manifest_dep",
"apk_name",
"expected_android_manifest",
"expected_libs_and_assets",
"min_sdk_version",
"target_sdk_version",
])
# TODO(torne): since there's no real java code in the library right now,
# leave out the build hooks and let them get compiled into each APK. Later
# this should probably be in the library.
no_build_hooks = true
include_size_info = is_official_build
alternative_android_sdk_dep = webview_framework_dep
r_java_root_package_name = "trichrome_lib"
app_as_shared_lib = true
# No support for this has been added, also not supported by test runner
# since trichrome library is used in "additional_apks" in the trichrome
# bundle smoke tests.
never_incremental = true
uncompress_shared_libraries = true
uncompress_dex = true
version_name = chrome_version_name
_use_stable_package_name_for_trichrome =
use_stable_package_name_for_trichrome && android_channel == "beta"
if (android_64bit_target_cpu) {
if (invoker.is_64_bit_browser) {
if (invoker.include_32_bit_webview) {
if (_use_stable_package_name_for_trichrome) {
version_code = trichrome_64_32_beta_version_code
} else {
version_code = trichrome_64_32_version_code
}
} else {
_use_high_package_name_for_64bit_only_trichrome = is_high_end_android
if (_use_high_package_name_for_64bit_only_trichrome) {
if (_use_stable_package_name_for_trichrome) {
version_code = trichrome_64_high_beta_version_code
} else {
version_code = trichrome_64_high_version_code
}
} else {
if (_use_stable_package_name_for_trichrome) {
version_code = trichrome_64_beta_version_code
} else {
version_code = trichrome_64_version_code
}
}
}
} else {
if (invoker.include_64_bit_webview) {
if (_use_stable_package_name_for_trichrome) {
version_code = trichrome_32_64_beta_version_code
} else {
version_code = trichrome_32_64_version_code
}
} else {
if (_use_stable_package_name_for_trichrome) {
version_code = trichrome_32_beta_version_code
} else {
version_code = trichrome_32_version_code
}
}
}
} else {
if (_use_stable_package_name_for_trichrome) {
version_code = trichrome_beta_version_code
} else {
version_code = trichrome_version_code
}
}
min_sdk_version = 29
# TODO(torne): using icon_resources just to get a temporary icon
deps = [
"//android_webview/nonembedded:icon_resources",
"//third_party/icu:icu_assets",
]
omit_dex = true
# Flag whether additional deps and libs should be included for each ABI.
_include_primary_support = false
_include_secondary_support = false
if (android_64bit_target_cpu) {
# Include the actual browser-bitness libmonochrome library, dependencies
# (crashpad and linker), and an opposite-bitness placeholder library to
# ensure that the library is treated as multiarch and gets its Java code
# precompiled for both architectures.
if (invoker.is_64_bit_browser) {
shared_libraries = [ "//chrome/android:libmonochrome_64" ]
_include_primary_support = true
if (invoker.include_32_bit_webview) {
secondary_native_lib_placeholders = [ "libdummy.so" ]
}
} else {
secondary_abi_shared_libraries =
[ "//chrome/android:monochrome_secondary_abi_lib" ]
_include_secondary_support = true
if (invoker.include_64_bit_webview) {
native_lib_placeholders = [ "libdummy.so" ]
}
}
} else {
shared_libraries = [ "//chrome/android:libmonochrome" ]
_include_primary_support = true
}
if (_include_primary_support) {
deps += [
"//chrome/android:chrome_public_v8_assets",
"//third_party/crashpad/crashpad/handler:crashpad_handler_trampoline",
]
loadable_modules = [ "$root_out_dir/libcrashpad_handler_trampoline.so" ]
}
if (_include_secondary_support) {
_trampoline =
"//third_party/crashpad/crashpad/handler:" +
"crashpad_handler_trampoline($android_secondary_abi_toolchain)"
deps += [
"//android_webview:v8_snapshot_secondary_abi_assets",
_trampoline,
]
_secondary_out_dir = get_label_info(_trampoline, "root_out_dir")
secondary_abi_loadable_modules =
[ "$_secondary_out_dir/libcrashpad_handler_trampoline.so" ]
}
if (enable_arcore) {
_libarcore_dir = get_label_info(
"//third_party/arcore-android-sdk-client:com_google_ar_core_java($default_toolchain)",
"target_out_dir") + "/com_google_ar_core_java/jni"
not_needed([ "_libarcore_dir" ])
_arcore_extra_deps = [ "//third_party/arcore-android-sdk-client:com_google_ar_core_J__unpack_aar" ]
not_needed([ "_arcore_extra_deps" ])
if (_include_primary_support) {
loadable_modules +=
[ "$_libarcore_dir/$android_app_abi/libarcore_sdk_c.so" ]
deps += _arcore_extra_deps
}
if (_include_secondary_support) {
if (enable_arcore) {
secondary_abi_loadable_modules += [
"$_libarcore_dir/$android_app_secondary_abi/libarcore_sdk_c.so",
]
deps += _arcore_extra_deps
}
}
}
}
}
# An .ssargs file is a text file to specify multiple input files with respective
# parameters, and is used by SuperSize-archive to create multi-container .size
# files. This is used to support SuperSize on Trichrome.
template("write_ssargs_trichrome") {
_extra_args = " --abi-filter $android_app_abi"
# Base names (i.e., no full path) are used because .ssargs files specifies
# files using paths relative to itself. It is expected for |ssargs_path| to
# be in the same directory as all Trichrome files whose sizes are measured
# by SuperSize.
_lines = [
"# Written by build target \"${target_name}.\"",
"Library -f ${invoker.trichrome_library_basename}$_extra_args --no-java",
"Chrome -f ${invoker.trichrome_chrome_basename}$_extra_args",
"WebView -f ${invoker.trichrome_webview_basename}$_extra_args",
]
write_file(invoker.ssargs_path, _lines)
}