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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
|
# Copyright 2014 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.
# This file contains common system config stuff for the Android build.
if (is_android) {
import("//build_overrides/build.gni")
has_chrome_android_internal =
exec_script("//build/dir_exists.py",
[ rebase_path("//clank", root_build_dir) ],
"string") == "True"
# We are using a separate declare_args block for only this argument so that
# we can decide if we have to pull in definitions from the internal config
# early.
declare_args() {
# Enables using the internal Chrome for Android repository. The default
# value depends on whether the repository is available, and if it's not but
# this argument is manually set to True, the generation will fail.
# The main purpose of this argument is to avoid having to maintain 2
# repositories to support both public only and internal builds.
enable_chrome_android_internal = has_chrome_android_internal
}
if (enable_chrome_android_internal) {
import("//clank/config.gni")
}
if (!defined(extra_chrome_shared_library_configs)) {
extra_chrome_shared_library_configs = []
}
if (!defined(default_android_ndk_root)) {
default_android_ndk_root = "//third_party/android_tools/ndk"
default_android_ndk_version = "r12b"
default_android_ndk_major_version = 12
} else {
assert(defined(default_android_ndk_version))
assert(defined(default_android_ndk_major_version))
}
if (!defined(default_android_sdk_root)) {
default_android_sdk_root = "//third_party/android_tools/sdk"
default_android_sdk_version = "25"
default_android_sdk_build_tools_version = "25.0.2"
}
if (!defined(default_lint_android_sdk_root)) {
# Purposefully repeated so that downstream can change
# default_android_sdk_root without changing lint version.
default_lint_android_sdk_root = "//third_party/android_tools/sdk"
default_lint_android_sdk_version = "25"
}
if (!defined(default_extras_android_sdk_root)) {
# Purposefully repeated so that downstream can change
# default_android_sdk_root without changing where we load the SDK extras
# from. (Google Play services, etc.)
default_extras_android_sdk_root = "//third_party/android_tools/sdk"
}
if (!defined(default_android_keystore_path)) {
default_android_keystore_path =
"//build/android/ant/chromium-debug.keystore"
default_android_keystore_name = "chromiumdebugkey"
default_android_keystore_password = "chromium"
}
# TODO(paulmiller): Remove; superseded by google_play_services_package.
if (!defined(google_play_services_library)) {
google_play_services_library =
"//third_party/android_tools:google_play_services_default_java"
}
# TODO(paulmiller): Remove; superseded by google_play_services_package.
if (!defined(google_play_services_resources)) {
google_play_services_resources =
"//third_party/android_tools:google_play_services_default_resources"
}
# google_play_services_package contains the path where individual client
# targets (e.g. google_play_services_base_java) are located.
if (!defined(google_play_services_package)) {
google_play_services_package = "//third_party/android_tools"
}
webview_public_framework_jar =
"//third_party/android_platform/webview/frameworks_7.1.1_r28.jar"
if (!defined(webview_framework_jar)) {
webview_framework_jar = webview_public_framework_jar
}
declare_args() {
android_ndk_root = default_android_ndk_root
android_ndk_version = default_android_ndk_version
android_ndk_major_version = default_android_ndk_major_version
android_sdk_root = default_android_sdk_root
android_sdk_version = default_android_sdk_version
android_sdk_build_tools_version = default_android_sdk_build_tools_version
lint_android_sdk_root = default_lint_android_sdk_root
lint_android_sdk_version = default_lint_android_sdk_version
# Libc++ library directory. Override to use a custom libc++ binary.
android_libcpp_lib_dir = ""
# Android versionCode for android_apk()s that don't expclitly set one.
android_default_version_code = "1"
# Android versionName for android_apk()s that don't expclitly set one.
android_default_version_name = "Developer Build"
# The path to the keystore to use for signing builds.
android_keystore_path = default_android_keystore_path
# The name of the keystore to use for signing builds.
android_keystore_name = default_android_keystore_name
# The password for the keystore to use for signing builds.
android_keystore_password = default_android_keystore_password
# Set to true to run findbugs on JAR targets.
run_findbugs = false
# Set to true to enable verbose findbugs logging. This does nothing if
# run_findbugs is false.
findbugs_verbose = false
# Enables verbose proguard output (summaries and unfiltered output).
proguard_verbose = false
# Java debug on Android. Having this on enables multidexing, and turning it
# off will enable proguard.
is_java_debug = is_debug
# Set to true to enable the Errorprone compiler
use_errorprone_java_compiler = false
# Enables EMMA Java code coverage. Instruments classes during build to
# produce .ec files during runtime
emma_coverage = false
# EMMA filter string consisting of a list of inclusion/exclusion patterns
# separated with whitespace and/or comma. Only has effect if
# emma_coverage==true
emma_filter = ""
# Disables process isolation when building _incremental targets.
# Required for Android M+ due to SELinux policies (stronger sandboxing).
disable_incremental_isolated_processes = false
# Speeds up incremental compiles by compiling only changed files.
enable_incremental_javac = false
# Adds intrumentation to each function. Writes a file with the order that
# functions are called at startup.
use_order_profiling = false
# Builds secondary abi for APKs, supports build 32-bit arch as secondary
# abi in 64-bit Monochrome and WebView.
build_apk_secondary_abi = true
# Enables java8 language features (via retrolambda).
# work-in-progress (http://crbug.com/642600)
use_java8 = false
# Build incremental targets whenever possible.
# Ex. with this arg set to true, the chrome_public_apk target result in
# chrome_public_apk_incremental being built.
incremental_apk_by_default = false
}
# We need a second declare_args block to make sure we are using the overridden
# value of the arguments set above.
declare_args() {
# Speed up dexing using dx --incremental.
enable_incremental_dx = is_java_debug
}
# Neither of these should ever be used for release builds since they are
# somewhat experimental and dx --incremental is known to not produce
# byte-for-byte identical output.
assert(!(enable_incremental_dx && !is_java_debug))
assert(!(enable_incremental_javac && !is_java_debug))
# Host stuff -----------------------------------------------------------------
# Defines the name the Android build gives to the current host CPU
# architecture, which is different than the names GN uses.
if (host_cpu == "x64") {
android_host_arch = "x86_64"
} else if (host_cpu == "x86") {
android_host_arch = "x86"
} else {
assert(false, "Need Android toolchain support for your build CPU arch.")
}
# Defines the name the Android build gives to the current host CPU
# architecture, which is different than the names GN uses.
if (host_os == "linux") {
android_host_os = "linux"
} else if (host_os == "mac") {
android_host_os = "darwin"
} else {
assert(false, "Need Android toolchain support for your build OS.")
}
# Directories and files ------------------------------------------------------
#
# We define may of the dirs strings here for each output architecture (rather
# than just the current one) since these are needed by the Android toolchain
# file to define toolchains for all possible targets in one pass.
android_sdk = "${android_sdk_root}/platforms/android-${android_sdk_version}"
# Path to the Android NDK and SDK.
android_ndk_include_dir = "$android_ndk_root/usr/include"
android_sdk_tools = "${android_sdk_root}/tools"
android_sdk_build_tools =
"${android_sdk_root}/build-tools/$android_sdk_build_tools_version"
# Path to the SDK's android.jar
android_sdk_jar = "$android_sdk/android.jar"
zipalign_path = "$android_sdk_build_tools/zipalign"
# Subdirectories inside android_ndk_root that contain the sysroot for the
# associated platform.
# If you raise this, reevaluate the snprintf=snprintf in ./BUILD.gn.
_android_api_level = 16
x86_android_sysroot_subdir =
"platforms/android-${_android_api_level}/arch-x86"
arm_android_sysroot_subdir =
"platforms/android-${_android_api_level}/arch-arm"
mips_android_sysroot_subdir =
"platforms/android-${_android_api_level}/arch-mips"
# If you raise this, reevaluate the snprintf=snprintf in ./BUILD.gn.
_android64_api_level = 21
x86_64_android_sysroot_subdir =
"platforms/android-${_android64_api_level}/arch-x86_64"
arm64_android_sysroot_subdir =
"platforms/android-${_android64_api_level}/arch-arm64"
mips64_android_sysroot_subdir =
"platforms/android-${_android64_api_level}/arch-mips64"
# Toolchain root directory for each build. The actual binaries are inside
# a "bin" directory inside of these.
_android_toolchain_version = "4.9"
_android_toolchain_detailed_version = "4.9.x"
x86_android_toolchain_root = "$android_ndk_root/toolchains/x86-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}"
arm_android_toolchain_root = "$android_ndk_root/toolchains/arm-linux-androideabi-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}"
mips_android_toolchain_root = "$android_ndk_root/toolchains/mipsel-linux-android-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}"
x86_64_android_toolchain_root = "$android_ndk_root/toolchains/x86_64-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}"
arm64_android_toolchain_root = "$android_ndk_root/toolchains/aarch64-linux-android-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}"
mips64_android_toolchain_root = "$android_ndk_root/toolchains/mips64el-linux-android-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}"
# Location of libgcc. This is only needed for the current GN toolchain, so we
# only need to define the current one, rather than one for every platform
# like the toolchain roots.
if (current_cpu == "x86") {
android_prebuilt_arch = "android-x86"
_binary_prefix = "i686-linux-android"
android_toolchain_root = "$x86_android_toolchain_root"
android_libgcc_file = "$android_toolchain_root/lib/gcc/i686-linux-android/${_android_toolchain_detailed_version}/libgcc.a"
} else if (current_cpu == "arm") {
android_prebuilt_arch = "android-arm"
_binary_prefix = "arm-linux-androideabi"
android_toolchain_root = "$arm_android_toolchain_root"
android_libgcc_file = "$android_toolchain_root/lib/gcc/arm-linux-androideabi/${_android_toolchain_detailed_version}/libgcc.a"
} else if (current_cpu == "mipsel") {
android_prebuilt_arch = "android-mips"
_binary_prefix = "mipsel-linux-android"
android_toolchain_root = "$mips_android_toolchain_root"
android_libgcc_file = "$android_toolchain_root/lib/gcc/mipsel-linux-android/${_android_toolchain_detailed_version}/libgcc.a"
} else if (current_cpu == "x64") {
android_prebuilt_arch = "android-x86_64"
_binary_prefix = "x86_64-linux-android"
android_toolchain_root = "$x86_64_android_toolchain_root"
android_libgcc_file = "$android_toolchain_root/lib/gcc/x86_64-linux-android/${_android_toolchain_detailed_version}/libgcc.a"
} else if (current_cpu == "arm64") {
android_prebuilt_arch = "android-arm64"
_binary_prefix = "aarch64-linux-android"
android_toolchain_root = "$arm64_android_toolchain_root"
android_libgcc_file = "$android_toolchain_root/lib/gcc/aarch64-linux-android/${_android_toolchain_detailed_version}/libgcc.a"
} else if (current_cpu == "mips64el") {
android_prebuilt_arch = "android-mips64"
_binary_prefix = "mips64el-linux-android"
android_toolchain_root = "$mips64_android_toolchain_root"
android_libgcc_file = "$android_toolchain_root/lib/gcc/mips64el-linux-android/${_android_toolchain_detailed_version}/libgcc.a"
} else {
assert(false, "Need android libgcc support for your target arch.")
}
android_tool_prefix = "$android_toolchain_root/bin/$_binary_prefix-"
android_readelf = "${android_tool_prefix}readelf"
android_objcopy = "${android_tool_prefix}objcopy"
android_gdbserver =
"$android_ndk_root/prebuilt/$android_prebuilt_arch/gdbserver/gdbserver"
# Toolchain stuff ------------------------------------------------------------
android_libcpp_root = "$android_ndk_root/sources/cxx-stl/llvm-libc++"
# ABI ------------------------------------------------------------------------
if (current_cpu == "x86") {
android_app_abi = "x86"
} else if (current_cpu == "arm") {
import("//build/config/arm.gni")
if (arm_version < 7) {
android_app_abi = "armeabi"
} else {
android_app_abi = "armeabi-v7a"
}
} else if (current_cpu == "mipsel") {
android_app_abi = "mips"
} else if (current_cpu == "x64") {
android_app_abi = "x86_64"
} else if (current_cpu == "arm64") {
android_app_abi = "arm64-v8a"
} else if (current_cpu == "mips64el") {
android_app_abi = "mips64"
} else {
assert(false, "Unknown Android ABI: " + current_cpu)
}
if (android_libcpp_lib_dir == "") {
android_libcpp_lib_dir = "${android_libcpp_root}/libs/${android_app_abi}"
}
# Secondary ABI -------------------------------------------------------------
if (target_cpu == "arm64" || target_cpu == "x64" || target_cpu == "mips64el") {
android_64bit_target_cpu = true
} else if (target_cpu == "arm" || target_cpu == "x86" ||
target_cpu == "mipsel") {
android_64bit_target_cpu = false
} else {
assert(false, "Unknown target CPU: $target_cpu")
}
# Intentionally do not define android_app_secondary_abi_cpu and
# android_app_secondary_abi for 32-bit target_cpu, since they are not used.
if (target_cpu == "arm64") {
android_secondary_abi_cpu = "arm"
android_app_secondary_abi = "armeabi-v7a"
} else if (target_cpu == "x64") {
android_secondary_abi_cpu = "x86"
android_app_secondary_abi = "x86"
} else if (target_cpu == "mips64el") {
android_secondary_abi_cpu = "mipsel"
android_app_secondary_abi = "mips"
}
if (defined(android_secondary_abi_cpu)) {
if (is_clang) {
android_secondary_abi_toolchain =
"//build/toolchain/android:android_clang_${android_secondary_abi_cpu}"
} else {
android_secondary_abi_toolchain =
"//build/toolchain/android:android_${android_secondary_abi_cpu}"
}
}
}
declare_args() {
# Enables used resource whitelist generation. Set for official builds only
# as a large amount of build output is generated.
enable_resource_whitelist_generation = is_android && is_official_build
}
|