| # Copyright 2015 The Chromium Authors |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//android_webview/variables.gni") |
| import("//base/android/linker/config.gni") |
| import("//base/android/resource_exclusions.gni") |
| import("//build/config/android/rules.gni") |
| import("//build/config/compiler/compiler.gni") |
| import("//build/config/locales.gni") |
| import("//build/toolchain/gcc_toolchain.gni") |
| import("//chrome/android/features/dev_ui/dev_ui_module.gni") |
| import("//chrome/android/modules/chrome_bundle_tmpl.gni") |
| import("//chrome/android/trichrome.gni") |
| import("//chrome/common/features.gni") |
| import("//chrome/version.gni") |
| import("//components/crash/android/silent_java_assert_reporting.gni") |
| import("//device/vr/buildflags/buildflags.gni") |
| import("channel.gni") |
| |
| declare_args() { |
| # Android package name to use when compiling the public chrome targets |
| # (chrome_public_apk, monochrome_public_apk, etc. as well as the |
| # *_bundle variants). This is particularly useful when using |
| # monochrome_public_apk for WebView development, as the OS only accepts |
| # WebView providers which declare one of a handful of package names. See |
| # https://chromium.googlesource.com/chromium/src/+/HEAD/android_webview/docs/build-instructions.md#Changing-package-name |
| # for details. |
| chrome_public_manifest_package = "org.chromium.chrome" |
| if (use_stable_package_name_for_trichrome) { |
| chrome_public_manifest_package += ".stable" |
| } else if (android_channel != "default") { |
| chrome_public_manifest_package += "." + android_channel |
| } |
| } |
| |
| chrome_public_test_manifest_package = "org.chromium.chrome.tests" |
| |
| default_chrome_public_jinja_variables = [ |
| "channel=$android_channel", |
| "enable_cardboard=$enable_cardboard", |
| "enable_vr=$enable_vr", |
| "enable_openxr=$enable_openxr", |
| "enable_arcore=$enable_arcore", |
| "is_desktop_android=$is_desktop_android", |
| "zygote_preload_class=org.chromium.content_public.app.ZygotePreload", |
| ] |
| |
| monochrome_android_manifest_jinja_variables = |
| [ "sandboxed_service_exported=true" ] |
| |
| # Generates an AndroidManifest.xml along with an optional second manifest |
| # dependent on the original. |
| # |
| # Variables: |
| # input: The base manifest template with the main application definition. |
| # output: Output path for |input|. |
| # split_input: Path to an alternate manifest that will be built if |
| # definitions_in_split is true. |
| # split_output: Output path for |split_input|. |
| # variables: Variables to pass to the jinja templates. |
| # definitions_in_split: If true will pass definitions_in_split=true in the |
| # variables passed to |input| and generate |split_output|. |
| template("split_manifest_template") { |
| _definitions_in_split = |
| defined(invoker.definitions_in_split) && invoker.definitions_in_split |
| jinja_template(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "includes", |
| "input", |
| "output", |
| "variables", |
| ]) |
| if (_definitions_in_split) { |
| variables += [ "definitions_in_split=true" ] |
| } |
| } |
| |
| if (_definitions_in_split) { |
| jinja_template("${target_name}__split") { |
| forward_variables_from(invoker, |
| [ |
| "includes", |
| "variables", |
| ]) |
| if (!defined(includes)) { |
| includes = [] |
| } |
| includes += [ invoker.input ] |
| input = invoker.split_input |
| output = invoker.split_output |
| _rebased_input = rebase_path(invoker.input, "//") |
| variables += [ "base_manifest=${_rebased_input}" ] |
| } |
| } else { |
| not_needed(invoker, |
| [ |
| "split_input", |
| "split_output", |
| ]) |
| } |
| } |
| |
| # 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. |
| # shared_libraries: List of native shared libraries targets to include in |
| # the final target (e.g. [ ":libchrome" ]). |
| # is_monochrome: Indicates that this target contains chrome and webview |
| # packaged together and can only run on Android N+. |
| # is_trichrome: Indicates this target relies on a trichrome static library |
| # target and can only run on Android P+. |
| # 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. |
| # |
| # Plus all other variables accepted by android_apk() or |
| # android_app_bundle_module(), depending on the target type. |
| # |
| template("chrome_common_apk_or_module_tmpl") { |
| forward_variables_from(invoker, TESTONLY_AND_VISIBILITY) |
| |
| _target_type = invoker.target_type |
| assert(_target_type == "android_apk" || |
| _target_type == "android_app_bundle_module" || |
| _target_type == "instrumentation_test_apk") |
| |
| _is_monochrome = defined(invoker.is_monochrome) && invoker.is_monochrome |
| _is_trichrome = defined(invoker.is_trichrome) && invoker.is_trichrome |
| _is_bundle = _target_type == "android_app_bundle_module" |
| _is_test = _target_type == "instrumentation_test_apk" |
| assert(!(_is_test && _is_monochrome), "Unsupported configuration") |
| assert(!(_is_test && _is_trichrome), "Unsupported configuration") |
| |
| if (_is_test) { |
| testonly = true |
| } |
| |
| _is_64_bit_browser = |
| android_64bit_target_cpu && |
| (!defined(invoker.is_64_bit_browser) || invoker.is_64_bit_browser) |
| if (_is_trichrome || _is_monochrome) { |
| _include_64_bit_webview = |
| android_64bit_target_cpu && (!defined(invoker.include_64_bit_webview) || |
| invoker.include_64_bit_webview) |
| _include_32_bit_webview = !defined(invoker.include_32_bit_webview) || |
| invoker.include_32_bit_webview |
| _include_primary_abi = !android_64bit_target_cpu || _is_64_bit_browser || |
| _include_64_bit_webview |
| _include_secondary_abi = android_64bit_target_cpu && |
| (!_is_64_bit_browser || _include_32_bit_webview) |
| if (_include_secondary_abi) { |
| _secondary_out_dir = |
| get_label_info("X($android_secondary_abi_toolchain)", "root_out_dir") |
| not_needed([ "_secondary_out_dir" ]) |
| } |
| } |
| |
| assert(!(_is_monochrome && _is_trichrome), |
| "Cannot be both trichrome and monochrome!") |
| assert(_is_trichrome == defined(invoker.static_library_provider), |
| "If trichrome library is used, static_library_provider must be set " + |
| "so that a dep can be added on the library APK.") |
| |
| if (_is_trichrome) { |
| _version_code = TRICHROME_VERSION_MAP["${android_64bit_target_cpu}_${_is_64_bit_browser}_${_include_64_bit_webview}_${_include_32_bit_webview}"] |
| } else if (_is_monochrome) { |
| _version_code = MONOCHROME_VERSION_MAP["${android_64bit_target_cpu}_${_is_64_bit_browser}_${_include_64_bit_webview}_${_include_32_bit_webview}"] |
| } else { |
| _version_code = chrome_version_code |
| } |
| |
| if (defined(invoker.version_code)) { |
| _version_code = invoker.version_code |
| } |
| |
| # Need to apply override explicitly to have it apply to library version. |
| if (android_override_version_code != "") { |
| _version_code = android_override_version_code |
| } |
| |
| if (defined(invoker.manifest_package)) { |
| _manifest_package = invoker.manifest_package |
| } else if (_is_test) { |
| _manifest_package = chrome_public_test_manifest_package |
| } else { |
| _manifest_package = chrome_public_manifest_package |
| } |
| |
| _android_manifest = "$target_gen_dir/$target_name/AndroidManifest.xml" |
| _split_android_manifest = |
| "$target_gen_dir/$target_name/AndroidManifest_split.xml" |
| _android_manifest_target_name = "${target_name}__android_manifest" |
| split_manifest_template(_android_manifest_target_name) { |
| definitions_in_split = _is_bundle |
| split_input = "//chrome/android/java/AndroidManifest_split.xml" |
| split_output = _split_android_manifest |
| includes = [] |
| output = _android_manifest |
| variables = default_chrome_public_jinja_variables + |
| [ "manifest_package=$_manifest_package" ] |
| if (_is_trichrome) { |
| input = "//chrome/android/java/AndroidManifest_trichrome_chrome.xml" |
| includes = [ "//chrome/android/java/AndroidManifest.xml" ] |
| variables += |
| trichrome_jinja_variables + [ "trichrome_version=$_version_code" ] |
| } else if (_is_monochrome) { |
| input = "//chrome/android/java/AndroidManifest_monochrome.xml" |
| includes = [ |
| "//android_webview/nonembedded/java/AndroidManifest.xml", |
| "//chrome/android/java/AndroidManifest.xml", |
| ] |
| variables += monochrome_android_manifest_jinja_variables |
| if (_is_64_bit_browser) { |
| variables += [ "webview_library=libmonochrome_64.so" ] |
| } else { |
| variables += [ "webview_library=libmonochrome.so" ] |
| } |
| } else { |
| input = "//chrome/android/java/AndroidManifest.xml" |
| } |
| if (_is_monochrome || _is_trichrome) { |
| _force_32_bit = _include_32_bit_webview && _include_64_bit_webview && |
| !_is_64_bit_browser |
| variables += [ "force_32_bit=$_force_32_bit" ] |
| } |
| if (_is_test) { |
| includes += [ input ] |
| input = "//chrome/android/javatests/AndroidManifest.xml" |
| } |
| if (defined(invoker.jinja_input)) { |
| includes += [ input ] |
| input = invoker.jinja_input |
| } |
| if (defined(invoker.jinja_extra_variables)) { |
| variables += invoker.jinja_extra_variables |
| } |
| if (defined(invoker.jinja_extra_includes)) { |
| includes += invoker.jinja_extra_includes |
| } |
| } |
| target(_target_type, target_name) { |
| android_manifest = _android_manifest |
| android_manifest_dep = ":$_android_manifest_target_name" |
| manifest_package = _manifest_package |
| |
| if (defined(invoker.min_sdk_version)) { |
| min_sdk_version = invoker.min_sdk_version |
| } else if (_is_trichrome) { |
| min_sdk_version = 29 |
| } |
| if (defined(invoker.version_name)) { |
| version_name = invoker.version_name |
| } else { |
| version_name = chrome_version_name |
| } |
| if (defined(invoker.version_code)) { |
| # Override for the actual versionCode, but not for trichrome_version. |
| version_code = invoker.version_code |
| } else { |
| version_code = _version_code |
| } |
| if (defined(invoker.expected_android_manifest)) { |
| if (android_64bit_target_cpu) { |
| _version_code_offset = chrome_32_version_code |
| } else { |
| _version_code_offset = chrome_version_code |
| } |
| expected_android_manifest_version_code_offset = _version_code_offset |
| expected_android_manifest_library_version_offset = _version_code_offset |
| } |
| |
| if (_target_type == "android_apk") { |
| command_line_flags_file = "chrome-command-line" |
| } |
| |
| if (_is_bundle) { |
| is_base_module = true |
| } |
| |
| product_config_java_packages = [ "org.chromium.chrome.browser" ] |
| |
| if (_is_monochrome) { |
| alternative_android_sdk_dep = webview_framework_dep |
| app_as_shared_lib = true |
| |
| # Resource allowlist used when generating R.java files and causes |
| # only the webview subset of resources to be marked as non-final. |
| # Strings in this target will also be kept in the base apk rather than placed in the language splits. |
| shared_resources_allowlist_target = |
| "//android_webview:system_webview_no_weblayer_apk" |
| |
| # Ensure the localized resources for all locales are used, even when |
| # a smaller set is specified through aapt_locale_allowlist. |
| shared_resources_allowlist_locales = platform_pak_locales |
| |
| product_config_java_packages += [ webview_product_config_java_package ] |
| } else { |
| # Chrome does not enable Strict Mode checks. |
| disable_strict_mode_context = true |
| } |
| |
| if (enable_silent_java_assert_reporting) { |
| custom_assertion_handler = crash_reporting_assertion_handler |
| } |
| |
| # Include resource strings files only for supported locales. |
| aapt_locale_allowlist = platform_pak_locales |
| |
| resource_exclusion_regex = common_resource_exclusion_regex |
| resource_exclusion_exceptions = common_resource_exclusion_exceptions |
| |
| # Exceptions (rationale in https://crbug.com/691733): |
| resource_exclusion_exceptions += [ |
| "*ic_file_download_white*", # Bottom edge seems misaligned. |
| "*ic_lock.*", # Bottom edge seems misaligned. |
| ] |
| |
| # Most of these, with the exception of resource_exclusion_exceptions, |
| # are currently duplicated in system_webview_apk_tmpl.gni. |
| |
| # Used only by alert dialog on tiny screens. |
| _material_package = "com_google_android_material.*" |
| resource_exclusion_regex += "|${_material_package}values-small" |
| |
| # Used only by date picker (which chrome doesn't use). |
| resource_exclusion_regex += "|${_material_package}-(w480dp-port|w360dp-port|h480dp-land|h360dp-land)" |
| |
| # Material design layouts that cause views to be kept that we don't use. |
| # Instead of manually filtering, unused resource removal would be better: |
| # https://crbug.com/636448 |
| resource_exclusion_regex += "|${_material_package}/xml.*badge_" |
| |
| if (!is_java_debug) { |
| # TODO(crbug.com/41475795): Update test goldens with webp versions of images. |
| if (!_is_test) { |
| png_to_webp = true |
| } |
| |
| proguard_enabled = true |
| proguard_configs = [ "//chrome/android/proguard/main.flags" ] |
| if (_is_monochrome) { |
| proguard_configs += |
| [ "//android_webview/nonembedded/java/proguard.flags" ] |
| } |
| if (_is_test) { |
| proguard_configs += [ "//chrome/android/proguard/apk_for_test.flags" ] |
| } |
| if (defined(invoker.proguard_configs)) { |
| proguard_configs += invoker.proguard_configs |
| } |
| |
| # We only optimize resources for bundles since APKs are not shipped. |
| # Resources only live in the base module atm as such we only need to set |
| # these on the base module |
| if (_is_bundle) { |
| # Removes metadata needed for Resources.getIdentifier("resource_name"). |
| strip_resource_names = true |
| |
| # Shortens resource file names in apk eg: res/drawable/button.xml -> res/a.xml |
| short_resource_paths = true |
| |
| # Removes unused resources from the apk. Only enabled on official builds |
| # since it adds a slow step and serializes the build graph causing fewer |
| # expensive tasks (eg: proguarding, resource optimization) to be run in |
| # parallel by adding dependencies between them (adds around 10-20 |
| # seconds on my machine). |
| strip_unused_resources = is_official_build |
| |
| # Resources config for blocklisting resource names from obfuscation |
| resources_config_paths = [ "//chrome/android/aapt2.config" ] |
| if (_is_monochrome) { |
| resources_config_paths += [ "//android_webview/aapt2.config" ] |
| } |
| if (defined(invoker.resources_config_paths)) { |
| resources_config_paths += invoker.resources_config_paths |
| } |
| } |
| } |
| |
| # shared_resources_allowlist_target causes a native dep to appear via resources. |
| if (!_is_monochrome) { |
| # Java and native targets form two independent compile graphs. Deps from java targets |
| # onto native ones (or vice versa) are unnecessary and reduce parallelism. |
| # This prevents most deps from java->native. |
| # One common violation is generate_jni() targets, which generate |
| # .srcjars, but also .h files, and so export their native deps. |
| # Tip: If the dep is due to loadable_modules or android_assets, use "asset_deps" rather than |
| # "deps". |
| assert_no_native_deps = [ |
| "//base", |
| "//build/config/compiler:compiler_buildflags", |
| "//build/rust:cxx_cppdeps", |
| "//third_party/abseil-cpp:absl", |
| ] |
| } |
| |
| deps = [ "//chrome/android:chrome_base_module_resources" ] |
| |
| # TODO(agrieve): Make unconditional when moving to trampoline. |
| if (_is_monochrome || _is_trichrome) { |
| deps += [ "//components/crash/android:handler_java" ] |
| } |
| if (_is_monochrome) { |
| deps += [ "//chrome/android:base_monochrome_module_java" ] |
| } else { |
| deps += [ "//chrome/android:base_module_java" ] |
| } |
| if (defined(invoker.deps)) { |
| deps += invoker.deps |
| } |
| |
| if (!_is_trichrome) { |
| # These go in trichrome library. |
| deps += [ |
| "//gin:v8_snapshot_assets", |
| "//third_party/icu:icu_assets", |
| ] |
| |
| # TODO(agrieve): This is excluded from trichrome in preparation for |
| # "synchronized proguarding", which we've since abandoned. Enable for |
| # trichrome, or just remove the version check altogether. |
| build_config_include_product_version_resource = true |
| deps += [ "//chrome/android:product_version_resources" ] |
| } |
| |
| if (_is_bundle) { |
| # Required to support macro resources. |
| # See https://crbug.com/1278419 |
| deps += [ ":${target_name}__all_dfm_resources" ] |
| } else { |
| # For bundles, this exists in the "chrome" split. |
| deps += [ "//chrome/android:chrome_all_java" ] |
| |
| if (dfmify_dev_ui) { |
| # For bundles, Dev UI is a feature in a DFM. |
| deps += [ "//chrome/android/features/dev_ui:java" ] |
| } |
| } |
| |
| if (_is_monochrome) { |
| deps += [ |
| "//android_webview/glue:glue_java", |
| "//android_webview/nonembedded:monochrome_devui_launcher_icon_resources", |
| "//android_webview/nonembedded:nonembedded_java", |
| ] |
| |
| # For bundles, this lives in chrome split. |
| if (!_is_bundle) { |
| deps += [ "//chrome/android:monochrome_java" ] |
| } |
| |
| if (_include_primary_abi) { |
| deps += [ "//android_webview:monochrome_webview_primary_abi_assets" ] |
| } |
| if (_include_secondary_abi) { |
| deps += [ "//android_webview:monochrome_webview_secondary_abi_assets" ] |
| } |
| } |
| |
| asset_deps = [ "//chrome/android:chrome_public_non_pak_assets" ] |
| if (defined(invoker.asset_deps)) { |
| asset_deps += invoker.asset_deps |
| } |
| |
| if (_is_bundle && _is_monochrome) { |
| asset_deps += [ "//chrome/android:monochrome_bundle_module_pak_assets" ] |
| } else if (_is_bundle && _is_trichrome) { |
| asset_deps += |
| [ "//chrome/android:trichrome_chrome_bundle_module_pak_assets" ] |
| } else if (_is_bundle) { |
| asset_deps += [ "//chrome/android:chrome_bundle_module_pak_assets" ] |
| } else if (_is_monochrome) { |
| asset_deps += [ "//chrome/android:monochrome_apk_pak_assets" ] |
| } else { |
| assert(!_is_trichrome) |
| asset_deps += [ "//chrome/android:chrome_apk_pak_assets" ] |
| } |
| |
| if (_is_trichrome) { |
| # Only the .build_config.json is used from this target, and it's fine if |
| # it contains more assets than we need (always use the 64_32 variant). |
| # https://crbug.com/357131361 |
| suffix_apk_assets_used_by = system_webview_apk_target |
| } |
| |
| if (defined(invoker.add_upstream_only_deps) && |
| invoker.add_upstream_only_deps) { |
| if (_is_monochrome) { |
| deps += upstream_only_webview_deps |
| } else if (!_is_trichrome) { |
| deps += [ |
| "//chrome/android:chrome_public_apk_base_module_resources", |
| "//components/browser_ui/styles/android:chrome_public_apk_resources", |
| ] |
| asset_deps += [ "//chrome/android:chrome_public_non_pak_assets" ] |
| } |
| if (!_is_bundle) { |
| deps += [ |
| "//chrome/android:chrome_all_java", |
| "//chrome/android:delegate_public_impl_java", |
| ] |
| } |
| if (_is_test) { |
| deps += [ "//chrome/android:chrome_public_base_module_java_for_test" ] |
| } |
| } |
| |
| # Chrome uses the window APIs directly instead of going through the |
| # androidx middleware. |
| # See //third_party/android_sdk/window_extensions/README.md |
| assert_no_deps = [ |
| "//third_party/android_deps:org_jetbrains_kotlin_kotlin_parcelize_runtime", |
| "//third_party/androidx:androidx_window_window_java_java", |
| ] |
| if (defined(invoker.assert_no_deps)) { |
| assert_no_deps += invoker.assert_no_deps |
| } |
| |
| # Unwind tables are included in the stack_unwinder DFM on Android, so they |
| # aren't needed for bundle builds. However, we keep them for non-bundle |
| # builds, such as test and development apks (e.g. chrome_public_apk), to |
| # allow tests and developers to use them directly. |
| if (!defined(invoker.shared_libraries) && !_is_bundle && |
| add_unwind_tables_in_chrome_32bit_apk && |
| (target_cpu == "arm" || |
| (target_cpu == "arm64" && !_is_64_bit_browser))) { |
| if (_is_test) { |
| asset_deps += |
| [ "//chrome/android:libchromefortest_unwind_table_assets" ] |
| } else if (_is_monochrome || _is_trichrome) { |
| asset_deps += [ "//chrome/android:libmonochrome_unwind_table_assets" ] |
| } else { |
| asset_deps += [ "//chrome/android:libchrome_unwind_table_assets" ] |
| } |
| } |
| |
| data_deps = [] |
| if (defined(invoker.data_deps)) { |
| data_deps += invoker.data_deps |
| } |
| |
| # Prefer to add this data_dep on the final target instead of java targets |
| # like chrome_all_java so that all other targets can build in parallel with |
| # lint. |
| if (!disable_android_lint) { |
| data_deps += [ "//chrome/android:android_lint" ] |
| } |
| |
| # Official builds need the dump_syms binary for symbolizing. This is a small |
| # binary necessary for debugging official builds. Ensure it is built. |
| if (is_official_build) { |
| data_deps += [ "//third_party/breakpad:dump_syms" ] |
| } |
| |
| shared_libraries = [] |
| loadable_modules = [] |
| if (android_64bit_target_cpu) { |
| secondary_abi_shared_libraries = [] |
| secondary_abi_loadable_modules = [] |
| } |
| if (defined(invoker.loadable_modules)) { |
| loadable_modules = invoker.loadable_modules |
| } |
| if (defined(invoker.secondary_abi_loadable_modules)) { |
| secondary_abi_loadable_modules = invoker.secondary_abi_loadable_modules |
| } |
| |
| if (_is_64_bit_browser && build_hwasan_splits) { |
| _hwasan_toolchain = "//build/toolchain/android:android_clang_arm64_hwasan" |
| } |
| |
| if (defined(invoker.shared_libraries)) { |
| shared_libraries += invoker.shared_libraries |
| } else if (_is_test) { |
| shared_libraries += [ "//chrome/android:libchromefortest" ] |
| srcjar_deps = [ "//chrome/android:libchromefortest__jni_registration($default_toolchain)" ] |
| } else if (_is_monochrome || _is_trichrome) { |
| # We are only doing the jni_registrations for Trichrome - the actual |
| # native libraries will end up in the Trichrome library. |
| if (android_64bit_target_cpu) { |
| # Build //android_webview:monochrome with the opposite bitness that |
| # Chrome runs in. |
| if (_is_64_bit_browser) { |
| srcjar_deps = [ "//chrome/android:libmonochrome_64__jni_registration($default_toolchain)" ] |
| if (_is_monochrome) { |
| shared_libraries += [ "//chrome/android:libmonochrome_64" ] |
| if (_include_32_bit_webview) { |
| secondary_abi_shared_libraries += [ "//android_webview:monochrome_64($android_secondary_abi_toolchain)" ] |
| } |
| if (build_hwasan_splits) { |
| shared_libraries += |
| [ "//chrome/android:libmonochrome_64($_hwasan_toolchain)" ] |
| } |
| } |
| } else { |
| srcjar_deps = [ "//chrome/android:libmonochrome__jni_registration($default_toolchain)" ] |
| if (_is_monochrome) { |
| if (_include_64_bit_webview) { |
| shared_libraries += [ "//android_webview:monochrome" ] |
| } |
| secondary_abi_shared_libraries += [ "//chrome/android:libmonochrome($android_secondary_abi_toolchain)" ] |
| } |
| } |
| } else { |
| srcjar_deps = [ "//chrome/android:libmonochrome__jni_registration($default_toolchain)" ] |
| if (_is_monochrome) { |
| shared_libraries += [ "//chrome/android:libmonochrome" ] |
| } |
| } |
| } else if (!_is_trichrome) { |
| shared_libraries += [ "//chrome/android:libchrome" ] |
| srcjar_deps = |
| [ "//chrome/android:libchrome__jni_registration($default_toolchain)" ] |
| } |
| |
| if (defined(invoker.srcjar_deps)) { |
| srcjar_deps += invoker.srcjar_deps |
| } |
| |
| if (enable_arcore) { |
| # The arcore manifest needs to be merged into the base module because |
| # the Play Store verifies the com.google.ar.core.min_apk_version |
| # meta-data tag is in the base manifest. |
| deps += [ |
| "//third_party/arcore-android-sdk-client:arcore_base_manifest_java", |
| ] |
| |
| # For Trichrome, the primary abi arcore library is added to |
| # TrichromeLibrary.apk, so it's not needed here. |
| if (!_is_trichrome) { |
| _arcore_target = "//third_party/arcore-android-sdk-client:com_google_ar_core_J__unpack_aar" |
| deps += [ _arcore_target ] |
| _libarcore_dir = get_label_info(_arcore_target, "target_out_dir") + |
| "/com_google_ar_core_java/jni" |
| |
| if (android_64bit_target_cpu) { |
| if (_is_64_bit_browser) { |
| loadable_modules += |
| [ "$_libarcore_dir/arm64-v8a/libarcore_sdk_c.so" ] |
| } else { |
| secondary_abi_loadable_modules += |
| [ "$_libarcore_dir/armeabi-v7a/libarcore_sdk_c.so" ] |
| } |
| } else { |
| loadable_modules += |
| [ "$_libarcore_dir/armeabi-v7a/libarcore_sdk_c.so" ] |
| } |
| } |
| } |
| library_always_compress = [] |
| if (defined(invoker.library_always_compress)) { |
| library_always_compress = invoker.library_always_compress |
| } |
| |
| # TODO(agrieve): Use Crashpad trampoline in chrome_public_apk. |
| if (!_is_monochrome && !_is_trichrome) { |
| deps += |
| [ "//components/crash/core/app:chrome_crashpad_handler_named_as_so" ] |
| loadable_modules += [ "$root_out_dir/libchrome_crashpad_handler.so" ] |
| library_always_compress += [ "libchrome_crashpad_handler.so" ] |
| } else if (!_is_trichrome) { |
| # Crashpad trampoline lives in TrichromeLibrary.apk. |
| # https://chromium.googlesource.com/chromium/src/+/main/docs/android_native_libraries.md#Crashpad-Packaging |
| if (_include_primary_abi) { |
| deps += [ |
| "//third_party/crashpad/crashpad/handler:crashpad_handler_trampoline", |
| ] |
| loadable_modules += |
| [ "$root_out_dir/libcrashpad_handler_trampoline.so" ] |
| } |
| if (_include_secondary_abi) { |
| deps += [ "//third_party/crashpad/crashpad/handler:crashpad_handler_trampoline($android_secondary_abi_toolchain)" ] |
| secondary_abi_loadable_modules += |
| [ "$_secondary_out_dir/libcrashpad_handler_trampoline.so" ] |
| } |
| } |
| |
| # The Chromium Linker depends on ASharedMemory_create() introduced in O. |
| use_chromium_linker = chromium_linker_supported && _is_trichrome |
| |
| if (use_chromium_linker) { |
| if (android_64bit_target_cpu && !_is_64_bit_browser) { |
| deps += [ "//base/android/linker:chromium_android_linker($android_secondary_abi_toolchain)" ] |
| secondary_abi_loadable_modules += |
| [ "$_secondary_out_dir/libchromium_android_linker$shlib_extension" ] |
| } else { |
| deps += [ "//base/android/linker:chromium_android_linker" ] |
| loadable_modules += |
| [ "$root_out_dir/libchromium_android_linker$shlib_extension" ] |
| } |
| if (_is_64_bit_browser && build_hwasan_splits) { |
| deps += [ |
| "//base/android/linker:chromium_android_linker($_hwasan_toolchain)", |
| ] |
| _hwasan_outdir = get_label_info(":($_hwasan_toolchain)", "root_out_dir") |
| loadable_modules += |
| [ "$_hwasan_outdir/libchromium_android_linker$shlib_extension" ] |
| } |
| } |
| |
| if (_is_trichrome) { |
| if (android_64bit_target_cpu && !_is_64_bit_browser) { |
| static_library_provider_use_secondary_abi = true |
| } |
| |
| # Include placeholder libraries to make Chrome multiarch in the same way |
| # as Monochrome, even though Chrome only runs with one of the two |
| # bitnesses. This allows the "32-bit" and "64-bit" versions of Chrome to |
| # depend on their respective versions of the shared library APK even |
| # though they're functionally the same. |
| if (_include_primary_abi && loadable_modules == []) { |
| native_lib_placeholders = [ "libplaceholder.so" ] |
| } |
| if (_include_secondary_abi && secondary_abi_loadable_modules == []) { |
| secondary_native_lib_placeholders = [ "libplaceholder.so" ] |
| } |
| } |
| |
| if (_is_test) { |
| deps += [ "//third_party/androidx:androidx_test_runner_java" ] |
| |
| # For EmbeddedTestServer. |
| additional_apks = [ "//net/android:net_test_support_apk" ] |
| if (defined(invoker.additional_apks)) { |
| additional_apks += invoker.additional_apks |
| } |
| } |
| |
| forward_variables_from(invoker, |
| "*", |
| TESTONLY_AND_VISIBILITY + [ |
| "additional_apks", |
| "assert_no_deps", |
| "data_deps", |
| "deps", |
| "loadable_modules", |
| "manifest_package", |
| "proguard_configs", |
| "resources_config_paths", |
| "secondary_abi_loadable_modules", |
| "secondary_abi_shared_libraries", |
| "shared_libraries", |
| "srcjar_deps", |
| "version_code", |
| "version_name", |
| ]) |
| } |
| } |
| |
| # For creating chrome targets without internal customizations. |
| template("chrome_public_apk_or_module_tmpl") { |
| chrome_common_apk_or_module_tmpl(target_name) { |
| add_upstream_only_deps = true |
| forward_variables_from(invoker, TESTONLY_AND_VISIBILITY) |
| forward_variables_from(invoker, "*", TESTONLY_AND_VISIBILITY) |
| } |
| } |
| |
| template("chrome_public_test_apk_tmpl") { |
| chrome_common_apk_or_module_tmpl(target_name) { |
| add_upstream_only_deps = true |
| target_type = "instrumentation_test_apk" |
| forward_variables_from(invoker, TESTONLY_AND_VISIBILITY) |
| forward_variables_from(invoker, "*", TESTONLY_AND_VISIBILITY) |
| } |
| } |