cc_defaults { name: "gd_defaults", target: { android: { test_config_template: "AndroidTestTemplate.xml", cflags: [ "-DOS_ANDROID", "-DOS_LINUX_GENERIC", ], shared_libs: [ "liblog", ], }, host: { cflags: [ "-DOS_LINUX", "-DOS_LINUX_GENERIC", ], }, darwin: { enabled: false, }, }, cpp_std: "c++17", cflags: [ "-DEXPORT_SYMBOL=__attribute__((visibility(\"default\")))", "-fvisibility=hidden", "-DLOG_NDEBUG=1", "-DGOOGLE_PROTOBUF_NO_RTTI", "-Wno-unused-parameter", "-Wno-implicit-fallthrough", "-Wno-unused-result", ], conlyflags: [ "-std=c99", ], sanitize: { misc_undefined: ["bounds"], }, } // Enables code coverage for a set of source files. Must be combined with // "clang_coverage_bin" in order to work. See //test/gen_coverage.py for more information // on generating code coverage. cc_defaults { name: "gd_clang_file_coverage", target: { host: { clang_cflags: [ "-fprofile-instr-generate", "-fcoverage-mapping", ], }, }, } // Enabled code coverage on a binary. These flags allow libraries that were // compiled with "clang_file_coverage" to be properly linked together in // order to create a binary that will create a profraw file when ran. Note // these flags themselves don't enable code coverage for the source files // compiled in the binary. See //test/gen_coverage.py for more information // on generating code coverage. cc_defaults { name: "gd_clang_coverage_bin", target: { host: { ldflags: [ "-fprofile-instr-generate", "-fcoverage-mapping", ], }, }, } cc_library { name: "libbluetooth_gd", defaults: [ "gd_defaults", "gd_clang_file_coverage", ], host_supported: true, target: { linux: { srcs: [ ":BluetoothOsSources_linux_generic", ], }, host: { srcs: [ ":BluetoothHalSources_hci_rootcanal", ], }, android: { srcs: [ ":BluetoothHalSources_hci_android_hidl", ], shared_libs: [ "android.hardware.bluetooth@1.0", "libhwbinder", "libhidlbase", "libhidltransport", "libutils", ], }, }, srcs: [ "stack_manager.cc", "module.cc", ":BluetoothCommonSources", ":BluetoothCryptoToolboxSources", ":BluetoothHalSources", ":BluetoothHciSources", ":BluetoothL2capSources", ":BluetoothPacketSources", ":BluetoothSmpSources", ], generated_headers: [ "BluetoothGeneratedPackets_h", ], shared_libs: [ "libchrome", ], } cc_binary { name: "stack_with_facade", defaults: [ "gd_defaults", ], host_supported: true, srcs: [ "facade/facade_main.cc", "facade/grpc_root_server.cc", "facade/read_only_property_server.cc", "grpc/grpc_module.cc", ":BluetoothFacade_hci_hal", ":BluetoothFacade_hci_layer", ":BluetoothFacade_l2cap_layer", ], generated_headers: [ "BluetoothGeneratedPackets_h", "BluetoothFacadeGeneratedStub_h", ], generated_sources: [ "BluetoothFacadeGeneratedStub_cc", ], static_libs: [ "libbluetooth_gd", ], shared_libs: [ "libchrome", "libgrpc++_unsecure", "libprotobuf-cpp-full", ], target: { android: { shared_libs: [ "android.hardware.bluetooth@1.0", "libhwbinder", "libhidlbase", "libhidltransport", "libutils", ], }, }, sanitize: { address: true, }, } cc_binary { name: "bluetooth_cert_stack", defaults: [ "gd_defaults", ], host_supported: true, srcs: [ "cert/cert_main.cc", "cert/grpc_root_server.cc", "cert/read_only_property_server.cc", "grpc/grpc_module.cc", ":BluetoothCertSource_hci_hal", ":BluetoothCertSource_hci_layer", ":BluetoothCertSource_l2cap_layer", ], generated_headers: [ "BluetoothGeneratedPackets_h", "BluetoothCertStackGeneratedStub_h", ], generated_sources: [ "BluetoothCertStackGeneratedStub_cc", ], static_libs: [ "libbluetooth_gd", ], shared_libs: [ "libchrome", "libgrpc++_unsecure", "libprotobuf-cpp-full", ], target: { android: { shared_libs: [ "android.hardware.bluetooth@1.0", "libhwbinder", "libhidlbase", "libhidltransport", "libutils", ], }, }, sanitize: { address: true, }, } cc_test { name: "bluetooth_test_gd", test_suites: ["device-tests"], defaults: [ "gd_defaults", "gd_clang_coverage_bin", ], host_supported: true, target: { linux: { srcs: [ ":BluetoothOsTestSources_linux_generic", ], }, host: { srcs: [ ":BluetoothHalTestSources_hci_rootcanal", ], }, android: { srcs: [ ":BluetoothHalTestSources_hci_android_hidl", ], shared_libs: [ "android.hardware.bluetooth@1.0", "libhwbinder", "libhidlbase", "libhidltransport", "libutils", ], }, }, srcs: [ "module_unittest.cc", "stack_manager_unittest.cc", ":BluetoothCommonTestSources", ":BluetoothCryptoToolboxTestSources", ":BluetoothHciTestSources", ":BluetoothL2capTestSources", ":BluetoothPacketTestSources", ":BluetoothSmpTestSources", ], generated_headers: [ "BluetoothGeneratedPackets_h", ], static_libs: [ "libbluetooth_gd", "libgmock", ], shared_libs: [ "libchrome", ], sanitize: { address: true, }, } cc_test { name: "bluetooth_packet_parser_test", test_suites: ["device-tests"], defaults: [ "gd_defaults", "gd_clang_coverage_bin", ], host_supported: true, srcs: [ ":BluetoothPacketSources", ":BluetoothPacketParserTestPacketTestSources", ], generated_headers: [ "BluetoothPacketParserTestPacketPdlGen_h", ], sanitize: { address: true, cfi: true, }, } cc_benchmark { name: "bluetooth_benchmark_gd", defaults: ["gd_defaults"], host_supported: true, srcs: [ "benchmark.cc", ":BluetoothOsBenchmarkSources", ], static_libs: [ "libbluetooth_gd", ], shared_libs: [ "libchrome", ], } genrule { name: "BluetoothGeneratedPackets_h", tools: [ "bluetooth_packetgen", ], cmd: "$(location bluetooth_packetgen) --include=system/bt/gd --out=$(genDir) $(in)", srcs: [ "hci/hci_packets.pdl", "l2cap/l2cap_packets.pdl", ], out: [ "hci/hci_packets.h", "l2cap/l2cap_packets.h", ], } filegroup { name: "BluetoothFacadeProto", srcs: [ "facade/common.proto", "facade/rootservice.proto", "hal/facade.proto", "hci/facade.proto", "l2cap/facade.proto", ], } genrule { name: "BluetoothFacadeGeneratedStub_h", tools: [ "aprotoc", "protoc-gen-grpc-cpp-plugin", ], 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)", srcs: [ ":BluetoothFacadeProto", ], out: [ "facade/common.grpc.pb.h", "facade/common.pb.h", "facade/rootservice.grpc.pb.h", "facade/rootservice.pb.h", "hal/facade.grpc.pb.h", "hal/facade.pb.h", "hci/facade.grpc.pb.h", "hci/facade.pb.h", "l2cap/facade.grpc.pb.h", "l2cap/facade.pb.h", ], } genrule { name: "BluetoothFacadeGeneratedStub_cc", tools: [ "aprotoc", "protoc-gen-grpc-cpp-plugin", ], 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)", srcs: [ ":BluetoothFacadeProto", ], out: [ "facade/common.grpc.pb.cc", "facade/common.pb.cc", "facade/rootservice.grpc.pb.cc", "facade/rootservice.pb.cc", "hal/facade.grpc.pb.cc", "hal/facade.pb.cc", "hci/facade.grpc.pb.cc", "hci/facade.pb.cc", "l2cap/facade.grpc.pb.cc", "l2cap/facade.pb.cc", ], } genrule { name: "BluetoothFacadeAndCertGeneratedStub_py", tools: [ "aprotoc", "protoc-gen-grpc-python-plugin", ], 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); " + "touch $(genDir)/facade/__init__.py; " + "touch $(genDir)/hal/__init__.py; " + "touch $(genDir)/hal/cert/__init__.py; " + "touch $(genDir)/hci/__init__.py; " + "touch $(genDir)/hci/cert/__init__.py; " + "touch $(genDir)/l2cap/__init__.py; " + "touch $(genDir)/l2cap/cert/__init__.py; ", srcs: [ ":BluetoothFacadeProto", ":BluetoothCertStackProto", ], out: [ "cert/rootservice_pb2_grpc.py", "cert/rootservice_pb2.py", "facade/__init__.py", "facade/common_pb2_grpc.py", "facade/common_pb2.py", "facade/rootservice_pb2_grpc.py", "facade/rootservice_pb2.py", "hal/__init__.py", "hal/facade_pb2_grpc.py", "hal/facade_pb2.py", "hci/__init__.py", "hci/facade_pb2_grpc.py", "hci/facade_pb2.py", "l2cap/__init__.py", "l2cap/facade_pb2_grpc.py", "l2cap/facade_pb2.py", "hal/cert/__init__.py", "hal/cert/api_pb2_grpc.py", "hal/cert/api_pb2.py", "hci/cert/__init__.py", "hci/cert/api_pb2_grpc.py", "hci/cert/api_pb2.py", "l2cap/cert/__init__.py", "l2cap/cert/api_pb2_grpc.py", "l2cap/cert/api_pb2.py", ], } filegroup { name: "BluetoothCertStackProto", srcs: [ "cert/rootservice.proto", "hal/cert/api.proto", "hci/cert/api.proto", "l2cap/cert/api.proto", ], } genrule { name: "BluetoothCertStackGeneratedStub_h", tools: [ "aprotoc", "protoc-gen-grpc-cpp-plugin", ], 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)", srcs: [ ":BluetoothCertStackProto", ":BluetoothFacadeProto", // we need to use facade/common.proto ], out: [ "cert/rootservice.grpc.pb.h", "cert/rootservice.pb.h", "facade/common.grpc.pb.h", "facade/common.pb.h", "hal/cert/api.grpc.pb.h", "hal/cert/api.pb.h", "hci/cert/api.grpc.pb.h", "hci/cert/api.pb.h", "l2cap/cert/api.grpc.pb.h", "l2cap/cert/api.pb.h", ], } genrule { name: "BluetoothCertStackGeneratedStub_cc", tools: [ "aprotoc", "protoc-gen-grpc-cpp-plugin", ], 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)", srcs: [ ":BluetoothCertStackProto", ":BluetoothFacadeProto", // we need to use facade/common.proto ], out: [ "cert/rootservice.grpc.pb.cc", "cert/rootservice.pb.cc", "facade/common.grpc.pb.cc", "facade/common.pb.cc", "hal/cert/api.grpc.pb.cc", "hal/cert/api.pb.cc", "hci/cert/api.grpc.pb.cc", "hci/cert/api.pb.cc", "l2cap/cert/api.grpc.pb.cc", "l2cap/cert/api.pb.cc", ], }