forked from Pissandshittium/pissandshittium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsystem_webview_apk_tmpl.gni
320 lines (282 loc) · 12.4 KB
/
system_webview_apk_tmpl.gni
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
# 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/resource_exclusions.gni")
import("//build/config/android/abi.gni")
import("//build/config/android/config.gni")
import("//build/config/android/rules.gni")
import("//build/config/chrome_build.gni")
import("//build/config/locales.gni")
import("//chrome/android/trichrome.gni")
import("//chrome/version.gni")
import("//components/crash/android/silent_java_assert_reporting.gni")
import("//device/vr/buildflags/buildflags.gni")
import("//tools/v8_context_snapshot/v8_context_snapshot.gni")
import("//weblayer/variables.gni")
import("//weblayer/weblayer_resource_exclusions.gni")
declare_args() {
# Android package name to use when compiling the system_webview_apk and
# trichrome_webview_apk targets. This should be used if the Android build
# on which you are going to install WebView is configured to load a
# different package name than the default used in AOSP.
system_webview_package_name = "com.android.webview"
# Whether to enable standalone and trichrome WebView bundle build targets.
enable_webview_bundles = true
}
template("system_webview_apk_or_module_tmpl") {
if (defined(invoker.target_type)) {
_target_type = invoker.target_type
} else {
_target_type = "android_apk"
}
target(_target_type, target_name) {
forward_variables_from(invoker, TESTONLY_AND_VISIBILITY)
# Do not forward variables used only by this template so that code below
# needs to use "invoker" to make it clear where variables are coming from.
forward_variables_from(invoker,
"*",
TESTONLY_AND_VISIBILITY + [
"exclude_weblayer_java",
"is_64_bit_browser",
"is_trichrome",
"include_32_bit_webview",
"include_64_bit_webview",
"weblayer_product_config_java_package",
"weblayer_in_split",
"webview_framework_dep",
"webview_product_config_java_package",
"webview_includes_weblayer",
"webview_devui_show_icon",
"use_stable_package_name_for_trichrome",
])
_is_bundle_module = _target_type == "android_app_bundle_module"
_webview_includes_weblayer = invoker.webview_includes_weblayer
_exclude_weblayer_java =
defined(invoker.exclude_weblayer_java) && invoker.exclude_weblayer_java
_omit_dex = defined(invoker.omit_dex) && invoker.omit_dex
if (defined(expected_android_manifest)) {
expected_android_manifest_version_code_offset = chrome_version_code
expected_android_manifest_library_version_offset = chrome_version_code
}
deps += [
"//android_webview:locale_pak_assets",
"//android_webview:pak_file_assets",
]
if (_exclude_weblayer_java) {
deps += [ "//android_webview:android_webview_no_weblayer_java" ]
} else {
if (_is_bundle_module && invoker.weblayer_in_split &&
_webview_includes_weblayer) {
deps += [
# TODO(crbug.com/1105096): WebLayer resources are added to the base
# module for now because of bugs with shared resources in splits.
":${target_name}__all_weblayer_resources",
"//android_webview:android_webview_no_weblayer_java",
"//weblayer/browser/java:base_module_java",
]
} else {
deps += [ "//android_webview:android_webview_java" ]
}
# Resources from this target will be kept in the base bundle module
# instead of in language splits.
if (!defined(shared_resources_allowlist_target)) {
shared_resources_allowlist_target =
"//android_webview:system_webview_no_weblayer_apk"
}
}
if (!_omit_dex) {
product_config_java_packages =
[ invoker.webview_product_config_java_package ]
if (allow_jni_multiplexing) {
enable_jni_multiplexing = true
}
}
if (_webview_includes_weblayer) {
if (_is_bundle_module) {
deps += [ "//weblayer:bundle_locale_pak_assets" ]
} else {
deps += [ "//weblayer:locale_pak_assets" ]
}
if (!_omit_dex) {
product_config_java_packages +=
[ invoker.weblayer_product_config_java_package ]
}
}
if (!defined(alternative_android_sdk_dep)) {
alternative_android_sdk_dep = invoker.webview_framework_dep
}
# We can't include an icon for anything with the Stable channel package name
# because it confuses work profiles. We check
# use_stable_package_name_for_trichrome here instead of where
# webview_devui_show_icon is assigned to avoid a circular dependency
# between //android_webview/variables.gni and
# //chrome/android/trichrome.gni.
if (invoker.webview_devui_show_icon &&
!invoker.use_stable_package_name_for_trichrome) {
deps += [ "//android_webview/nonembedded:devui_launcher_icon_resources" ]
}
_is_trichrome = defined(invoker.is_trichrome) && invoker.is_trichrome
assert(
_is_trichrome == defined(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.")
_include_32_bit_webview = !defined(invoker.include_32_bit_webview) ||
invoker.include_32_bit_webview
_include_64_bit_webview =
android_64bit_target_cpu && (!defined(invoker.include_64_bit_webview) ||
invoker.include_64_bit_webview)
if (_is_trichrome) {
_is_64_bit_browser = android_64bit_target_cpu && invoker.is_64_bit_browser
}
not_needed(invoker,
[
"include_32_bit_webview",
"include_64_bit_webview",
])
not_needed([
"_include_32_bit_webview",
"_include_64_bit_webview",
"_is_64_bit_browser",
])
# Flag whether additional deps and libs should be included for each ABI.
_include_primary_support = false
_include_secondary_support = false
if (!_is_trichrome) {
shared_resources = true
if ((!android_64bit_target_cpu && _include_32_bit_webview) ||
(android_64bit_target_cpu && _include_64_bit_webview)) {
shared_libraries = [ "//android_webview:libwebviewchromium" ]
_include_primary_support = true
}
if (android_64bit_target_cpu && _include_32_bit_webview) {
secondary_abi_shared_libraries = [ "//android_webview:libwebviewchromium($android_secondary_abi_toolchain)" ]
_include_secondary_support = true
}
deps += [ "//third_party/icu:icu_assets" ]
} else {
app_as_shared_lib = true
# Include placeholder libraries to ensure we are treated as the desired
# architecture.
if (android_64bit_target_cpu) {
if (_is_64_bit_browser) {
native_lib_placeholders = [ "libdummy.so" ]
if (_include_32_bit_webview) {
secondary_abi_shared_libraries = [ "//android_webview:monochrome_64($android_secondary_abi_toolchain)" ]
_include_secondary_support = true
}
} else {
if (_include_64_bit_webview) {
shared_libraries = [ "//android_webview:monochrome" ]
_include_primary_support = true
}
secondary_native_lib_placeholders = [ "libdummy.so" ]
static_library_provider_use_secondary_abi = true
}
# http://crbug.com/1042107.
if (is_component_build) {
if (_is_64_bit_browser) {
main_component_library = "libmonochrome_64.cr.so"
} else {
main_component_library = "libmonochrome.cr.so"
}
}
} else {
native_lib_placeholders = [ "libdummy.so" ]
}
}
_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" ])
_include_arcore = _webview_includes_weblayer && enable_arcore &&
!_exclude_weblayer_java &&
(_include_secondary_support || _include_primary_support)
if (_include_primary_support) {
deps += [
"//android_webview:webview_primary_abi_assets",
"//third_party/crashpad/crashpad/handler:crashpad_handler_trampoline",
]
loadable_modules = [ "$root_out_dir/libcrashpad_handler_trampoline.so" ]
if (_webview_includes_weblayer) {
deps += [ "//base/android/linker:chromium_android_linker" ]
loadable_modules +=
[ "$root_out_dir/libchromium_android_linker$shlib_extension" ]
}
if (_include_arcore) {
loadable_modules +=
[ "$_libarcore_dir/$android_app_abi/libarcore_sdk_c.so" ]
}
}
if (_include_secondary_support) {
_trampoline = "//third_party/crashpad/crashpad/handler:crashpad_handler_trampoline($android_secondary_abi_toolchain)"
deps += [
"//android_webview:webview_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 (_webview_includes_weblayer) {
deps += [ "//base/android/linker:chromium_android_linker($android_secondary_abi_toolchain)" ]
secondary_abi_loadable_modules +=
[ "$_secondary_out_dir/libchromium_android_linker$shlib_extension" ]
}
if (_include_arcore) {
secondary_abi_loadable_modules +=
[ "$_libarcore_dir/$android_app_secondary_abi/libarcore_sdk_c.so" ]
}
}
if (_include_arcore) {
deps += [ "//third_party/arcore-android-sdk-client:com_google_ar_core_J__unpack_aar" ]
}
aapt_locale_allowlist = platform_pak_locales
resource_exclusion_regex = common_resource_exclusion_regex
resource_exclusion_exceptions = common_resource_exclusion_exceptions
if (_webview_includes_weblayer) {
resource_values_filter_rules = weblayer_resource_values_filter_rules
resource_exclusion_exceptions += weblayer_resource_exclusion_exceptions
# Note: WebLayer's resource exclusion regex deliberately does not start
# with "|".
resource_exclusion_regex += "|" + weblayer_resource_exclusion_regex
}
# 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_module) {
# Removes metadata needed for Resources.getIdentifier("resource_name").
strip_resource_names = !is_java_debug
# Shortens resource file names in apk eg: res/drawable/button.xml -> res/a.xml
short_resource_paths = !is_java_debug
# 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
}
if (!_is_bundle_module) {
# Used as an additional apk in test scripts.
never_incremental = true
command_line_flags_file = "webview-command-line"
}
if (!is_java_debug && !_omit_dex) {
proguard_enabled = true
if (!defined(proguard_configs)) {
proguard_configs = []
}
proguard_configs +=
[ "//android_webview/nonembedded/java/proguard.flags" ]
png_to_webp = true
}
if (enable_silent_java_assert_reporting && !_omit_dex) {
custom_assertion_handler = crash_reporting_assertion_handler
}
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 {
version_code = WEBVIEW_VERSION_MAP["${android_64bit_target_cpu}_${_include_64_bit_webview}_${_include_32_bit_webview}"]
}
version_name = chrome_version_name
}
}