1// 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 17package { 18 default_applicable_licenses: ["system_tools_aidl_license"], 19} 20 21// Added automatically by a large-scale-change 22// See: http://go/android-license-faq 23license { 24 name: "system_tools_aidl_license", 25 visibility: [":__subpackages__"], 26 license_kinds: [ 27 "SPDX-license-identifier-Apache-2.0", 28 ], 29 license_text: [ 30 "NOTICE", 31 ], 32} 33 34cc_defaults { 35 name: "aidl_defaults", 36 cflags: [ 37 "-Wall", 38 "-Werror", 39 "-Wextra", 40 ], 41 header_libs: ["libgtest_prod_headers"], 42 static_libs: [ 43 "libbase", 44 "libcutils", 45 "libgtest", 46 ], 47 // TODO(b/174366536): basic_stringbuf::overflow causes "ubsan: implicit-conversion" 48 // sanitize: { 49 // integer_overflow: true, 50 // misc_undefined: ["integer"], 51 // }, 52 target: { 53 windows: { 54 enabled: true, 55 }, 56 host: { 57 cflags: [ 58 "-O0", 59 "-g", 60 ], 61 }, 62 }, 63 product_variables: { 64 platform_sdk_version: { 65 cflags: ["-DPLATFORM_SDK_VERSION=%d"], 66 }, 67 }, 68} 69 70// Logic shared between aidl and its unittests 71cc_library_static { 72 name: "libaidl-common", 73 defaults: ["aidl_defaults"], 74 host_supported: true, 75 76 srcs: [ 77 "aidl_checkapi.cpp", 78 "aidl_const_expressions.cpp", 79 "aidl_dumpapi.cpp", 80 "aidl_language_l.ll", 81 "aidl_language_y.yy", 82 "aidl_language.cpp", 83 "aidl_to_cpp_common.cpp", 84 "aidl_to_cpp.cpp", 85 "aidl_to_java.cpp", 86 "aidl_to_ndk.cpp", 87 "aidl_to_rust.cpp", 88 "aidl_typenames.cpp", 89 "aidl.cpp", 90 "ast_cpp.cpp", 91 "ast_java.cpp", 92 "code_writer.cpp", 93 "comments.cpp", 94 "diagnostics.cpp", 95 "generate_aidl_mappings.cpp", 96 "generate_cpp.cpp", 97 "generate_java_binder.cpp", 98 "generate_java.cpp", 99 "generate_ndk.cpp", 100 "generate_rust.cpp", 101 "import_resolver.cpp", 102 "io_delegate.cpp", 103 "line_reader.cpp", 104 "location.cpp", 105 "logging.cpp", 106 "options.cpp", 107 "parser.cpp", 108 ], 109 yacc: { 110 gen_location_hh: true, 111 gen_position_hh: true, 112 }, 113} 114 115// aidl executable 116cc_binary_host { 117 name: "aidl", 118 defaults: ["aidl_defaults"], 119 srcs: ["main.cpp"], 120 static_libs: [ 121 "libaidl-common", 122 "libbase", 123 "liblog", 124 ], 125} 126 127// aidl-cpp legacy executable, please use 'aidl' instead 128cc_binary_host { 129 name: "aidl-cpp", 130 defaults: ["aidl_defaults"], 131 srcs: ["main.cpp"], 132 cflags: ["-DAIDL_CPP_BUILD"], 133 static_libs: [ 134 "libaidl-common", 135 "libbase", 136 "liblog", 137 ], 138} 139 140// Unit tests 141cc_test { 142 name: "aidl_unittests", 143 host_supported: true, 144 145 test_suites: ["general-tests"], 146 147 cflags: [ 148 "-Wall", 149 "-Wextra", 150 "-Werror", 151 "-g", 152 ], 153 154 srcs: [ 155 "aidl_unittest.cpp", 156 "ast_cpp_unittest.cpp", 157 "ast_java_unittest.cpp", 158 "code_writer_unittest.cpp", 159 "diagnostics_unittest.cpp", 160 "generate_cpp_unittest.cpp", 161 "io_delegate_unittest.cpp", 162 "options_unittest.cpp", 163 "tests/fake_io_delegate.cpp", 164 "tests/main.cpp", 165 "tests/test_util.cpp", 166 ], 167 168 static_libs: [ 169 "libaidl-common", 170 "libbase", 171 "libcutils", 172 "libgmock", 173 "liblog", 174 ], 175 176 required: ["aidl-golden-test-build-hook"], 177} 178 179cc_fuzz { 180 name: "aidl_parser_fuzzer", 181 host_supported: true, 182 dictionary: "tests/aidl_parser_fuzzer.dict", 183 corpus: [ 184 "tests/corpus/*", 185 ], 186 187 fuzz_config: { 188 cc: [ 189 "devinmoore@google.com", 190 "smoreland@google.com", 191 "jiyong@google.com", 192 "jeongik@google.com", 193 ], 194 }, 195 196 srcs: [ 197 "tests/aidl_parser_fuzzer.cpp", 198 "tests/fake_io_delegate.cpp", 199 "tests/test_util.cpp", 200 ], 201 static_libs: [ 202 "libaidl-common", 203 "libbase", 204 "libcutils", 205 "libgtest", 206 "liblog", 207 ], 208 // Enable this to show additional information about what is being parsed during fuzzing. 209 // cflags: ["-DFUZZ_LOG"], 210} 211 212// 213// Integration testing of generated AIDL code. 214// 215 216python_test_host { 217 name: "aidl_integration_test", 218 main: "tests/aidl_integration_test.py", 219 srcs: ["tests/aidl_integration_test.py"], 220 test_config: "tests/aidl_integration_test.xml", 221 target_required: [ 222 "aidl_test_client", 223 "aidl_test_service", 224 "aidl_test_java_client", 225 "aidl_test_java_service", 226 "aidl_test_rust_client", 227 "aidl_test_rust_service", 228 ], 229 test_suites: ["general-tests"], 230 test_options: { 231 unit_test: false, 232 }, 233} 234 235cc_defaults { 236 name: "aidl_test_defaults", 237 cflags: [ 238 "-Wall", 239 "-Wextra", 240 "-Werror", 241 ], 242 shared_libs: [ 243 "libbase", 244 "libbinder", 245 "liblog", 246 "libutils", 247 ], 248 compile_multilib: "both", 249 multilib: { 250 lib32: { 251 suffix: "32", 252 }, 253 lib64: { 254 suffix: "64", 255 }, 256 }, 257 test_suites: ["general-tests"], 258} 259 260// Header-only library used for atrace in platform NDK builds 261cc_library_headers { 262 name: "libandroid_aidltrace", 263 host_supported: true, 264 vendor_available: true, 265 export_include_dirs: ["trace"], 266 apex_available: [ 267 "//apex_available:platform", 268 "//apex_available:anyapex", 269 ], 270} 271 272filegroup { 273 name: "libaidl-integration-test-files", 274 srcs: [ 275 "tests/android/aidl/tests/BackendType.aidl", 276 "tests/android/aidl/tests/ByteEnum.aidl", 277 "tests/android/aidl/tests/ConstantExpressionEnum.aidl", 278 "tests/android/aidl/tests/DeprecatedEnum.aidl", 279 "tests/android/aidl/tests/DeprecatedParcelable.aidl", 280 "tests/android/aidl/tests/GenericStructuredParcelable.aidl", 281 "tests/android/aidl/tests/IDeprecated.aidl", 282 "tests/android/aidl/tests/INamedCallback.aidl", 283 "tests/android/aidl/tests/INewName.aidl", 284 "tests/android/aidl/tests/IOldName.aidl", 285 "tests/android/aidl/tests/ITestService.aidl", 286 "tests/android/aidl/tests/IntEnum.aidl", 287 "tests/android/aidl/tests/LongEnum.aidl", 288 "tests/android/aidl/tests/OtherParcelableForToString.aidl", 289 "tests/android/aidl/tests/ParcelableForToString.aidl", 290 "tests/android/aidl/tests/StructuredParcelable.aidl", 291 "tests/android/aidl/tests/Union.aidl", 292 "tests/android/aidl/tests/UnionWithFd.aidl", 293 "tests/android/aidl/tests/unions/*.aidl", 294 ], 295 path: "tests", 296} 297 298filegroup { 299 name: "libaidl-integration-cpp-java-test-files", 300 srcs: [ 301 "tests/android/aidl/tests/ICppJavaTests.aidl", 302 "tests/android/aidl/tests/SimpleParcelable.aidl", 303 "tests/android/aidl/tests/extension/*.aidl", 304 ], 305 path: "tests", 306} 307 308aidl_interface { 309 name: "aidl-test-versioned-interface", 310 local_include_dir: "tests/versioned", 311 flags: ["-Werror"], 312 srcs: [ 313 "tests/versioned/**/*.aidl", 314 ], 315 versions: [ 316 "1", 317 "2", 318 ], 319 backend: { 320 rust: { 321 enabled: true, 322 }, 323 }, 324} 325 326cc_library_static { 327 name: "libaidl-integration-test", 328 defaults: ["aidl_test_defaults"], 329 aidl: { 330 generate_traces: true, 331 export_aidl_headers: true, 332 local_include_dirs: ["tests"], 333 include_dirs: ["frameworks/native/aidl/binder"], 334 }, 335 srcs: [ 336 ":libaidl-integration-test-files", 337 ":libaidl-integration-cpp-java-test-files", 338 "tests/simple_parcelable.cpp", 339 ], 340} 341 342cc_test { 343 name: "aidl_test_service", 344 gtest: false, 345 defaults: ["aidl_test_defaults"], 346 static_libs: [ 347 "libaidl-integration-test", 348 "libcutils", 349 // service uses the old version 350 "aidl-test-versioned-interface-V1-cpp", 351 "aidl_test_loggable_interface-cpp", 352 ], 353 srcs: ["tests/aidl_test_service.cpp"], 354} 355 356cc_test { 357 name: "aidl_test_client", 358 defaults: ["aidl_test_defaults"], 359 static_libs: [ 360 "libaidl-integration-test", 361 "libcutils", 362 "libgmock", 363 // client uses the latest version 364 "aidl-test-versioned-interface-V2-cpp", 365 "aidl_test_loggable_interface-cpp" 366 ], 367 srcs: [ 368 "tests/aidl_test_client.cpp", 369 "tests/aidl_test_client_file_descriptors.cpp", 370 "tests/aidl_test_client_parcelables.cpp", 371 "tests/aidl_test_client_nullables.cpp", 372 "tests/aidl_test_client_primitives.cpp", 373 "tests/aidl_test_client_utf8_strings.cpp", 374 "tests/aidl_test_client_service_exceptions.cpp", 375 "tests/aidl_test_client_defaultimpl.cpp", 376 "tests/aidl_test_client_versioned_interface.cpp", 377 "tests/aidl_test_client_renamed_interface.cpp", 378 "tests/aidl_test_client_loggable_interface.cpp", 379 ], 380} 381 382cc_test { 383 name: "aidl_test_client_ndk", 384 defaults: ["aidl_test_defaults"], 385 static_libs: [ 386 "libcutils", 387 "libgmock", 388 // client uses the latest version 389 "aidl-test-versioned-interface-V2-ndk_platform", 390 "aidl-test-interface-ndk_platform", 391 "aidl_test_loggable_interface-ndk_platform" 392 ], 393 shared_libs: [ 394 "libbinder_ndk", 395 ], 396 srcs: [ 397 "tests/aidl_test_client_ndk_loggable_interface.cpp", 398 "tests/aidl_test_client_ndk_versioned_interface.cpp", 399 ], 400} 401 402java_defaults { 403 name: "aidl_test_java_defaults", 404 platform_apis: true, 405 // Turn off Java optimization tools to speed up our test iterations. 406 optimize: { 407 enabled: false, 408 }, 409 dex_preopt: { 410 enabled: false, 411 }, 412 static_libs: [ 413 "androidx.test.core", 414 "androidx.test.runner", 415 "aidl_test_nonvintf_parcelable-V1-java", 416 "aidl_test_unstable_parcelable-java", 417 "aidl_test_vintf_parcelable-V1-java", 418 // TODO: remove once Android migrates to JUnit 4.12, 419 // which provides assertThrows 420 "testng", 421 ], 422 srcs: [ 423 "tests/android/aidl/tests/*.aidl", 424 "tests/android/aidl/tests/generic/*.aidl", 425 "tests/android/aidl/tests/immutable/*.aidl", 426 "tests/android/aidl/tests/map/*.aidl", 427 "tests/android/aidl/tests/extension/*.aidl", 428 "tests/android/aidl/tests/unions/*.aidl", 429 "tests/java/src/android/aidl/tests/SimpleParcelable.java", 430 "tests/java/src/android/aidl/tests/generic/Pair.java", 431 ], 432 aidl: { 433 include_dirs: [ 434 "system/tools/aidl/tests/", 435 "frameworks/native/aidl/binder", 436 ], 437 generate_traces: true, 438 }, 439 test_suites: ["general-tests"], 440} 441 442java_test { 443 name: "aidl_test_java_client", 444 defaults: ["aidl_test_java_defaults"], 445 static_libs: [ 446 // client uses the new version 447 "aidl-test-versioned-interface-V2-java", 448 ], 449 // tests are included in defaults 450 srcs: [ 451 "tests/java/src/android/aidl/tests/MapTests.java", 452 "tests/java/src/android/aidl/tests/TestServiceClient.java", 453 "tests/java/src/android/aidl/tests/JavaOnlyImmutableAnnotationTests.java", 454 "tests/java/src/android/aidl/tests/AidlJavaTests.java", 455 "tests/java/src/android/aidl/tests/GenericTests.java", 456 "tests/java/src/android/aidl/tests/TestVersionedInterface.java", 457 "tests/java/src/android/aidl/tests/UnionTests.java", 458 "tests/java/src/android/aidl/tests/ExtensionTests.java", 459 "tests/java/src/android/aidl/tests/NullableTests.java", 460 "tests/java/src/android/aidl/tests/VintfTests.java", 461 ], 462} 463 464java_test { 465 name: "aidl_test_java_service", 466 defaults: ["aidl_test_java_defaults"], 467 static_libs: [ 468 // service uses the old version 469 "aidl-test-versioned-interface-V1-java", 470 ], 471 srcs: [ 472 "tests/java/src/android/aidl/service/**/*.java", 473 ], 474} 475 476// 477// "Golden" test of compiler output 478// 479 480sh_binary_host { 481 name: "aidl-golden-test", 482 src: "tests/golden_test.sh", 483} 484 485genrule { 486 name: "aidl-golden-test-build-hook-gen", 487 tools: ["aidl-golden-test"], 488 cmd: "$(location aidl-golden-test) check && " + 489 "echo 'int main(){return 0;}' > $(genDir)/TODO_b_37575883.cpp", 490 srcs: [ 491 // warning: keep this list up to date with tests/golden_test.sh 492 ":aidl-test-interface-cpp-source", 493 ":aidl-test-interface-java-source", 494 ":aidl-test-interface-ndk_platform-source", 495 ":aidl-test-interface-rust-source", 496 ":aidl_test_loggable_interface-cpp-source", 497 ":aidl_test_loggable_interface-java-source", 498 ":aidl_test_loggable_interface-ndk_platform-source", 499 ":aidl_test_loggable_interface-ndk-source", 500 "tests/golden_output/**/*", 501 ], 502 out: ["TODO_b_37575883.cpp"], 503} 504 505cc_test_host { 506 name: "aidl-golden-test-build-hook", 507 generated_sources: ["aidl-golden-test-build-hook-gen"], 508 gtest: false, 509} 510 511// 512// Testing generation of logs 513// 514 515aidl_interface { 516 name: "aidl_test_loggable_interface", 517 unstable: true, 518 local_include_dir: "tests", 519 flags: ["-Werror"], 520 srcs: [ 521 "tests/android/aidl/loggable/ILoggableInterface.aidl", 522 "tests/android/aidl/loggable/Data.aidl", 523 "tests/android/aidl/loggable/Enum.aidl", 524 "tests/android/aidl/loggable/Union.aidl", 525 ], 526 gen_trace: true, 527 backend: { 528 cpp: { 529 srcs_available: true, 530 gen_log: true, 531 }, 532 ndk: { 533 srcs_available: true, 534 gen_log: true, 535 }, 536 java: { 537 srcs_available: true, 538 platform_apis: true, 539 }, 540 }, 541} 542 543// 544// Rust tests 545// 546 547aidl_interface { 548 name: "aidl-test-interface", 549 unstable: true, 550 flags: ["-Werror"], 551 srcs: [":libaidl-integration-test-files"], 552 local_include_dir: "tests", 553 backend: { 554 cpp: { 555 srcs_available: true, 556 }, 557 java: { 558 platform_apis: true, 559 srcs_available: true, 560 }, 561 rust: { 562 enabled: true, 563 srcs_available: true, 564 }, 565 ndk: { 566 apps_enabled: false, 567 srcs_available: true, 568 }, 569 }, 570} 571 572rust_test { 573 name: "aidl_test_rust_client", 574 srcs: [ 575 "tests/rust/test_client.rs", 576 ], 577 rustlibs: [ 578 "aidl-test-interface-rust", 579 "aidl-test-versioned-interface-V2-rust", 580 "liblibc", 581 ], 582 prefer_rlib: true, 583 compile_multilib: "both", 584 multilib: { 585 lib32: { 586 suffix: "32", 587 }, 588 lib64: { 589 suffix: "64", 590 }, 591 }, 592 test_suites: ["general-tests"], 593} 594 595rust_test { 596 name: "aidl_test_rust_service", 597 test_harness: false, 598 srcs: [ 599 "tests/rust/test_service.rs", 600 ], 601 rustlibs: [ 602 "aidl-test-interface-rust", 603 "aidl-test-versioned-interface-V1-rust", 604 "liblibc", 605 ], 606 prefer_rlib: true, 607 compile_multilib: "both", 608 multilib: { 609 lib32: { 610 suffix: "32", 611 }, 612 lib64: { 613 suffix: "64", 614 }, 615 }, 616 test_suites: ["general-tests"], 617} 618