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