forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrichrome.gni
257 lines (230 loc) · 9.34 KB
/
trichrome.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
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/android/abi.gni")
import("//build/config/android/config.gni")
import("//build/config/android/rules.gni")
import("//build/util/version.gni")
import("//chrome/android/chrome_public_apk_tmpl.gni")
import("//chrome/android/modules/buildflags.gni")
import("//device/vr/buildflags/buildflags.gni")
if (!defined(default_trichrome_certdigest)) {
default_trichrome_certdigest =
"32a2fc74d731105859e5a85df16d95f102d85b22099b8064c5d8915c61dad1e0"
}
declare_args() {
# The package name for the Trichrome static shared library on Android.
trichrome_library_package = "org.chromium.trichromelibrary"
# The SHA256 certificate digest for the Trichrome static shared library on
# Android. You can use "apksigner verify --print-certs" on the signed APK to
# calculate the correct digest.
trichrome_certdigest = default_trichrome_certdigest
# WIP: Enable synchronized proguard for Trichrome. (http://crbug.com/901465)
# Only affects trichrome targets when !is_java_debug.
enable_trichrome_synchronized_proguard = false
}
trichrome_jinja_variables = [
"min_sdk_version=29",
"target_sdk_version=$android_sdk_version",
"trichrome_library=$trichrome_library_package",
"trichrome_certdigest=$trichrome_certdigest",
"use32bitAbi=android:use32bitAbi=\"true\"",
"zygote_preload_class=org.chromium.chrome.app.TrichromeZygotePreload",
]
trichrome_synchronized_proguard =
enable_trichrome_synchronized_proguard && !is_java_debug
template("trichrome_library_apk_tmpl") {
android_apk(target_name) {
forward_variables_from(invoker,
[
"android_manifest",
"android_manifest_dep",
"apk_name",
"expected_android_manifest",
"expected_libs_and_assets",
"min_sdk_version",
"target_sdk_version",
])
# TODO(torne): since there's no real java code in the library right now,
# leave out the build hooks and let them get compiled into each APK. Later
# this should probably be in the library.
no_build_hooks = true
alternative_android_sdk_dep = webview_framework_dep
if (trichrome_synchronized_proguard) {
if (defined(invoker.webview_target) && defined(invoker.chrome_target)) {
shared_resources_allowlist_locales = locales
static_library_dependent_targets = [
{
name = invoker.webview_target
is_resource_ids_provider = true
},
{
name = invoker.chrome_target
is_resource_ids_provider = false
},
]
}
} else {
# TODO(crbug.com/901465): Remove r_java_root_package_name once shared
# Java code is moved to the shared library even in debug.
r_java_root_package_name = "trichrome_lib"
app_as_shared_lib = true
}
# No support for this has been added, also not supported by test runner
# since trichrome library is used in "additional_apks" in the trichrome
# bundle smoke tests.
never_incremental = true
uncompress_shared_libraries = true
uncompress_dex = true
version_name = chrome_version_name
if (android_64bit_target_cpu) {
if (invoker.is_64_bit_browser) {
if (invoker.include_32_bit_webview) {
version_code = trichrome_64_32_version_code
} else {
version_code = trichrome_64_version_code
}
} else {
if (invoker.include_64_bit_webview) {
version_code = trichrome_32_64_version_code
} else {
version_code = trichrome_32_version_code
}
}
} else {
version_code = trichrome_version_code
}
min_sdk_version = 29
if (trichrome_synchronized_proguard) {
product_version_resources_dep =
"//chrome/android:product_version_resources"
} else {
generate_buildconfig_java = false
}
# TODO(torne): using icon_resources just to get a temporary icon
deps = [
"//android_webview/nonembedded:icon_resources",
"//third_party/icu:icu_assets",
]
# Flag whether additional deps and libs should be included for each ABI.
_include_primary_support = false
_include_secondary_support = false
if (android_64bit_target_cpu) {
# Include the actual browser-bitness libmonochrome library, dependencies
# (crashpad and linker), and an opposite-bitness placeholder library to
# ensure that the library is treated as multiarch and gets its Java code
# precompiled for both architectures.
if (invoker.is_64_bit_browser) {
shared_libraries = [ "//chrome/android:libmonochrome_64" ]
_include_primary_support = true
if (invoker.include_32_bit_webview) {
secondary_native_lib_placeholders = [ "libdummy.so" ]
}
} else {
secondary_abi_shared_libraries =
[ "//chrome/android:monochrome_secondary_abi_lib" ]
_include_secondary_support = true
if (invoker.include_64_bit_webview) {
native_lib_placeholders = [ "libdummy.so" ]
}
}
} else {
shared_libraries = [ "//chrome/android:libmonochrome" ]
_include_primary_support = true
}
if (_include_primary_support) {
deps += [
"//chrome/android:chrome_public_v8_assets",
"//third_party/crashpad/crashpad/handler:crashpad_handler_trampoline",
]
loadable_modules = [ "$root_out_dir/libcrashpad_handler_trampoline.so" ]
}
if (_include_secondary_support) {
_trampoline =
"//third_party/crashpad/crashpad/handler:" +
"crashpad_handler_trampoline($android_secondary_abi_toolchain)"
deps += [
"//android_webview:v8_snapshot_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 (enable_arcore) {
_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" ])
_arcore_extra_deps = [ "//third_party/arcore-android-sdk-client:com_google_ar_core_J__unpack_aar" ]
not_needed([ "_arcore_extra_deps" ])
if (_include_primary_support) {
loadable_modules +=
[ "$_libarcore_dir/$android_app_abi/libarcore_sdk_c.so" ]
deps += _arcore_extra_deps
}
if (_include_secondary_support) {
if (enable_arcore) {
secondary_abi_loadable_modules += [
"$_libarcore_dir/$android_app_secondary_abi/libarcore_sdk_c.so",
]
deps += _arcore_extra_deps
}
}
}
# http://crbug.com/1042107.
if (is_component_build) {
if (android_64bit_target_cpu && invoker.is_64_bit_browser) {
main_component_library = "libmonochrome_64.cr.so"
} else {
main_component_library = "libmonochrome.cr.so"
}
}
if (!is_java_debug) {
proguard_enabled = true
proguard_configs = [
"//base/android/proguard/chromium_apk.flags",
"//base/android/proguard/chromium_code.flags",
"//chrome/android/proguard/trichrome.flags",
]
if (trichrome_synchronized_proguard) {
proguard_configs += [
"//chrome/android/proguard/static_library_dex_reference_workarounds.flags",
"//base/android/proguard/enable_obfuscation.flags",
]
} else {
# Disabling all obfuscation for the Trichrome library as a temporary
# workaround for crbug.com/1012842. There were naming conflicts between
# Library and Chrome, since each Proguard run doesn't know about the
# other, and thus handed out the first names (a, b, c) to both.
proguard_enable_obfuscation = false
}
}
deps += [ "//chrome/android:trichrome_dummy_resources" ]
}
}
# An .ssargs file is a text file to specify multiple input files with respective
# parameters, and is used by SuperSize-archive to create multi-container .size
# files. This is used to support SuperSize on Trichrome.
template("write_ssargs_trichrome") {
if (target_cpu == "arm64" || target_cpu == "x64") {
# Ignore secondary abi libmonochrome in library apk in favor of primary one
# in TrichromeWebView.
_library_args = " --no-native"
} else {
_library_args = ""
}
_extra_args = " --abi-filter $android_app_abi"
# Base names (i.e., no full path) are used because .ssargs files specifies
# files using paths relative to itself. It is expected for |ssargs_path| to
# be in the same directory as all Trichrome files whose sizes are measured
# by SuperSize.
_lines = [
"# Written by build target \"${target_name}.\"",
"Library -f ${invoker.trichrome_library_basename}$_extra_args$_library_args",
"# Add --no-native to Chrome as workaround for crbug.com/1103271.",
"Chrome -f ${invoker.trichrome_chrome_basename}$_extra_args --no-native",
"WebView -f ${invoker.trichrome_webview_basename}$_extra_args",
]
write_file(invoker.ssargs_path, _lines)
}