blob: 373c40299274926c5382c12998c5c91ee7b77dec [file] [log] [blame]
Dan Willemsen8fd503f2016-10-04 20:04:36 -07001//
2// Copyright (C) 2015 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17cc_defaults {
18 name: "aidl_defaults",
Chih-Hung Hsieh15607962017-10-02 10:03:55 -070019 cflags: [
Dan Willemsen8fd503f2016-10-04 20:04:36 -070020 "-Wall",
Dan Willemsen8fd503f2016-10-04 20:04:36 -070021 "-Werror",
Chih-Hung Hsieh15607962017-10-02 10:03:55 -070022 "-Wextra",
Dan Willemsen8fd503f2016-10-04 20:04:36 -070023 ],
24 whole_static_libs: ["libgtest_prod"],
25 static_libs: [
26 "libbase",
27 "libcutils",
28 ],
29 target: {
30 windows: {
31 enabled: true,
32 },
Steven Morelandb49a33d2019-08-21 11:17:32 -070033 host: {
34 cflags: [
35 "-O0",
36 "-g",
37 ],
38 },
Dan Willemsen8fd503f2016-10-04 20:04:36 -070039 },
Steven Moreland1c894432020-02-14 11:32:44 -080040 product_variables: {
41 platform_sdk_version: {
42 cflags: ["-DPLATFORM_SDK_VERSION=%d"],
43 },
44 },
Dan Willemsen8fd503f2016-10-04 20:04:36 -070045}
46
47// Logic shared between aidl and its unittests
Andreas Gampe76a6a462018-10-08 17:44:16 -070048cc_library_static {
Dan Willemsen8fd503f2016-10-04 20:04:36 -070049 name: "libaidl-common",
50 defaults: ["aidl_defaults"],
Andreas Gampe76a6a462018-10-08 17:44:16 -070051 host_supported: true,
Dan Willemsen8fd503f2016-10-04 20:04:36 -070052
Dan Willemsen8fd503f2016-10-04 20:04:36 -070053 srcs: [
54 "aidl.cpp",
Steven Moreland49585242019-12-18 16:06:49 -080055 "aidl_checkapi.cpp",
Will McVickerefd970d2019-09-25 15:28:30 -070056 "aidl_const_expressions.cpp",
Dan Willemsen8fd503f2016-10-04 20:04:36 -070057 "aidl_language.cpp",
58 "aidl_language_l.ll",
59 "aidl_language_y.yy",
Jiyong Park1deecc32018-07-17 01:14:41 +090060 "aidl_typenames.cpp",
Steven Moreland860b1942018-08-16 14:59:28 -070061 "aidl_to_cpp.cpp",
Jiyong Park1d2df7d2018-07-23 15:22:50 +090062 "aidl_to_java.cpp",
Steven Morelande8a3a192018-09-20 14:14:28 -070063 "aidl_to_ndk.cpp",
Dan Willemsen8fd503f2016-10-04 20:04:36 -070064 "ast_cpp.cpp",
65 "ast_java.cpp",
66 "code_writer.cpp",
67 "generate_cpp.cpp",
Steven Morelandb0057e72018-08-27 01:44:11 -070068 "aidl_to_cpp_common.cpp",
69 "generate_ndk.cpp",
Dan Willemsen8fd503f2016-10-04 20:04:36 -070070 "generate_java.cpp",
71 "generate_java_binder.cpp",
Andrei Onea8714b022019-02-01 18:55:54 +000072 "generate_aidl_mappings.cpp",
Dan Willemsen8fd503f2016-10-04 20:04:36 -070073 "import_resolver.cpp",
74 "line_reader.cpp",
75 "io_delegate.cpp",
76 "options.cpp",
Dan Willemsen8fd503f2016-10-04 20:04:36 -070077 ],
Dan Willemsenfad411f2019-04-12 14:40:55 -070078 yacc: {
79 gen_location_hh: true,
80 gen_position_hh: true,
81 },
Dan Willemsen8fd503f2016-10-04 20:04:36 -070082}
83
84// aidl executable
85cc_binary_host {
86 name: "aidl",
87 defaults: ["aidl_defaults"],
Jiyong Park74595c12018-07-23 15:22:50 +090088 srcs: ["main.cpp"],
Dan Willemsen8fd503f2016-10-04 20:04:36 -070089 static_libs: [
90 "libaidl-common",
91 "libbase",
Tom Cherryffe43cd2020-01-08 14:10:30 -080092 "liblog",
Dan Willemsen8fd503f2016-10-04 20:04:36 -070093 ],
94}
95
Steven Morelandbb654e32020-01-08 19:52:05 -080096// aidl-cpp legacy executable, please use 'aidl' instead
Dan Willemsen8fd503f2016-10-04 20:04:36 -070097cc_binary_host {
98 name: "aidl-cpp",
99 defaults: ["aidl_defaults"],
Steven Morelandbb654e32020-01-08 19:52:05 -0800100 srcs: ["main.cpp"],
101 cflags: ["-DAIDL_CPP_BUILD"],
Dan Willemsen8fd503f2016-10-04 20:04:36 -0700102 static_libs: [
103 "libaidl-common",
104 "libbase",
Tom Cherryffe43cd2020-01-08 14:10:30 -0800105 "liblog",
Dan Willemsen8fd503f2016-10-04 20:04:36 -0700106 ],
107}
108
109// Unit tests
Andreas Gampe76a6a462018-10-08 17:44:16 -0700110cc_test {
Dan Willemsen8fd503f2016-10-04 20:04:36 -0700111 name: "aidl_unittests",
Andreas Gampe76a6a462018-10-08 17:44:16 -0700112 host_supported: true,
113
Steven Moreland2921b8b2020-03-10 16:12:47 -0700114 test_suites: ["general-tests"],
Dan Willemsen8fd503f2016-10-04 20:04:36 -0700115
116 cflags: [
117 "-Wall",
118 "-Wextra",
119 "-Werror",
120 "-g",
Dan Willemsen8fd503f2016-10-04 20:04:36 -0700121 ],
Steven Moreland1c41e972018-07-09 16:07:00 -0700122
Dan Willemsen8fd503f2016-10-04 20:04:36 -0700123 srcs: [
124 "aidl_unittest.cpp",
125 "ast_cpp_unittest.cpp",
126 "ast_java_unittest.cpp",
Jiyong Park22b4ecd2018-07-23 23:34:42 +0900127 "code_writer_unittest.cpp",
Dan Willemsen8fd503f2016-10-04 20:04:36 -0700128 "generate_cpp_unittest.cpp",
129 "io_delegate_unittest.cpp",
130 "options_unittest.cpp",
131 "tests/end_to_end_tests.cpp",
132 "tests/fake_io_delegate.cpp",
133 "tests/main.cpp",
134 "tests/test_data_example_interface.cpp",
135 "tests/test_data_ping_responder.cpp",
136 "tests/test_data_string_constants.cpp",
137 "tests/test_util.cpp",
Dan Willemsen8fd503f2016-10-04 20:04:36 -0700138 ],
139
140 static_libs: [
141 "libaidl-common",
142 "libbase",
143 "libcutils",
Steven Moreland57ec44a2019-10-25 15:50:21 -0700144 "libgmock",
Tom Cherryffe43cd2020-01-08 14:10:30 -0800145 "liblog",
Dan Willemsen8fd503f2016-10-04 20:04:36 -0700146 ],
Dan Willemsen8fd503f2016-10-04 20:04:36 -0700147}
148
Steven Moreland45857d72019-10-25 17:08:09 -0700149cc_fuzz {
150 name: "aidl_parser_fuzzer",
151 host_supported: true,
152 dictionary: "tests/aidl_parser_fuzzer.dict",
Mitch Phillips17fad882019-12-18 11:27:40 -0800153 corpus: [
154 "tests/corpus/*",
155 ],
Steven Moreland00f1ee72019-11-04 09:52:06 -0800156
157 fuzz_config: {
158 cc: [
Steven Morelanda1e49872020-04-10 10:08:17 -0700159 "devinmoore@google.com",
Steven Moreland00f1ee72019-11-04 09:52:06 -0800160 "smoreland@google.com",
161 "jiyong@google.com",
162 "jeongik@google.com",
163 ],
164 },
165
Steven Moreland45857d72019-10-25 17:08:09 -0700166 srcs: [
167 "tests/aidl_parser_fuzzer.cpp",
168 "tests/fake_io_delegate.cpp",
169 "tests/test_util.cpp",
170 ],
171 static_libs: [
172 "libaidl-common",
173 "libbase",
174 "libcutils",
Tom Cherryffe43cd2020-01-08 14:10:30 -0800175 "liblog",
Steven Moreland45857d72019-10-25 17:08:09 -0700176 ],
Steven Moreland45857d72019-10-25 17:08:09 -0700177 // Enable this to show additional information about what is being parsed during fuzzing.
178 // cflags: ["-DFUZZ_LOG"],
179}
180
Dan Willemsen8fd503f2016-10-04 20:04:36 -0700181//
Steven Moreland9866fcd2020-03-10 16:51:48 -0700182// Integration testing of generated AIDL code.
Dan Willemsen8fd503f2016-10-04 20:04:36 -0700183//
Steven Moreland9866fcd2020-03-10 16:51:48 -0700184
185python_test_host {
186 name: "aidl_integration_test",
187 main: "tests/aidl_integration_test.py",
188 srcs: ["tests/aidl_integration_test.py"],
189 test_config: "tests/aidl_integration_test.xml",
190 target_required: [
191 "aidl_test_client",
192 "aidl_test_sentinel_searcher",
193 "aidl_test_service",
194 "aidl_test_services",
Dan Willemsen8fd503f2016-10-04 20:04:36 -0700195 ],
Steven Moreland9866fcd2020-03-10 16:51:48 -0700196 test_suites: ["device-tests"],
Dan Willemsen8fd503f2016-10-04 20:04:36 -0700197}
Dan Willemsen8f883612016-11-03 14:22:48 -0700198
199cc_defaults {
200 name: "aidl_test_defaults",
201 cflags: [
202 "-Wall",
203 "-Wextra",
204 "-Werror",
Dan Willemsen8f883612016-11-03 14:22:48 -0700205 ],
206 shared_libs: [
207 "libbase",
208 "libbinder",
209 "liblog",
210 "libutils",
211 ],
Steven Moreland9866fcd2020-03-10 16:51:48 -0700212 compile_multilib: "both",
213 multilib: {
214 lib32: {
215 suffix: "32",
216 },
217 lib64: {
218 suffix: "64",
219 },
220 },
221 test_suites: ["device-tests"],
222}
223
224// Could consider simplifying this test by removing this.
225cc_test {
226 name: "aidl_test_sentinel_searcher",
227 defaults: ["aidl_test_defaults"],
228 gtest: false,
229 srcs: ["tests/aidl_test_sentinel_searcher.cpp"],
230 cflags: [
231 "-Wall",
232 "-Wextra",
233 "-Werror",
234 ],
Dan Willemsen8f883612016-11-03 14:22:48 -0700235}
236
Dan Willemsenc46b65e2019-06-06 10:55:58 -0700237filegroup {
238 name: "libaidl-integration-test-files",
239 srcs: ["tests/android/aidl/tests/*.aidl"],
240 path: "tests",
241}
242
Steven Moreland87bbbd82019-07-30 16:32:54 -0700243cc_library_static {
Dan Willemsen8f883612016-11-03 14:22:48 -0700244 name: "libaidl-integration-test",
245 defaults: ["aidl_test_defaults"],
246 aidl: {
247 export_aidl_headers: true,
248 local_include_dirs: ["tests"],
249 include_dirs: ["frameworks/native/aidl/binder"],
250 },
251 srcs: [
Dan Willemsenc46b65e2019-06-06 10:55:58 -0700252 ":libaidl-integration-test-files",
Dan Willemsen8f883612016-11-03 14:22:48 -0700253 "tests/simple_parcelable.cpp",
254 ],
255}
256
Steven Moreland87bbbd82019-07-30 16:32:54 -0700257cc_test {
Dan Willemsen8f883612016-11-03 14:22:48 -0700258 name: "aidl_test_service",
Steven Moreland87bbbd82019-07-30 16:32:54 -0700259 gtest: false,
Dan Willemsen8f883612016-11-03 14:22:48 -0700260 defaults: ["aidl_test_defaults"],
Steven Moreland87bbbd82019-07-30 16:32:54 -0700261 static_libs: ["libaidl-integration-test"],
Dan Willemsen8f883612016-11-03 14:22:48 -0700262 srcs: ["tests/aidl_test_service.cpp"],
263}
264
Steven Moreland87bbbd82019-07-30 16:32:54 -0700265cc_test {
Dan Willemsen8f883612016-11-03 14:22:48 -0700266 name: "aidl_test_client",
Steven Moreland87bbbd82019-07-30 16:32:54 -0700267 gtest: false,
Dan Willemsen8f883612016-11-03 14:22:48 -0700268 defaults: ["aidl_test_defaults"],
Steven Moreland87bbbd82019-07-30 16:32:54 -0700269 static_libs: ["libaidl-integration-test"],
Dan Willemsen8f883612016-11-03 14:22:48 -0700270 srcs: [
271 "tests/aidl_test_client.cpp",
272 "tests/aidl_test_client_file_descriptors.cpp",
273 "tests/aidl_test_client_parcelables.cpp",
274 "tests/aidl_test_client_nullables.cpp",
275 "tests/aidl_test_client_primitives.cpp",
276 "tests/aidl_test_client_utf8_strings.cpp",
277 "tests/aidl_test_client_service_exceptions.cpp",
Jiyong Park75e1a742018-07-04 12:31:23 +0900278 "tests/aidl_test_client_defaultimpl.cpp",
Dan Willemsen8f883612016-11-03 14:22:48 -0700279 ],
280}
Steven Moreland0ae34602018-06-28 10:08:19 -0700281
Steven Moreland9866fcd2020-03-10 16:51:48 -0700282android_test_helper_app {
Steven Moreland0ae34602018-06-28 10:08:19 -0700283 name: "aidl_test_services",
284 platform_apis: true,
285 // Turn off Java optimization tools to speed up our test iterations.
286 optimize: {
287 enabled: false,
288 },
289 dex_preopt: {
290 enabled: false,
291 },
292 certificate: "platform",
293 manifest: "tests/java_app/AndroidManifest.xml",
294 resource_dirs: ["tests/java_app/resources"],
295 srcs: [
Steven Moreland2a9a7d62019-02-05 16:11:54 -0800296 "tests/android/aidl/tests/*.aidl",
Jeongik Chae74c86d2019-12-12 16:54:03 +0900297 "tests/android/aidl/tests/generic/*.aidl",
Jeongik Chae48d9942020-01-02 17:39:00 +0900298 "tests/android/aidl/tests/map/*.aidl",
Jeongik Chae74c86d2019-12-12 16:54:03 +0900299 "tests/java_app/src/android/aidl/tests/GenericTests.java",
Jeongik Chae48d9942020-01-02 17:39:00 +0900300 "tests/java_app/src/android/aidl/tests/MapTests.java",
Steven Moreland0ae34602018-06-28 10:08:19 -0700301 "tests/java_app/src/android/aidl/tests/NullableTests.java",
302 "tests/java_app/src/android/aidl/tests/SimpleParcelable.java",
303 "tests/java_app/src/android/aidl/tests/TestFailException.java",
304 "tests/java_app/src/android/aidl/tests/TestLogger.java",
305 "tests/java_app/src/android/aidl/tests/TestServiceClient.java",
Jeongik Chae74c86d2019-12-12 16:54:03 +0900306 "tests/java_app/src/android/aidl/tests/generic/Pair.java",
Steven Moreland0ae34602018-06-28 10:08:19 -0700307 ],
308 aidl: {
309 include_dirs: [
310 "system/tools/aidl/tests/",
311 "frameworks/native/aidl/binder",
312 ],
313 },
Steven Moreland9866fcd2020-03-10 16:51:48 -0700314 test_suites: ["device-tests"],
Steven Moreland0ae34602018-06-28 10:08:19 -0700315}
Jiyong Parkce50e262018-10-29 09:54:20 +0900316
Steven Moreland9866fcd2020-03-10 16:51:48 -0700317//
318// Testing generation of logs
319//
320
Jiyong Parkce50e262018-10-29 09:54:20 +0900321aidl_interface {
Steven Moreland2a9a7d62019-02-05 16:11:54 -0800322 name: "aidl_test_loggable_interface",
Jiyong Parka3617e62020-04-13 11:32:05 +0900323 unstable: true,
Jiyong Parkce50e262018-10-29 09:54:20 +0900324 local_include_dir: "tests",
325 srcs: [
Steven Moreland6e435322019-03-29 18:16:39 -0700326 "tests/android/aidl/loggable/ILoggableInterface.aidl",
Jiyong Parkce50e262018-10-29 09:54:20 +0900327 ],
Devin Moorea45a3602020-04-16 11:22:55 -0700328 gen_trace: true,
Jiyong Parkce50e262018-10-29 09:54:20 +0900329 backend: {
330 cpp: {
331 gen_log: true,
332 },
333 ndk: {
Jeongik Cha37e2ad52019-04-18 13:44:26 +0900334 gen_log: true,
335 },
336 },
Steven Morelandbb654e32020-01-08 19:52:05 -0800337}