1// Bluetooth main HW module / shared library for target
2// ========================================================
3package {
4    // See: http://go/android-license-faq
5    // A large-scale-change added 'default_applicable_licenses' to import
6    // all of the 'license_kinds' from "system_bt_license"
7    // to get the below license kinds:
8    //   SPDX-license-identifier-Apache-2.0
9    default_applicable_licenses: ["system_bt_license"],
10}
11
12filegroup {
13    name: "LibBluetoothSources",
14    srcs: [
15        "bte_conf.cc",
16        "bte_init_cpp_logging.cc",
17        "bte_logmsg.cc",
18        "bte_main.cc",
19        "stack_config.cc",
20    ]
21}
22
23cc_library_static {
24    name: "libbte",
25    defaults: ["fluoride_defaults"],
26    srcs: [
27        ":LibBluetoothSources",
28        ":LibBluetoothShimSources",
29    ],
30    include_dirs: [
31        "system/bt",
32        "system/bt/gd",
33        "system/bt/gd/rust/shim",
34        "system/bt/bta/include",
35        "system/bt/bta/sys",
36        "system/bt/bta/dm",
37        "system/bt/btcore/include",
38        "system/bt/internal_include",
39        "system/bt/stack/include",
40        "system/bt/stack/l2cap",
41        "system/bt/stack/a2dp",
42        "system/bt/stack/btm",
43        "system/bt/stack/avdt",
44        "system/bt/udrv/include",
45        "system/bt/btif/include",
46        "system/bt/btif/co",
47        "system/bt/hci/include",
48        "system/bt/vnd/include",
49        "system/bt/embdrv/sbc/encoder/include",
50        "system/bt/embdrv/sbc/decoder/include",
51        "system/bt/utils/include",
52        "system/security/keystore/include",
53        "hardware/interfaces/keymaster/4.0/support/include",
54    ],
55    shared_libs: [
56            "libflatbuffers-cpp",
57    ],
58    generated_headers: [
59        "BluetoothGeneratedBundlerSchema_h_bfbs",
60        "BluetoothGeneratedDumpsysDataSchema_h",
61        "BluetoothGeneratedPackets_h",
62    ],
63    header_libs: ["libbt_callbacks_cxx_headers"],
64    host_supported: true,
65}
66
67cc_library_shared {
68    name: "libbluetooth",
69    defaults: ["fluoride_defaults"],
70    header_libs: ["libbluetooth_headers"],
71    export_header_lib_headers: ["libbluetooth_headers"],
72    include_dirs: [
73        "system/bt",
74        "system/bt/bta/include",
75        "system/bt/bta/sys",
76        "system/bt/bta/dm",
77        "system/bt/btcore/include",
78        "system/bt/internal_include",
79        "system/bt/stack/include",
80        "system/bt/stack/l2cap",
81        "system/bt/stack/a2dp",
82        "system/bt/stack/btm",
83        "system/bt/stack/avdt",
84        "system/bt/udrv/include",
85        "system/bt/btif/include",
86        "system/bt/btif/co",
87        "system/bt/hci/include",
88        "system/bt/vnd/include",
89        "system/bt/embdrv/sbc/encoder/include",
90        "system/bt/embdrv/sbc/decoder/include",
91        "system/bt/utils/include",
92        "system/security/keystore/include",
93        "hardware/interfaces/keymaster/4.0/support/include",
94    ],
95    logtags: ["../EventLogTags.logtags"],
96    shared_libs: [
97        "android.hardware.bluetooth.a2dp@1.0",
98        "android.hardware.bluetooth.audio@2.0",
99        "android.hardware.bluetooth.audio@2.1",
100        "android.hardware.bluetooth@1.0",
101        "android.hardware.bluetooth@1.1",
102        "libbinder_ndk",
103        "libcrypto",
104        "libcutils",
105        "libflatbuffers-cpp",
106        "libhidlbase",
107        "liblog",
108        "libprocessgroup",
109        "libprotobuf-cpp-lite",
110        "libtinyxml2",
111        "libutils",
112        "libz",
113    ],
114    static_libs: [
115        "libbte",
116        "libbt-sbc-decoder",
117        "libbt-sbc-encoder",
118        "libFraunhoferAAC",
119        "libg722codec",
120        "libudrv-uipc",
121        "libbluetooth_gd", // Gabeldorsche
122        "libbluetooth_rust_interop",
123    ],
124    whole_static_libs: [
125        "libbt-bta",
126        "libbt-common",
127        "libbtdevice",
128        "libbtif",
129        "libbt-hci",
130        "libbt-stack",
131        "libbt-utils",
132        "libbtcore",
133        "libosi",
134        "libbt-protos-lite",
135    ],
136    target: {
137        android: {
138            shared_libs: [
139                "android.system.suspend.control-V1-ndk",
140                "android.system.suspend@1.0",
141                "libaaudio",
142                "libfmq",
143            ],
144            required: [
145                "libldacBT_enc",
146                "libldacBT_abr",
147            ],
148        },
149    },
150    // Shared library link options.
151    // References to global symbols and functions should bind to the library
152    // itself. This is to avoid issues with some of the unit/system tests
153    // that might link statically with some of the code in the library, and
154    // also dlopen(3) the shared library.
155    ldflags: ["-Wl,-Bsymbolic,-Bsymbolic-functions"],
156    required: [
157        "bt_did.conf",
158        "bt_stack.conf",
159    ],
160    cflags: [
161        "-DBUILDCFG",
162    ],
163    sanitize: {
164        never: true,
165    },
166    host_supported: true,
167}
168
169cc_library_static {
170    name: "libbluetooth-for-tests",
171    defaults: ["fluoride_defaults"],
172
173    srcs: [
174        ":LibBluetoothSources",
175        ":LibBluetoothShimSources",
176    ],
177    host_supported: true,
178    include_dirs: [
179        "system/bt",
180        "system/bt/gd",
181        "system/bt/gd/rust/shim",
182        "system/bt/bta/include",
183        "system/bt/btcore/include",
184        "system/bt/btif/include",
185        "system/bt/hci/include",
186        "system/bt/internal_include",
187        "system/bt/stack/include",
188        "system/bt/utils/include",
189    ],
190    generated_headers: [
191        "BluetoothGeneratedBundlerSchema_h_bfbs",
192        "BluetoothGeneratedPackets_h",
193        "BluetoothGeneratedDumpsysDataSchema_h",
194    ],
195    cflags: [
196        "-DBUILDCFG",
197    ],
198    shared_libs: [
199        "libflatbuffers-cpp",
200    ],
201    whole_static_libs: [
202        "libbluetooth_gd", // Gabeldorsche
203    ],
204}
205
206cc_test {
207    name: "net_test_main_shim",
208    test_suites: ["device-tests"],
209    host_supported: true,
210    test_options: {
211        unit_test: true,
212    },
213    defaults: ["fluoride_defaults"],
214    include_dirs: [
215        "system/bt",
216        "system/bt/gd",
217        "system/bt/stack/include",
218    ],
219    srcs: [
220        ":TestMockBta",
221        ":TestMockBtif",
222        ":TestMockLegacyHciCommands",
223        ":TestMockMainShimEntry",
224        ":TestMockStack",
225        "shim/acl_api.cc",
226        "shim/acl.cc",
227        "shim/acl_legacy_interface.cc",
228        "shim/btm_api.cc",
229        "shim/btm.cc",
230        "shim/config.cc",
231        "shim/controller.cc",
232        "shim/dumpsys.cc",
233        "shim/hci_layer.cc",
234        "shim/l2c_api.cc",
235        "shim/le_advertising_manager.cc",
236        "shim/le_scanning_manager.cc",
237        "shim/link_policy.cc",
238        "shim/metric_id_api.cc",
239        "shim/metrics_api.cc",
240        "shim/shim.cc",
241        "shim/stack.cc",
242        "test/main_shim_test.cc",
243    ],
244    static_libs: [
245        "libbt-common",
246        "libbt-protos-lite",
247        "libgmock",
248        "liblog",
249        "libosi",
250        "libbtdevice",
251    ],
252    shared_libs: [
253        "libcrypto",
254        "libflatbuffers-cpp",
255        "libprotobuf-cpp-lite",
256    ],
257    sanitize: {
258        address: true,
259        all_undefined: true,
260        cfi: true,
261        integer_overflow: true,
262        scs: true,
263        diag: {
264            undefined : true
265        },
266    },
267    generated_headers: [
268        "BluetoothGeneratedBundlerSchema_h_bfbs",
269        "BluetoothGeneratedDumpsysDataSchema_h",
270        "BluetoothGeneratedDumpsysBundledSchema_h",
271        "BluetoothGeneratedPackets_h",
272    ],
273}
274