Avi Drissman | 4a6ec7e | 2022-09-08 20:26:46 | [diff] [blame] | 1 | # Copyright 2019 The Chromium Authors |
Clark DuVall | ebd41cb | 2019-12-19 23:14:16 | [diff] [blame] | 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
| 5 | import("//build/config/android/rules.gni") |
| 6 | import("//build/config/locales.gni") |
Sam Maier | fb196b2 | 2022-09-06 17:48:51 | [diff] [blame] | 7 | import("//components/crash/android/silent_java_assert_reporting.gni") |
Clark DuVall | c5f986b | 2020-08-17 20:47:14 | [diff] [blame] | 8 | import("//weblayer/variables.gni") |
Clark DuVall | ebd41cb | 2019-12-19 23:14:16 | [diff] [blame] | 9 | |
| 10 | template("system_webview_bundle") { |
Andrew Grieve | cdcd217b | 2023-03-14 13:45:30 | [diff] [blame] | 11 | _is_trichrome = defined(invoker.is_trichrome) && invoker.is_trichrome |
Clark DuVall | 977485e | 2020-08-20 15:21:00 | [diff] [blame] | 12 | _base_target_name = get_label_info(invoker.base_module_target, "name") |
| 13 | _base_target_gen_dir = |
| 14 | get_label_info(invoker.base_module_target, "target_gen_dir") |
| 15 | _base_module_build_config = |
Peter Wen | d9e1d00 | 2021-07-12 15:36:42 | [diff] [blame] | 16 | "$_base_target_gen_dir/${_base_target_name}.build_config.json" |
Clark DuVall | 977485e | 2020-08-20 15:21:00 | [diff] [blame] | 17 | _rebased_base_module_build_config = |
| 18 | rebase_path(_base_module_build_config, root_build_dir) |
| 19 | _base_module_version_code = |
| 20 | "@FileArg($_rebased_base_module_build_config:deps_info:version_code)" |
Andrew Grieve | cdcd217b | 2023-03-14 13:45:30 | [diff] [blame] | 21 | |
Andrew Grieve | 5d9b90f | 2023-03-16 21:09:47 | [diff] [blame^] | 22 | assert(_is_trichrome == defined(invoker.static_library_provider)) |
Andrew Grieve | cdcd217b | 2023-03-14 13:45:30 | [diff] [blame] | 23 | |
Clark DuVall | c5f986b | 2020-08-17 20:47:14 | [diff] [blame] | 24 | if (webview_includes_weblayer && weblayer_in_split) { |
| 25 | # TODO(crbug.com/1105096): If WebView starts using |
| 26 | # //components/module_installer, it will probably make sense to refactor |
| 27 | # chrome_feature_module() to be used here. |
Clark DuVall | c5f986b | 2020-08-17 20:47:14 | [diff] [blame] | 28 | _base_module_build_config_target = |
| 29 | "${invoker.base_module_target}$build_config_target_suffix" |
Clark DuVall | c5f986b | 2020-08-17 20:47:14 | [diff] [blame] | 30 | _weblayer_module_target = "${target_name}__weblayer_bundle_module" |
| 31 | _weblayer_module_desc = { |
| 32 | name = "weblayer" |
| 33 | module_target = ":${_weblayer_module_target}" |
| 34 | } |
Clark DuVall | 6206881 | 2020-09-15 03:18:31 | [diff] [blame] | 35 | |
| 36 | # TODO(crbug.com/1105096): This target is needed to add all WebLayer |
| 37 | # resources to the base module because of bugs with shared resources in |
| 38 | # splits. |
| 39 | android_resources("${_base_target_name}__all_weblayer_resources") { |
| 40 | recursive_resource_deps = true |
| 41 | deps = [ "//weblayer/browser/java" ] |
| 42 | if (defined(invoker.weblayer_deps)) { |
| 43 | deps += invoker.weblayer_deps |
| 44 | } |
| 45 | } |
| 46 | |
Clark DuVall | c5f986b | 2020-08-17 20:47:14 | [diff] [blame] | 47 | android_app_bundle_module(_weblayer_module_target) { |
| 48 | forward_variables_from(invoker, |
| 49 | [ |
| 50 | "base_module_target", |
| 51 | "min_sdk_version", |
Clark DuVall | c5f986b | 2020-08-17 20:47:14 | [diff] [blame] | 52 | ]) |
| 53 | android_manifest = "//weblayer/browser/java/AndroidManifest.xml" |
Clark DuVall | 9158c02 | 2020-09-17 17:49:30 | [diff] [blame] | 54 | |
| 55 | # The manifest depends on the package name from the base build config. |
| 56 | android_manifest_dep = _base_module_build_config_target |
Clark DuVall | c5f986b | 2020-08-17 20:47:14 | [diff] [blame] | 57 | deps = [ |
| 58 | "//weblayer/browser/java", |
| 59 | _base_module_build_config_target, |
| 60 | ] |
| 61 | if (defined(invoker.weblayer_deps)) { |
| 62 | deps += invoker.weblayer_deps |
| 63 | } |
Trevor Perrier | c8f7da5b | 2022-02-08 17:29:46 | [diff] [blame] | 64 | aapt_locale_allowlist = platform_pak_locales |
Clark DuVall | c5f986b | 2020-08-17 20:47:14 | [diff] [blame] | 65 | proguard_enabled = !is_java_debug |
Sam Maier | 57b7afeb5 | 2023-01-10 16:31:44 | [diff] [blame] | 66 | module_name = "weblayer" |
Clark DuVall | c5f986b | 2020-08-17 20:47:14 | [diff] [blame] | 67 | package_id = 126 |
| 68 | version_name = |
| 69 | "@FileArg($_rebased_base_module_build_config:deps_info:version_name)" |
Clark DuVall | 977485e | 2020-08-20 15:21:00 | [diff] [blame] | 70 | version_code = _base_module_version_code |
Clark DuVall | c5f986b | 2020-08-17 20:47:14 | [diff] [blame] | 71 | manifest_package = |
| 72 | "@FileArg($_rebased_base_module_build_config:deps_info:package_name)" |
Andrew Grieve | cdcd217b | 2023-03-14 13:45:30 | [diff] [blame] | 73 | if (!defined(min_sdk_version) && _is_trichrome) { |
| 74 | min_sdk_version = 29 |
| 75 | } |
Sam Maier | fb196b2 | 2022-09-06 17:48:51 | [diff] [blame] | 76 | |
| 77 | if (enable_silent_java_assert_reporting) { |
| 78 | custom_assertion_handler = crash_reporting_assertion_handler |
| 79 | } |
Clark DuVall | c5f986b | 2020-08-17 20:47:14 | [diff] [blame] | 80 | } |
| 81 | } |
| 82 | |
Clark DuVall | ebd41cb | 2019-12-19 23:14:16 | [diff] [blame] | 83 | android_app_bundle(target_name) { |
| 84 | command_line_flags_file = "webview-command-line" |
| 85 | proguard_enabled = !is_java_debug |
| 86 | enable_language_splits = true |
Andrew Grieve | cdcd217b | 2023-03-14 13:45:30 | [diff] [blame] | 87 | if (_is_trichrome) { |
| 88 | min_sdk_version = 29 |
| 89 | } else { |
| 90 | compress_shared_libraries = true |
| 91 | } |
Clark DuVall | c5f986b | 2020-08-17 20:47:14 | [diff] [blame] | 92 | if (webview_includes_weblayer && weblayer_in_split) { |
| 93 | extra_modules = [ _weblayer_module_desc ] |
| 94 | } |
Trevor Perrier | c8f7da5b | 2022-02-08 17:29:46 | [diff] [blame] | 95 | system_image_locale_allowlist = platform_pak_locales |
Christopher Grant | 83e35a4 | 2020-01-06 16:06:08 | [diff] [blame] | 96 | is_multi_abi = |
| 97 | android_64bit_target_cpu && (!defined(invoker.include_64_bit_webview) || |
| 98 | invoker.include_64_bit_webview) && |
| 99 | (!defined(invoker.include_32_bit_webview) || |
| 100 | invoker.include_32_bit_webview) |
Clark DuVall | ebd41cb | 2019-12-19 23:14:16 | [diff] [blame] | 101 | |
| 102 | if (!defined(proguard_android_sdk_dep)) { |
| 103 | proguard_android_sdk_dep = webview_framework_dep |
| 104 | } |
| 105 | |
Sam Maier | fb196b2 | 2022-09-06 17:48:51 | [diff] [blame] | 106 | if (enable_silent_java_assert_reporting) { |
| 107 | custom_assertion_handler = crash_reporting_assertion_handler |
| 108 | } |
| 109 | |
Fergal Daly | ebb8059 | 2022-03-24 03:30:48 | [diff] [blame] | 110 | # For this to be respected, it must also be set on the base module target. |
| 111 | strip_unused_resources = is_official_build |
| 112 | |
Clark DuVall | ebd41cb | 2019-12-19 23:14:16 | [diff] [blame] | 113 | forward_variables_from(invoker, "*") |
| 114 | } |
| 115 | } |