forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBUILD.gn
225 lines (197 loc) · 6.86 KB
/
BUILD.gn
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
# 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.
import("//build/config/android/build_vars.gni")
import("//build/config/android/config.gni")
import("//build/config/android/rules.gni")
import("//build/config/python.gni")
import("//build_overrides/build.gni")
if (enable_java_templates) {
# Create or update the API versions cache if necessary by running a
# functionally empty lint task. This prevents racy creation of the
# cache while linting java targets in android_lint.
android_lint("prepare_android_lint_cache") {
create_cache = true
}
if (enable_jdk_library_desugaring) {
dex_jdk_libs("all_jdk_libs") {
output = "$target_out_dir/$target_name.l8.dex"
min_sdk_version = default_min_sdk_version
}
}
generate_build_config_srcjar("build_config_gen") {
use_final_fields = false
}
write_native_libraries_java("native_libraries_gen") {
use_final_fields = false
}
java_library("build_java") {
supports_android = true
srcjar_deps = [
":build_config_gen",
":native_libraries_gen",
]
sources = [
"java/src/org/chromium/base/annotations/CheckDiscard.java",
"java/src/org/chromium/base/annotations/DoNotClassMerge.java",
"java/src/org/chromium/base/annotations/DoNotInline.java",
"java/src/org/chromium/base/annotations/IdentifierNameString.java",
"java/src/org/chromium/base/annotations/MainDex.java",
"java/src/org/chromium/base/annotations/MockedInTests.java",
"java/src/org/chromium/base/annotations/UsedByReflection.java",
]
jar_excluded_patterns = [ "*/build/BuildConfig.class" ]
# New version of NativeLibraries.java (with the actual correct values) will
# be created when creating an apk.
jar_excluded_patterns += [ "*/NativeLibraries.class" ]
}
# Not all //build embedders pull in junit_binary deps that live in //third_party.
if (build_with_chromium) {
android_assets("junit_test_assets") {
testonly = true
# We just need any file here, so use the test itself.
sources = [ "junit/src/org/chromium/build/AndroidAssetsTest.java" ]
}
android_resources("junit_test_resources") {
testonly = true
sources = [ "junit/res/values/strings.xml" ]
mergeable_android_manifests = [ "junit/AndroidManifest_mergetest.xml" ]
}
robolectric_binary("build_junit_tests") {
# Test has no JNI, so skip JNI Generator step.
generate_final_jni = false
resources_package = "org.chromium.build"
sources = [
"junit/src/org/chromium/build/AndroidAssetsTest.java",
"junit/src/org/chromium/build/IncrementalJavacTest.java",
]
deps = [
":junit_test_assets",
":junit_test_resources",
"//build/android/test/incremental_javac_gn:no_signature_change_prebuilt_java",
"//third_party/junit",
]
}
}
}
python_library("test_result_presentations_py") {
pydeps_file = "pylib/results/presentation/test_results_presentation.pydeps"
data = [ "//build/android/pylib/results/presentation/template" ]
}
python_library("devil_chromium_py") {
pydeps_file = "devil_chromium.pydeps"
data = [
"devil_chromium.py",
"devil_chromium.json",
"//third_party/catapult/third_party/gsutil/",
"//third_party/catapult/devil/devil/devil_dependencies.json",
# Read by gn_helpers.BuildWithChromium()
"//build/config/gclient_args.gni",
]
}
# Contains runtime deps for installing apks.
# E.g. from test_runner.py or from apk_operations.py.
group("apk_installer_data") {
# Other //build users let devil library fetch these from Google Storage.
if (build_with_chromium) {
data_deps = [
"//build/android/pylib/device/commands",
"//tools/android/md5sum",
]
data = [ "//third_party/android_build_tools/bundletool/bundletool.jar" ]
}
}
python_library("apk_operations_py") {
pydeps_file = "apk_operations.pydeps"
deps = [ ":apk_installer_data" ]
}
group("test_runner_py") {
testonly = true
deps = [
":test_runner_core_py",
":test_runner_device_support",
]
}
python_library("test_runner_core_py") {
testonly = true
pydeps_file = "test_runner.pydeps"
data = [
"pylib/gtest/filter/",
"pylib/instrumentation/render_test.html.jinja",
"test_wrapper/logdog_wrapper.py",
"//third_party/requests/",
]
data_deps = [ ":logdog_wrapper_py" ]
}
group("test_runner_device_support") {
testonly = true
data = [
"${android_sdk_build_tools}/aapt",
"${android_sdk_build_tools}/dexdump",
"${android_sdk_build_tools}/lib64/libc++.so",
"${android_sdk_build_tools}/split-select",
"${android_sdk_root}/platform-tools/adb",
]
data_deps = [
":apk_installer_data",
":devil_chromium_py",
":stack_tools",
]
# Other //build users let devil library fetch these from Google Storage.
if (build_with_chromium) {
data_deps += [ "//tools/android/forwarder2" ]
data += [ "//tools/android/avd/proto/" ]
if (is_asan) {
data_deps += [ "//tools/android/asan/third_party:asan_device_setup" ]
}
}
# Proguard is needed only when using apks (rather than native executables).
if (enable_java_templates) {
data_deps += [ "//build/android/stacktrace:java_deobfuscate" ]
}
}
python_library("logdog_wrapper_py") {
pydeps_file = "test_wrapper/logdog_wrapper.pydeps"
}
python_library("resource_sizes_py") {
pydeps_file = "resource_sizes.pydeps"
data_deps = [
":devil_chromium_py",
"//third_party/catapult/tracing:convert_chart_json",
]
data = [
build_vars_file,
android_readelf,
rebase_path("$android_ndk_library_path/libc++.so.1", root_build_dir),
]
}
# Tools necessary for symbolizing tombstones or stack traces that are output to
# logcat.
# Hidden behind build_with_chromium because some third party repos that use
# //build don't pull in //third_party/android_platform.
# TODO(crbug.com/1120190): Move stack script into //build/third_party
# and enable unconditionally.
group("stack_tools") {
if (build_with_chromium) {
data = [
"tombstones.py",
"pylib/symbols/",
"stacktrace/",
]
data_deps =
[ "//third_party/android_platform/development/scripts:stack_py" ]
}
}
# GN evaluates each .gn file once per toolchain, so restricting to default
# toolchain will ensure write_file() is called only once.
assert(current_toolchain == default_toolchain)
# NOTE: If other platforms would benefit from exporting variables, we should
# move this to a more top-level place.
# It is currently here (instead of //BUILD.gn) to ensure that the file is
# written even for non-chromium embedders of //build.
_build_vars_json = {
# Underscore prefix so that it appears at the top.
_HEADER = "Generated during 'gn gen' by //build/android/BUILD.gn."
forward_variables_from(android_build_vars_json, "*")
}
write_file(build_vars_file, _build_vars_json, "json")