1package {
2    // See: http://go/android-license-faq
3    // A large-scale-change added 'default_applicable_licenses' to import
4    // all of the 'license_kinds' from "system_bt_license"
5    // to get the below license kinds:
6    //   SPDX-license-identifier-Apache-2.0
7    //   SPDX-license-identifier-BSD
8    default_applicable_licenses: ["system_bt_license"],
9}
10
11cc_defaults {
12    name: "gd_defaults",
13    defaults: [
14        "bluetooth_cflags",
15        "bluetooth_tidy",
16    ],
17    target: {
18        android: {
19            test_config_template: "AndroidTestTemplate.xml",
20            shared_libs: [
21                "liblog",
22            ],
23            sanitize: {
24                misc_undefined: ["bounds"],
25            },
26        },
27        darwin: {
28            enabled: false,
29        },
30    },
31    cflags: [
32        "-DEXPORT_SYMBOL=__attribute__((visibility(\"default\")))",
33        "-DGOOGLE_PROTOBUF_NO_RTTI",
34        "-DLOG_NDEBUG=0",
35        "-fvisibility=hidden",
36    ],
37    header_libs: ["jni_headers"],
38}
39
40soong_config_module_type {
41    name: "mgmt_cc_defaults",
42    module_type: "cc_defaults",
43    config_namespace: "mgmt",
44    variables: ["vertical"],
45    properties: ["srcs"],
46}
47
48soong_config_string_variable {
49    name: "vertical",
50    values: [
51        "android_default",
52        "android_desktop",
53    ],
54}
55
56mgmt_cc_defaults {
57    name: "mgmt_defaults",
58    soong_config_variables: {
59        vertical: {
60            android_desktop: {
61                srcs: [":BluetoothOsSources_mgmt_linux"],
62            },
63            android_default: {
64                srcs: [":BluetoothOsSources_mgmt"],
65            },
66            conditions_default: {
67                srcs: [":BluetoothOsSources_mgmt"],
68            },
69        },
70    },
71}
72
73cc_defaults {
74    name: "libbluetooth_gd_defaults",
75    defaults: [
76        "gd_defaults",
77        "mgmt_defaults",
78    ],
79    host_supported: true,
80    target: {
81        linux: {
82            srcs: [
83                ":BluetoothOsSources_linux_generic",
84            ],
85        },
86        host: {
87            srcs: [
88                ":BluetoothHalSources_hci_host",
89                ":BluetoothHalSources_ranging_host",
90                ":BluetoothHalSources_socket_host",
91                ":BluetoothOsSources_host",
92                ":BluetoothSyspropsSources",
93            ],
94        },
95        android: {
96            srcs: [
97                ":BluetoothHalSources_hci_android_hidl",
98                ":BluetoothHalSources_ranging_android",
99                ":BluetoothHalSources_socket_android",
100                ":BluetoothOsSources_android",
101            ],
102            shared_libs: [
103                "[email protected]",
104                "[email protected]",
105                "android.system.suspend-V1-ndk",
106                "android.system.suspend.control-V1-ndk",
107                "libbinder_ndk",
108                "libcutils",
109                "libhidlbase",
110                "libstatslog_bt",
111                "libstatssocket",
112                "libutils",
113            ],
114            static_libs: [
115                "libexpresslog",
116                "libstatslog_express",
117                "libtextclassifier_hash_static",
118            ],
119            whole_static_libs: [
120                "android.hardware.bluetooth-V1-ndk",
121                "android.hardware.bluetooth.ranging-V2-ndk",
122                "android.hardware.bluetooth.socket-V1-ndk",
123                "android.hardware.contexthub-V4-ndk",
124            ],
125        },
126    },
127    srcs: [
128        ":BluetoothCommonSources",
129        ":BluetoothHalSources",
130        ":BluetoothHciSources",
131        ":BluetoothLppOffloadSources",
132        ":BluetoothMetricsSources",
133        ":BluetoothNeighborSources",
134        ":BluetoothOsSources",
135        ":BluetoothPacketSources",
136        ":BluetoothShimSources",
137        ":BluetoothStorageSources",
138        "module.cc",
139        "stack_manager.cc",
140    ],
141    shared_libs: [
142        "libcrypto",
143        "libflatbuffers-cpp",
144        "liblog",
145    ],
146    export_shared_lib_headers: [
147        "libflatbuffers-cpp",
148    ],
149    whole_static_libs: [
150        "libbluetooth_hci_pdl",
151        "libbluetooth_l2cap_pdl",
152        "libbluetooth_ras_pdl",
153        "libbluetooth_smp_pdl",
154    ],
155    static_libs: [
156        "libaconfig_storage_read_api_cc",
157        "libbase",
158        "libbluetooth-protos",
159        "libbluetooth-types",
160        "libbluetooth_crypto_toolbox",
161        "libbluetooth_log",
162        "libbt-common",
163        "libbt-platform-protos-lite",
164        "libcom.android.sysprop.bluetooth.wrapped",
165        "libosi",
166        "server_configurable_flags",
167    ],
168    include_dirs: [
169        "packages/modules/Bluetooth/system/include",
170        "packages/modules/Bluetooth/system/stack/include",
171    ],
172}
173
174cc_library_static {
175    name: "libbluetooth_gd",
176    defaults: [
177        "libbluetooth_gd_defaults",
178    ],
179    include_dirs: [
180        "packages/modules/Bluetooth/system",
181    ],
182    apex_available: [
183        "com.android.btservices",
184    ],
185    min_sdk_version: "31",
186    static_libs: [
187        "bluetooth_flags_c_lib",
188        "libchrome",
189    ],
190}
191
192cc_library_static {
193    name: "libbluetooth_gd_fuzzing",
194    defaults: [
195        "libbluetooth_gd_defaults",
196    ],
197    include_dirs: [
198        "packages/modules/Bluetooth/system",
199    ],
200    srcs: [
201        ":BluetoothOsSources_fake_timer",
202    ],
203    cflags: [
204        "-DFUZZ_TARGET",
205        "-DUSE_FAKE_TIMERS",
206    ],
207    static_libs: [
208        "bluetooth_flags_c_lib",
209        "libbluetooth-types",
210        "libbt-common",
211        "libchrome",
212        "libosi",
213    ],
214}
215
216cc_library_static {
217    name: "libbluetooth_gd_unit_tests",
218    defaults: [
219        "libbluetooth_gd_defaults",
220    ],
221    include_dirs: [
222        "packages/modules/Bluetooth/system",
223    ],
224    srcs: [
225        ":BluetoothOsSources_fake_timer",
226    ],
227    cflags: [
228        "-DUSE_FAKE_TIMERS",
229    ],
230    static_libs: [
231        "bluetooth_flags_c_lib_for_test",
232        "libbluetooth-types",
233        "libbt-common",
234        "libchrome",
235        "libosi",
236    ],
237}
238
239cc_binary {
240    name: "bluetooth_stack_with_facade",
241    defaults: [
242        "gd_defaults",
243    ],
244    cflags: [
245        // The generated gRPC code triggers these warnings.
246        "-Wno-missing-prototypes",
247    ],
248    include_dirs: [
249        "packages/modules/Bluetooth/system",
250        "packages/modules/Bluetooth/system/include",
251    ],
252    host_supported: true,
253    srcs: [
254        ":BluetoothFacade_hci_hal",
255        ":BluetoothFacade_hci_layer",
256        ":BluetoothFacade_neighbor",
257        ":TestCommonMockFunctions",
258        ":TestMockMainShimStack",
259        ":TestMockStackMetrics",
260        "facade/facade_main.cc",
261        "facade/grpc_root_server.cc",
262        "facade/read_only_property_server.cc",
263        "grpc/grpc_module.cc",
264    ],
265    generated_headers: [
266        "BlueberryFacadeGeneratedStub_h",
267    ],
268    generated_sources: [
269        "BlueberryFacadeGeneratedStub_cc",
270    ],
271    static_libs: [
272        "bluetooth_flags_c_lib",
273        "breakpad_client",
274        "libPlatformProperties",
275        "libbluetooth-protos",
276        "libbluetooth-types",
277        "libbluetooth_crypto_toolbox",
278        "libbluetooth_gd",
279        "libbluetooth_hci_pdl",
280        "libbluetooth_l2cap_pdl",
281        "libbluetooth_log",
282        "libbluetooth_ras_pdl",
283        "libbluetooth_smp_pdl",
284        "libbt-common",
285        "libbt-platform-protos-lite",
286        "libchrome",
287        "libcom.android.sysprop.bluetooth.wrapped",
288        "libflatbuffers-cpp",
289        "libosi",
290    ],
291    shared_libs: [
292        "libaconfig_storage_read_api_cc",
293        "libbase",
294        "libcrypto",
295        "libgrpc++",
296        "libgrpc_wrap",
297        "liblog",
298        "libprotobuf-cpp-full",
299        "libunwindstack",
300        "server_configurable_flags",
301    ],
302    target: {
303        android: {
304            shared_libs: [
305                "[email protected]",
306                "[email protected]",
307                "libbinder_ndk",
308                "libcutils",
309                "libhidlbase",
310                "libstatssocket",
311                "libutils",
312            ],
313            static_libs: [
314                "android.system.suspend-V1-ndk",
315                "android.system.suspend.control-V1-ndk",
316                "libstatslog_bt",
317            ],
318        },
319        host: {
320            required: [
321                "root-canal",
322            ],
323        },
324    },
325    sanitize: {
326        address: true,
327        cfi: true,
328    },
329}
330
331cc_test {
332    name: "bluetooth_test_with_timerfd",
333    test_suites: ["general-tests"],
334    defaults: [
335        "gd_defaults",
336        "mts_defaults",
337    ],
338    include_dirs: [
339        "packages/modules/Bluetooth/system",
340        "packages/modules/Bluetooth/system/include",
341    ],
342    host_supported: true,
343    target: {
344        host: {
345            srcs: [
346                ":BluetoothOsSystemProperties_host",
347            ],
348        },
349        android: {
350            srcs: [
351                ":BluetoothOsSystemProperties_android",
352            ],
353        },
354    },
355    srcs: [
356        ":BluetoothOsTestSources_timerfd",
357    ],
358    static_libs: [
359        "bluetooth_flags_c_lib_for_test",
360        "libbluetooth_log",
361        "libchrome",
362        "libgmock",
363        "server_configurable_flags",
364    ],
365    shared_libs: [
366        "libbase",
367        "liblog",
368    ],
369    sanitize: {
370        address: true,
371    },
372    min_sdk_version: "Tiramisu",
373}
374
375cc_test {
376    name: "bluetooth_test_gd_unit",
377    test_suites: ["general-tests"],
378    defaults: [
379        "gd_defaults",
380        "mts_defaults",
381    ],
382    include_dirs: [
383        "packages/modules/Bluetooth/system",
384        "packages/modules/Bluetooth/system/include",
385    ],
386    host_supported: true,
387    // TODO(b/231993739): Reenable isolated:true by deleting the explicit disable below
388    isolated: false,
389    target: {
390        linux: {
391            srcs: [
392                ":BluetoothOsTestSources_linux_generic",
393            ],
394        },
395        host: {
396            srcs: [
397                ":BluetoothHalTestSources_hci_host",
398                ":BluetoothOsTestSources_host",
399                ":BluetoothSyspropsUnitTestSources",
400            ],
401        },
402        android: {
403            srcs: [
404                ":BluetoothOsTestSources_android",
405            ],
406            static_libs: [
407                "[email protected]",
408                "[email protected]",
409                "android.system.suspend-V1-ndk",
410                "android.system.suspend.control-V1-ndk",
411                "libstatslog_bt",
412            ],
413            shared_libs: [
414                "libbinder_ndk",
415                "libcutils",
416                "libhidlbase",
417                "libstatssocket",
418                "libutils",
419            ],
420        },
421    },
422    srcs: [
423        ":BluetoothCommonTestSources",
424        ":BluetoothCryptoToolboxTestSources",
425        ":BluetoothHalTestSources",
426        ":BluetoothHciUnitTestSources",
427        ":BluetoothMetricsTestSources",
428        ":BluetoothOsTestSources",
429        ":BluetoothPacketTestSources",
430        ":BluetoothStorageUnitTestSources",
431        ":TestCommonMockFunctions",
432        ":TestMockStackMetrics",
433        "module_unittest.cc",
434        "stack_manager_unittest.cc",
435    ],
436    static_libs: [
437        "bluetooth_flags_c_lib_for_test",
438        "libbase",
439        "libbluetooth-protos",
440        "libbluetooth-types",
441        "libbluetooth_crypto_toolbox",
442        "libbluetooth_gd_unit_tests",
443        "libbluetooth_hci_pdl",
444        "libbluetooth_l2cap_pdl",
445        "libbluetooth_log",
446        "libbluetooth_ras_pdl",
447        "libbluetooth_smp_pdl",
448        "libbt-common",
449        "libbt-platform-protos-lite",
450        "libchrome",
451        "libcom.android.sysprop.bluetooth.wrapped",
452        "libflagtest",
453        "libflatbuffers-cpp",
454        "libgmock",
455        "libosi",
456        "server_configurable_flags",
457    ],
458    shared_libs: [
459        "libPlatformProperties",
460        "libaconfig_storage_read_api_cc",
461        "libcrypto",
462    ],
463    sanitize: {
464        address: true,
465    },
466    min_sdk_version: "Tiramisu",
467}
468
469cc_test {
470    name: "bluetooth_packet_parser_test",
471    test_suites: ["general-tests"],
472    defaults: [
473        "gd_defaults",
474        "mts_defaults",
475    ],
476    include_dirs: ["packages/modules/Bluetooth/system/gd"],
477    host_supported: true,
478    test_options: {
479        unit_test: true,
480    },
481    srcs: [
482        ":BluetoothPacketParserTestPacketTestSources",
483        ":BluetoothPacketSources",
484    ],
485    generated_headers: [
486        "BluetoothPacketParserTestPacketPdlGen_h",
487    ],
488    sanitize: {
489        address: true,
490        cfi: true,
491    },
492    static_libs: [
493        "libbase",
494        "libbluetooth_log",
495        "liblog",
496    ],
497    target: {
498        android: {
499            shared_libs: [
500                "libcutils",
501                "libhidlbase",
502                "libutils",
503            ],
504        },
505        host_linux: {
506            shared_libs: [
507                "libcutils",
508                "libhidlbase",
509                "libutils",
510            ],
511        },
512    },
513    min_sdk_version: "30",
514}
515
516cc_defaults {
517    name: "gd_fuzz_defaults",
518    defaults: ["gd_defaults"],
519    srcs: [
520        ":BluetoothFuzzHelperSources",
521        ":BluetoothHciFuzzHelperSources",
522    ],
523    static_libs: [
524        "bluetooth_flags_c_lib",
525        "libbluetooth-protos",
526        "libbluetooth-types",
527        "libbluetooth_crypto_toolbox",
528        "libbluetooth_gd_fuzzing",
529        "libbluetooth_log",
530        "libbt-common",
531        "libchrome",
532        "libcom.android.sysprop.bluetooth.wrapped",
533        "libgmock",
534        "libgtest",
535        "libosi",
536    ],
537    host_supported: true,
538    shared_libs: [
539        "libPlatformProperties",
540        "libaconfig_storage_read_api_cc",
541        "libbase",
542        "libcrypto",
543        "libgrpc++",
544        "libgrpc_wrap",
545        "liblog",
546        "server_configurable_flags",
547    ],
548    cflags: [
549        "-DFUZZ_TARGET",
550        "-DUSE_FAKE_TIMERS",
551    ],
552    target: {
553        android: {
554            shared_libs: [
555                "[email protected]",
556                "[email protected]",
557                "android.system.suspend.control-V1-ndk",
558                "libbinder_ndk",
559                "libcutils",
560                "libhidlbase",
561                "libstatslog_bt",
562                "libutils",
563            ],
564        },
565    },
566}
567
568cc_fuzz {
569    name: "bluetooth_gd_fuzz_test",
570    defaults: ["gd_fuzz_defaults"],
571    srcs: [
572        ":BluetoothHciFuzzTestSources",
573        "fuzz_test.cc",
574    ],
575    fuzz_config: {
576        cc: ["[email protected]"],
577        componentid: 27441,
578    },
579}
580
581cc_fuzz {
582    name: "bluetooth_gd_hci_layer_fuzz_test",
583    defaults: ["gd_fuzz_defaults"],
584    srcs: [
585        ":BluetoothHalFuzzSources",
586        "hci/fuzz/hci_layer_fuzz_test.cc",
587    ],
588}
589
590cc_fuzz {
591    name: "bluetooth_gd_acl_manager_fuzz_test",
592    defaults: ["gd_fuzz_defaults"],
593    srcs: [
594        ":TestCommonMockFunctions",
595        ":TestMockStackMetrics",
596        "hci/fuzz/acl_manager_fuzz_test.cc",
597    ],
598    include_dirs: [
599        "packages/modules/Bluetooth/system",
600    ],
601    static_libs: [
602        "libbt-platform-protos-lite",
603    ],
604    fuzz_config: {
605        cc: ["[email protected]"],
606        componentid: 27441,
607    },
608}
609
610cc_benchmark {
611    name: "bluetooth_benchmark_gd",
612    defaults: [
613        "aconfig_lib_cc_shared_link.defaults",
614        "gd_defaults",
615    ],
616    host_supported: true,
617    srcs: [
618        ":BluetoothOsBenchmarkSources",
619        "benchmark.cc",
620    ],
621    static_libs: [
622        "bluetooth_flags_c_lib",
623        "libbase",
624        "libbluetooth_gd",
625        "libbluetooth_log",
626        "libchrome",
627        "liblog",
628        "server_configurable_flags",
629    ],
630}
631