1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 import("//android_webview/variables.gni")
6 import("//base/android/resource_exclusions.gni")
7 import("//build/config/android/config.gni")
8 import("//build/config/android/rules.gni")
9 import("//build/config/locales.gni")
10 import("//build/util/version.gni")
11 import("//chrome/android/trichrome.gni")
12 import("//tools/v8_context_snapshot/v8_context_snapshot.gni")
13 import("//weblayer/variables.gni")
14 import("//weblayer/weblayer_resource_exclusions.gni")
17 # Android package name to use when compiling the system_webview_apk and
18 # trichrome_webview_apk targets. This should be used if the Android build
19 # on which you are going to install WebView is configured to load a
20 # different package name than the default used in AOSP.
21 system_webview_package_name = "com.android.webview"
23 # Whether to enable standalone and trichrome WebView bundle build targets.
24 enable_webview_bundles = true
27 template("system_webview_apk_or_module_tmpl") {
28 if (!defined(invoker.target_type)) {
29 _is_bundle_module = false
30 _target_type = "android_apk"
32 _is_bundle_module = invoker.target_type == "android_app_bundle_module"
33 _target_type = invoker.target_type
35 _exclude_weblayer_java =
36 defined(invoker.exclude_weblayer_java) && invoker.exclude_weblayer_java
37 target(_target_type, target_name) {
38 forward_variables_from(invoker,
42 "include_32_bit_webview",
43 "include_64_bit_webview",
47 "//android_webview:locale_pak_assets",
48 "//android_webview:pak_file_assets",
51 # If the R SDK isn't public yet, include the downstream code to support R.
52 if (!public_android_sdk && android_sdk_release == "r") {
53 deps += [ "//clank/android_webview/next:r_sdk_java" ]
56 if (_exclude_weblayer_java) {
57 deps += [ "//android_webview:android_webview_no_weblayer_java" ]
59 deps += [ "//android_webview:android_webview_java" ]
61 # Resources from this target will be kept in the base bundle module
62 # instead of in language splits.
63 if (!defined(invoker.shared_resources_allowlist_target)) {
64 shared_resources_allowlist_target =
65 "//android_webview:system_webview_no_weblayer_apk"
69 target_sdk_version = android_sdk_version
70 product_config_java_packages = [ webview_product_config_java_package ]
72 if (webview_includes_weblayer) {
73 if (_is_bundle_module) {
74 deps += [ "//weblayer:bundle_locale_pak_assets" ]
76 deps += [ "//weblayer:locale_pak_assets" ]
78 product_config_java_packages += [ weblayer_product_config_java_package ]
81 if (!defined(alternative_android_sdk_dep)) {
82 alternative_android_sdk_dep = webview_framework_dep
85 if (webview_devui_show_icon) {
86 deps += [ "//android_webview/nonembedded:devui_launcher_icon_resources" ]
89 _use_trichrome_library =
90 defined(use_trichrome_library) && use_trichrome_library
92 _use_trichrome_library == defined(invoker.static_library_provider),
93 "If trichrome library is used, static_library_provider must be set " +
94 "so that a dep can be added on the library APK.")
96 # Pure 32-bit implies a 32-bit only Webview built on a 64-bit configuration.
98 android_64bit_target_cpu && defined(invoker.include_64_bit_webview) &&
99 !invoker.include_64_bit_webview
100 not_needed([ "_pure_32_bit" ])
102 # Flag whether additional deps and libs should be included for each ABI.
103 _include_primary_support = false
104 _include_secondary_support = false
106 if (!_use_trichrome_library) {
107 shared_resources = true
109 if (!android_64bit_target_cpu || !_pure_32_bit) {
110 shared_libraries = [ "//android_webview:libwebviewchromium" ]
111 _include_primary_support = true
113 if (android_64bit_target_cpu) {
114 secondary_abi_shared_libraries = [ "//android_webview:libwebviewchromium($android_secondary_abi_toolchain)" ]
115 _include_secondary_support = true
117 deps += [ "//third_party/icu:icu_assets" ]
119 uncompress_shared_libraries = true
120 app_as_shared_lib = true
122 # Include placeholder libraries to ensure we are treated as the desired
124 if (android_64bit_target_cpu) {
125 if (invoker.is_64_bit_browser) {
126 native_lib_placeholders = [ "libdummy.so" ]
127 if (invoker.include_32_bit_webview) {
128 secondary_abi_shared_libraries = [ "//android_webview:monochrome_64($android_secondary_abi_toolchain)" ]
129 _include_secondary_support = true
132 if (invoker.include_64_bit_webview) {
133 shared_libraries = [ "//android_webview:monochrome" ]
134 _include_primary_support = true
136 secondary_native_lib_placeholders = [ "libdummy.so" ]
139 native_lib_placeholders = [ "libdummy.so" ]
143 if (_include_primary_support) {
145 "//android_webview:webview_primary_abi_assets",
146 "//third_party/crashpad/crashpad/handler:crashpad_handler_trampoline",
148 loadable_modules = [ "$root_out_dir/libcrashpad_handler_trampoline.so" ]
149 if (webview_includes_weblayer) {
150 deps += [ "//base/android/linker:chromium_android_linker" ]
152 [ "$root_out_dir/libchromium_android_linker$shlib_extension" ]
155 if (_include_secondary_support) {
156 _trampoline = "//third_party/crashpad/crashpad/handler:crashpad_handler_trampoline($android_secondary_abi_toolchain)"
158 "//android_webview:webview_secondary_abi_assets",
161 _secondary_out_dir = get_label_info(_trampoline, "root_out_dir")
162 secondary_abi_loadable_modules =
163 [ "$_secondary_out_dir/libcrashpad_handler_trampoline.so" ]
164 if (webview_includes_weblayer) {
165 deps += [ "//base/android/linker:chromium_android_linker($android_secondary_abi_toolchain)" ]
166 secondary_abi_loadable_modules +=
167 [ "$_secondary_out_dir/libchromium_android_linker$shlib_extension" ]
171 if (!_use_trichrome_library || android_64bit_target_cpu) {
172 # 32-bit TrichromeWebView doesn't have a native library, so only do this
174 native_lib_version_rule = "//build/util:chrome_version_json"
176 rebase_path("$root_gen_dir/CHROME_VERSION.json", root_out_dir)
177 native_lib_version_arg = "@FileArg($_native_lib_file:full-quoted)"
180 aapt_locale_allowlist = locales
182 resource_exclusion_regex = common_resource_exclusion_regex
183 resource_exclusion_exceptions = common_resource_exclusion_exceptions
185 if (webview_includes_weblayer) {
186 resource_values_filter_rules = weblayer_resource_values_filter_rules
187 resource_exclusion_exceptions += weblayer_resource_exclusion_exceptions
189 # Note: WebLayer's resource exclusion regex deliberately does not start
191 resource_exclusion_regex += "|" + weblayer_resource_exclusion_regex
194 if (!_is_bundle_module) {
195 # Used as an additional apk in test scripts.
196 never_incremental = true
197 command_line_flags_file = "webview-command-line"
200 if (!is_java_debug) {
201 proguard_enabled = true
202 if (!defined(proguard_configs)) {
203 proguard_configs = []
205 proguard_configs += [
206 "//android_webview/nonembedded/java/proguard.flags",
207 "//base/android/proguard/chromium_apk.flags",
208 "//base/android/proguard/chromium_code.flags",
210 if (enable_proguard_obfuscation) {
212 [ "//base/android/proguard/enable_obfuscation.flags" ]
215 [ "//base/android/proguard/disable_all_obfuscation.flags" ]
220 if (!defined(version_code)) {
221 if (_use_trichrome_library) {
222 if (android_64bit_target_cpu) {
223 if (invoker.is_64_bit_browser) {
224 if (invoker.include_32_bit_webview) {
225 version_code = trichrome_64_32_version_code
227 version_code = trichrome_64_version_code
230 if (invoker.include_64_bit_webview) {
231 version_code = trichrome_32_64_version_code
233 version_code = trichrome_32_version_code
237 version_code = trichrome_version_code
240 if (android_channel == "dev") {
242 version_code = webview_32_dev_version_code
244 version_code = webview_dev_version_code
246 } else if (android_channel == "beta") {
248 version_code = webview_32_beta_version_code
250 version_code = webview_beta_version_code
254 version_code = webview_32_stable_version_code
256 version_code = webview_stable_version_code
261 if (!defined(version_name)) {
262 version_name = chrome_version_name