1cc_defaults { 2 name: "gd_defaults", 3 target: { 4 android: { 5 test_config_template: "AndroidTestTemplate.xml", 6 cflags: [ 7 "-DOS_ANDROID", 8 "-DOS_LINUX_GENERIC", 9 ], 10 shared_libs: [ 11 "liblog", 12 ], 13 }, 14 host: { 15 cflags: [ 16 "-DOS_LINUX", 17 "-DOS_LINUX_GENERIC", 18 ], 19 }, 20 darwin: { 21 enabled: false, 22 }, 23 }, 24 cpp_std: "c++17", 25 cflags: [ 26 "-DEXPORT_SYMBOL=__attribute__((visibility(\"default\")))", 27 "-fvisibility=hidden", 28 "-DLOG_NDEBUG=1", 29 "-DGOOGLE_PROTOBUF_NO_RTTI", 30 "-Wno-unused-parameter", 31 "-Wno-unused-result", 32 ], 33 conlyflags: [ 34 "-std=c99", 35 ], 36 sanitize: { 37 misc_undefined: ["bounds"], 38 }, 39} 40 41// Enables code coverage for a set of source files. Must be combined with 42// "clang_coverage_bin" in order to work. See //test/gen_coverage.py for more information 43// on generating code coverage. 44cc_defaults { 45 name: "gd_clang_file_coverage", 46 target: { 47 host: { 48 clang_cflags: [ 49 "-fprofile-instr-generate", 50 "-fcoverage-mapping", 51 ], 52 }, 53 }, 54} 55 56// Enabled code coverage on a binary. These flags allow libraries that were 57// compiled with "clang_file_coverage" to be properly linked together in 58// order to create a binary that will create a profraw file when ran. Note 59// these flags themselves don't enable code coverage for the source files 60// compiled in the binary. See //test/gen_coverage.py for more information 61// on generating code coverage. 62cc_defaults { 63 name: "gd_clang_coverage_bin", 64 target: { 65 host: { 66 ldflags: [ 67 "-fprofile-instr-generate", 68 "-fcoverage-mapping", 69 ], 70 }, 71 }, 72} 73 74cc_library { 75 name: "libbluetooth_gd", 76 defaults: [ 77 "gd_defaults", 78 "gd_clang_file_coverage", 79 ], 80 host_supported: true, 81 target: { 82 linux: { 83 srcs: [ 84 ":BluetoothOsSources_linux_generic", 85 ], 86 }, 87 host: { 88 srcs: [ 89 ":BluetoothHalSources_hci_rootcanal", 90 ], 91 }, 92 android: { 93 srcs: [ 94 ":BluetoothHalSources_hci_android_hidl", 95 ], 96 shared_libs: [ 97 "android.hardware.bluetooth@1.0", 98 "libhidlbase", 99 "libutils", 100 ], 101 }, 102 }, 103 srcs: [ 104 "stack_manager.cc", 105 "module.cc", 106 ":BluetoothAttSources", 107 ":BluetoothCommonSources", 108 ":BluetoothCryptoToolboxSources", 109 ":BluetoothHalSources", 110 ":BluetoothHciSources", 111 ":BluetoothL2capSources", 112 ":BluetoothNeighborSources", 113 ":BluetoothPacketSources", 114 ":BluetoothShimSources", 115 ":BluetoothSecuritySources", 116 ":BluetoothStorageSources", 117 ], 118 generated_headers: [ 119 "BluetoothGeneratedPackets_h", 120 ], 121 shared_libs: [ 122 "libchrome", 123 ], 124} 125 126cc_binary { 127 name: "bluetooth_stack_with_facade", 128 defaults: [ 129 "gd_defaults", 130 ], 131 host_supported: true, 132 srcs: [ 133 "facade/facade_main.cc", 134 "facade/grpc_root_server.cc", 135 "facade/read_only_property_server.cc", 136 "grpc/grpc_module.cc", 137 ":BluetoothFacade_hci_hal", 138 ":BluetoothFacade_hci_layer", 139 ":BluetoothFacade_l2cap_layer", 140 ":BluetoothFacade_neighbor", 141 ":BluetoothFacade_security_layer", 142 ], 143 generated_headers: [ 144 "BluetoothGeneratedPackets_h", 145 "BluetoothFacadeGeneratedStub_h", 146 ], 147 generated_sources: [ 148 "BluetoothFacadeGeneratedStub_cc", 149 ], 150 static_libs: [ 151 "libbluetooth_gd", 152 ], 153 shared_libs: [ 154 "libchrome", 155 "libgrpc++_unsecure", 156 "libprotobuf-cpp-full", 157 ], 158 target: { 159 android: { 160 shared_libs: [ 161 "android.hardware.bluetooth@1.0", 162 "libhidlbase", 163 "libutils", 164 ], 165 }, 166 host: { 167 required: [ 168 "root-canal", 169 ], 170 }, 171 }, 172 sanitize: { 173 address: true, 174 }, 175} 176 177cc_test { 178 name: "bluetooth_test_gd", 179 test_suites: ["device-tests"], 180 defaults: [ 181 "gd_defaults", 182 "gd_clang_coverage_bin", 183 ], 184 host_supported: true, 185 target: { 186 linux: { 187 srcs: [ 188 ":BluetoothOsTestSources_linux_generic", 189 ], 190 }, 191 host: { 192 srcs: [ 193 ":BluetoothHalTestSources_hci_rootcanal", 194 ], 195 }, 196 android: { 197 srcs: [ 198 ":BluetoothHalTestSources_hci_android_hidl", 199 ], 200 shared_libs: [ 201 "android.hardware.bluetooth@1.0", 202 "libhidlbase", 203 "libutils", 204 ], 205 }, 206 }, 207 srcs: [ 208 "module_unittest.cc", 209 "stack_manager_unittest.cc", 210 ":BluetoothAttTestSources", 211 ":BluetoothCommonTestSources", 212 ":BluetoothCryptoToolboxTestSources", 213 ":BluetoothHciTestSources", 214 ":BluetoothL2capTestSources", 215 ":BluetoothNeighborTestSources", 216 ":BluetoothPacketTestSources", 217 ":BluetoothSecurityTestSources", 218 ":BluetoothShimTestSources", 219 ":BluetoothStorageTestSources", 220 ], 221 generated_headers: [ 222 "BluetoothGeneratedPackets_h", 223 ], 224 static_libs: [ 225 "libbluetooth_gd", 226 "libgmock", 227 ], 228 shared_libs: [ 229 "libchrome", 230 ], 231 sanitize: { 232 address: true, 233 }, 234} 235 236cc_test { 237 name: "bluetooth_packet_parser_test", 238 test_suites: ["device-tests"], 239 defaults: [ 240 "gd_defaults", 241 "gd_clang_coverage_bin", 242 ], 243 host_supported: true, 244 srcs: [ 245 ":BluetoothPacketSources", 246 ":BluetoothPacketParserTestPacketTestSources", 247 ], 248 generated_headers: [ 249 "BluetoothPacketParserTestPacketPdlGen_h", 250 ], 251 sanitize: { 252 address: true, 253 cfi: true, 254 }, 255} 256 257cc_fuzz { 258 name: "bluetooth_gd_fuzz_test", 259 defaults: ["gd_defaults"], 260 srcs: [ 261 "fuzz_test.cc", 262 ":BluetoothHciFuzzTestSources", 263 ":BluetoothL2capFuzzTestSources", 264 ], 265 static_libs: [ 266 "libbluetooth_gd", 267 "libchrome", 268 "libgmock", 269 "libgtest", 270 ], 271 host_supported: true, 272 generated_headers: [ 273 "BluetoothGeneratedPackets_h", 274 ], 275 target: { 276 android: { 277 shared_libs: [ 278 "android.hardware.bluetooth@1.0", 279 "libhidlbase", 280 "libutils", 281 ], 282 }, 283 }, 284} 285 286cc_benchmark { 287 name: "bluetooth_benchmark_gd", 288 defaults: ["gd_defaults"], 289 host_supported: true, 290 srcs: [ 291 "benchmark.cc", 292 ":BluetoothOsBenchmarkSources", 293 ], 294 static_libs: [ 295 "libbluetooth_gd", 296 ], 297 shared_libs: [ 298 "libchrome", 299 ], 300} 301 302filegroup { 303 name: "BluetoothHciClassSources", 304 srcs: [ 305 "hci/address.cc", 306 "hci/class_of_device.cc", 307 ], 308} 309 310genrule { 311 name: "BluetoothGeneratedPackets_h", 312 tools: [ 313 "bluetooth_packetgen", 314 ], 315 cmd: "$(location bluetooth_packetgen) --include=system/bt/gd --out=$(genDir) $(in)", 316 srcs: [ 317 "hci/hci_packets.pdl", 318 "l2cap/l2cap_packets.pdl", 319 "security/smp_packets.pdl", 320 ], 321 out: [ 322 "hci/hci_packets.h", 323 "l2cap/l2cap_packets.h", 324 "security/smp_packets.h", 325 ], 326} 327 328genrule { 329 name: "BluetoothGeneratedPackets_python3_cc", 330 tools: [ 331 "bluetooth_packetgen", 332 ], 333 cmd: "$(location bluetooth_packetgen) --include=system/bt/gd --out=$(genDir) --num_shards=5 $(in)", 334 srcs: [ 335 "hci/hci_packets.pdl", 336 "l2cap/l2cap_packets.pdl", 337 "security/smp_packets.pdl", 338 ], 339 out: [ 340 "hci/hci_packets_python3.cc", 341 "hci/hci_packets_python3_shard_0.cc", 342 "hci/hci_packets_python3_shard_1.cc", 343 "hci/hci_packets_python3_shard_2.cc", 344 "hci/hci_packets_python3_shard_3.cc", 345 "hci/hci_packets_python3_shard_4.cc", 346 "l2cap/l2cap_packets_python3.cc", 347 "l2cap/l2cap_packets_python3_shard_0.cc", 348 "l2cap/l2cap_packets_python3_shard_1.cc", 349 "l2cap/l2cap_packets_python3_shard_2.cc", 350 "l2cap/l2cap_packets_python3_shard_3.cc", 351 "l2cap/l2cap_packets_python3_shard_4.cc", 352 "security/smp_packets_python3.cc", 353 "security/smp_packets_python3_shard_0.cc", 354 "security/smp_packets_python3_shard_1.cc", 355 "security/smp_packets_python3_shard_2.cc", 356 "security/smp_packets_python3_shard_3.cc", 357 "security/smp_packets_python3_shard_4.cc", 358 ], 359} 360 361filegroup { 362 name: "BluetoothFacadeProto", 363 srcs: [ 364 "facade/common.proto", 365 "facade/rootservice.proto", 366 "hal/facade.proto", 367 "hci/facade/facade.proto", 368 "hci/facade/acl_manager_facade.proto", 369 "hci/facade/controller_facade.proto", 370 "hci/facade/le_acl_manager_facade.proto", 371 "hci/facade/le_advertising_manager_facade.proto", 372 "hci/facade/le_scanning_manager_facade.proto", 373 "neighbor/facade/facade.proto", 374 "l2cap/classic/facade.proto", 375 "security/facade.proto", 376 ], 377} 378 379genrule { 380 name: "BluetoothFacadeGeneratedStub_h", 381 tools: [ 382 "aprotoc", 383 "protoc-gen-grpc-cpp-plugin", 384 ], 385 cmd: "$(location aprotoc) -Isystem/bt/gd -Iexternal/protobuf/src --plugin=protoc-gen-grpc=$(location protoc-gen-grpc-cpp-plugin) $(in) --grpc_out=$(genDir) --cpp_out=$(genDir)", 386 srcs: [ 387 ":BluetoothFacadeProto", 388 ], 389 out: [ 390 "facade/common.grpc.pb.h", 391 "facade/common.pb.h", 392 "facade/rootservice.grpc.pb.h", 393 "facade/rootservice.pb.h", 394 "hal/facade.grpc.pb.h", 395 "hal/facade.pb.h", 396 "hci/facade/facade.grpc.pb.h", 397 "hci/facade/facade.pb.h", 398 "hci/facade/acl_manager_facade.grpc.pb.h", 399 "hci/facade/acl_manager_facade.pb.h", 400 "hci/facade/controller_facade.grpc.pb.h", 401 "hci/facade/controller_facade.pb.h", 402 "hci/facade/le_acl_manager_facade.grpc.pb.h", 403 "hci/facade/le_acl_manager_facade.pb.h", 404 "hci/facade/le_advertising_manager_facade.grpc.pb.h", 405 "hci/facade/le_advertising_manager_facade.pb.h", 406 "hci/facade/le_scanning_manager_facade.grpc.pb.h", 407 "hci/facade/le_scanning_manager_facade.pb.h", 408 "l2cap/classic/facade.grpc.pb.h", 409 "l2cap/classic/facade.pb.h", 410 "neighbor/facade/facade.grpc.pb.h", 411 "neighbor/facade/facade.pb.h", 412 "security/facade.grpc.pb.h", 413 "security/facade.pb.h", 414 ], 415} 416 417genrule { 418 name: "BluetoothFacadeGeneratedStub_cc", 419 tools: [ 420 "aprotoc", 421 "protoc-gen-grpc-cpp-plugin", 422 ], 423 cmd: "$(location aprotoc) -Isystem/bt/gd -Iexternal/protobuf/src --plugin=protoc-gen-grpc=$(location protoc-gen-grpc-cpp-plugin) $(in) --grpc_out=$(genDir) --cpp_out=$(genDir)", 424 srcs: [ 425 ":BluetoothFacadeProto", 426 ], 427 out: [ 428 "facade/common.grpc.pb.cc", 429 "facade/common.pb.cc", 430 "facade/rootservice.grpc.pb.cc", 431 "facade/rootservice.pb.cc", 432 "hal/facade.grpc.pb.cc", 433 "hal/facade.pb.cc", 434 "hci/facade/facade.grpc.pb.cc", 435 "hci/facade/facade.pb.cc", 436 "hci/facade/acl_manager_facade.grpc.pb.cc", 437 "hci/facade/acl_manager_facade.pb.cc", 438 "hci/facade/controller_facade.grpc.pb.cc", 439 "hci/facade/controller_facade.pb.cc", 440 "hci/facade/le_acl_manager_facade.grpc.pb.cc", 441 "hci/facade/le_acl_manager_facade.pb.cc", 442 "hci/facade/le_advertising_manager_facade.grpc.pb.cc", 443 "hci/facade/le_advertising_manager_facade.pb.cc", 444 "hci/facade/le_scanning_manager_facade.grpc.pb.cc", 445 "hci/facade/le_scanning_manager_facade.pb.cc", 446 "l2cap/classic/facade.grpc.pb.cc", 447 "l2cap/classic/facade.pb.cc", 448 "neighbor/facade/facade.grpc.pb.cc", 449 "neighbor/facade/facade.pb.cc", 450 "security/facade.grpc.pb.cc", 451 "security/facade.pb.cc", 452 ], 453} 454 455genrule { 456 name: "BluetoothFacadeAndCertGeneratedStub_py", 457 tools: [ 458 "aprotoc", 459 "protoc-gen-grpc-python-plugin", 460 "soong_zip", 461 ], 462 cmd: "$(location aprotoc) -Isystem/bt/gd -Iexternal/protobuf/src --plugin=protoc-gen-grpc=$(location protoc-gen-grpc-python-plugin) $(in) --grpc_out=$(genDir) --python_out=$(genDir); " + 463 "touch $(genDir)/facade/__init__.py; " + 464 "touch $(genDir)/hal/__init__.py; " + 465 "touch $(genDir)/hci/__init__.py; " + 466 "touch $(genDir)/hci/facade/__init__.py; " + 467 "touch $(genDir)/l2cap/classic/__init__.py; " + 468 "touch $(genDir)/neighbor/facade/__init__.py; " + 469 "touch $(genDir)/security/__init__.py; " + 470 "$(location soong_zip) -C $(genDir) -D $(genDir) -o $(out)", 471 srcs: [ 472 ":BluetoothFacadeProto", 473 ], 474 out: ["bluetooth_cert_generated_py.zip"], 475 dist: { 476 targets: ["bluetooth_stack_with_facade"], 477 }, 478 479} 480 481cc_defaults { 482 name: "bluetooth_py3_native_extension_defaults", 483 include_dirs: [ 484 "external/python/cpython3/Include", 485 ], 486 target: { 487 android: { 488 include_dirs: ["external/python/cpython3/android/bionic/pyconfig"], 489 }, 490 android_arm: { 491 cflags: ["-DSOABI=\"cpython-38android-arm-android-bionic\""], 492 suffix: ".cpython-38android-arm-android-bionic", 493 }, 494 android_arm64: { 495 cflags: ["-DSOABI=\"cpython-38android-arm64-android-bionic\""], 496 suffix: ".cpython-38android-arm64-android-bionic", 497 }, 498 android_x86: { 499 cflags: ["-DSOABI=\"cpython-38android-x86-android-bionic\""], 500 suffix: ".cpython-38android-x86-android-bionic", 501 }, 502 android_x86_64: { 503 cflags: ["-DSOABI=\"cpython-38android-x86_64-android-bionic\""], 504 suffix: ".cpython-38android-x86_64-android-bionic", 505 }, 506 // Regenerate include dirs with android_regen.sh 507 darwin_x86_64: { 508 include_dirs: ["external/python/cpython3/android/darwin_x86_64/pyconfig"], 509 cflags: [ 510 "-Wno-deprecated-declarations", 511 "-Wno-pointer-arith", 512 "-DSOABI=\"cpython-38android-x86_64-darwin\"", 513 ], 514 suffix: ".cpython-38android-x86_64-darwin", 515 }, 516 linux_bionic: { 517 // NB linux_bionic is a 'host' architecture but it uses the bionic libc like 'android' 518 // targets so use the android pyconfig. 519 include_dirs: ["external/python/cpython3/android/bionic/pyconfig"], 520 cflags: ["-DSOABI=\"cpython-38android-x86_64-linux-bionic\""], 521 suffix: ".cpython-38android-x86_64-linux-bionic", 522 }, 523 linux_glibc_x86: { 524 enabled: false, 525 }, 526 linux_glibc_x86_64: { 527 include_dirs: ["external/python/cpython3/android/linux_x86_64/pyconfig"], 528 cflags: ["-DSOABI=\"cpython-38android-x86_64-linux-gnu\""], 529 // Commenting out the Linux suffix so that cpython-38-x86_64-linux-gnu 530 // Python 3.8 can also import the untagged .so library per PEP 3149 531 // Keep this change until Android py3-cmd can run ACTS, gRPC and can 532 // Export Python native symbols such as PyType_Type 533 // suffix: ".cpython-38android-x86_64-linux-gnu", 534 }, 535 windows: { 536 enabled: false, 537 }, 538 }, 539 allow_undefined_symbols: true, 540} 541 542cc_library_host_shared { 543 name: "bluetooth_packets_python3", 544 defaults: [ 545 "gd_defaults", 546 "bluetooth_py3_native_extension_defaults" 547 ], 548 srcs: [ 549 "packet/python3_module.cc", 550 "l2cap/fcs.cc", 551 ":BluetoothPacketSources", 552 "hci/address.cc", 553 "hci/class_of_device.cc", 554 ], 555 generated_headers: [ 556 "BluetoothGeneratedPackets_h", 557 ], 558 generated_sources: [ 559 "BluetoothGeneratedPackets_python3_cc", 560 ], 561 header_libs: [ 562 "pybind11_headers", 563 ], 564 cflags: [ 565 "-fexceptions", 566 ], 567 rtti: true, 568} 569