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    //   SPDX-license-identifier-MIT
9    //   legacy_unencumbered
10    default_applicable_licenses: ["system_bt_license"],
11}
12
13filegroup {
14    name: "BlueberryFacadeProto",
15    srcs: [
16        "blueberry/facade/common.proto",
17        "blueberry/facade/hal/hal_facade.proto",
18        "blueberry/facade/hci/acl_manager_facade.proto",
19        "blueberry/facade/hci/controller_facade.proto",
20        "blueberry/facade/hci/hci_facade.proto",
21        "blueberry/facade/hci/le_acl_manager_facade.proto",
22        "blueberry/facade/hci/le_advertising_manager_facade.proto",
23        "blueberry/facade/hci/le_initiator_address_facade.proto",
24        "blueberry/facade/hci/le_scanning_manager_facade.proto",
25        "blueberry/facade/l2cap/classic/facade.proto",
26        "blueberry/facade/l2cap/le/facade.proto",
27        "blueberry/facade/neighbor/facade.proto",
28        "blueberry/facade/rootservice.proto",
29        "blueberry/facade/topshim/facade.proto",
30    ],
31}
32
33filegroup {
34    name: "TestMockCodecManager",
35    srcs: [
36        "bta/le_audio/mock_codec_manager.cc",
37    ],
38}
39
40genrule {
41    name: "BlueberryFacadeGeneratedStub_h",
42    tools: [
43        "aprotoc",
44        "protoc-gen-grpc-cpp-plugin",
45    ],
46    cmd: "$(location aprotoc) -Ipackages/modules/Bluetooth/system -Iexternal/protobuf/src --plugin=protoc-gen-grpc=$(location protoc-gen-grpc-cpp-plugin) $(locations :BlueberryFacadeProto) --grpc_out=$(genDir) --cpp_out=$(genDir)",
47    srcs: [
48        ":BlueberryFacadeProto",
49        ":libprotobuf-internal-protos",
50    ],
51    out: [
52        "blueberry/facade/common.grpc.pb.h",
53        "blueberry/facade/common.pb.h",
54        "blueberry/facade/hal/hal_facade.grpc.pb.h",
55        "blueberry/facade/hal/hal_facade.pb.h",
56        "blueberry/facade/hci/acl_manager_facade.grpc.pb.h",
57        "blueberry/facade/hci/acl_manager_facade.pb.h",
58        "blueberry/facade/hci/controller_facade.grpc.pb.h",
59        "blueberry/facade/hci/controller_facade.pb.h",
60        "blueberry/facade/hci/hci_facade.grpc.pb.h",
61        "blueberry/facade/hci/hci_facade.pb.h",
62        "blueberry/facade/hci/le_acl_manager_facade.grpc.pb.h",
63        "blueberry/facade/hci/le_acl_manager_facade.pb.h",
64        "blueberry/facade/hci/le_advertising_manager_facade.grpc.pb.h",
65        "blueberry/facade/hci/le_advertising_manager_facade.pb.h",
66        "blueberry/facade/hci/le_initiator_address_facade.grpc.pb.h",
67        "blueberry/facade/hci/le_initiator_address_facade.pb.h",
68        "blueberry/facade/hci/le_scanning_manager_facade.grpc.pb.h",
69        "blueberry/facade/hci/le_scanning_manager_facade.pb.h",
70        "blueberry/facade/l2cap/classic/facade.grpc.pb.h",
71        "blueberry/facade/l2cap/classic/facade.pb.h",
72        "blueberry/facade/l2cap/le/facade.grpc.pb.h",
73        "blueberry/facade/l2cap/le/facade.pb.h",
74        "blueberry/facade/neighbor/facade.grpc.pb.h",
75        "blueberry/facade/neighbor/facade.pb.h",
76        "blueberry/facade/rootservice.grpc.pb.h",
77        "blueberry/facade/rootservice.pb.h",
78    ],
79}
80
81genrule {
82    name: "BlueberryFacadeGeneratedStub_cc",
83    tools: [
84        "aprotoc",
85        "protoc-gen-grpc-cpp-plugin",
86    ],
87    cmd: "$(location aprotoc) -Ipackages/modules/Bluetooth/system -Iexternal/protobuf/src --plugin=protoc-gen-grpc=$(location protoc-gen-grpc-cpp-plugin) $(locations :BlueberryFacadeProto) --grpc_out=$(genDir) --cpp_out=$(genDir)",
88    srcs: [
89        ":BlueberryFacadeProto",
90        ":libprotobuf-internal-protos",
91    ],
92    out: [
93        "blueberry/facade/common.grpc.pb.cc",
94        "blueberry/facade/common.pb.cc",
95        "blueberry/facade/hal/hal_facade.grpc.pb.cc",
96        "blueberry/facade/hal/hal_facade.pb.cc",
97        "blueberry/facade/hci/acl_manager_facade.grpc.pb.cc",
98        "blueberry/facade/hci/acl_manager_facade.pb.cc",
99        "blueberry/facade/hci/controller_facade.grpc.pb.cc",
100        "blueberry/facade/hci/controller_facade.pb.cc",
101        "blueberry/facade/hci/hci_facade.grpc.pb.cc",
102        "blueberry/facade/hci/hci_facade.pb.cc",
103        "blueberry/facade/hci/le_acl_manager_facade.grpc.pb.cc",
104        "blueberry/facade/hci/le_acl_manager_facade.pb.cc",
105        "blueberry/facade/hci/le_advertising_manager_facade.grpc.pb.cc",
106        "blueberry/facade/hci/le_advertising_manager_facade.pb.cc",
107        "blueberry/facade/hci/le_initiator_address_facade.grpc.pb.cc",
108        "blueberry/facade/hci/le_initiator_address_facade.pb.cc",
109        "blueberry/facade/hci/le_scanning_manager_facade.grpc.pb.cc",
110        "blueberry/facade/hci/le_scanning_manager_facade.pb.cc",
111        "blueberry/facade/l2cap/classic/facade.grpc.pb.cc",
112        "blueberry/facade/l2cap/classic/facade.pb.cc",
113        "blueberry/facade/l2cap/le/facade.grpc.pb.cc",
114        "blueberry/facade/l2cap/le/facade.pb.cc",
115        "blueberry/facade/neighbor/facade.grpc.pb.cc",
116        "blueberry/facade/neighbor/facade.pb.cc",
117        "blueberry/facade/rootservice.grpc.pb.cc",
118        "blueberry/facade/rootservice.pb.cc",
119    ],
120}
121
122genrule {
123    name: "BlueberryFacadeAndCertGeneratedStub_py",
124    tools: [
125        "aprotoc",
126        "protoc-gen-grpc-python-plugin",
127        "soong_zip",
128    ],
129    cmd: "mkdir -p $(genDir)/files && " +
130        "$(location aprotoc) -Ipackages/modules/Bluetooth/system -Iexternal/protobuf/src --plugin=protoc-gen-grpc=$(location protoc-gen-grpc-python-plugin) $(locations :BlueberryFacadeProto) --grpc_out=$(genDir)/files --python_out=$(genDir)/files && " +
131        "for dir in `find $(genDir)/files -type d`; do touch $$dir/__init__.py; done &&" +
132        "$(location soong_zip) -C $(genDir)/files -D $(genDir)/files -o $(out)",
133    srcs: [
134        ":BlueberryFacadeProto",
135        ":libprotobuf-internal-protos",
136    ],
137    out: ["blueberry_facade_generated_py.zip"],
138}
139
140rust_protobuf {
141    name: "libbt_topshim_facade_protobuf",
142    crate_name: "bt_topshim_facade_protobuf",
143    source_stem: "topshim_facade",
144    host_supported: true,
145    grpc_protos: ["blueberry/facade/topshim/facade.proto"],
146}
147
148// Export system headers for rules that can't simply use `include_dirs`
149cc_library_headers {
150    name: "libbluetooth_system_headers",
151    visibility: [
152        "//packages/modules/Bluetooth/system:__subpackages__",
153    ],
154    export_include_dirs: ["./"],
155    vendor_available: true,
156    host_supported: true,
157    apex_available: [
158        "//apex_available:platform",
159        "com.android.btservices",
160    ],
161    min_sdk_version: "30",
162}
163
164genrule {
165    name: "bluetooth_cert_test_sources-zip",
166    tools: [
167        "soong_zip",
168    ],
169    srcs: [
170        "blueberry/**/*.py",
171        "blueberry/**/*.yaml",
172        "setup.py",
173    ],
174    out: ["bluetooth_cert_test_sources.zip"],
175    cmd: "echo $(in) > $(genDir)/file_list.txt && " +
176        "$(location soong_zip) -C packages/modules/Bluetooth/system -l $(genDir)/file_list.txt -o $(out)",
177}
178
179genrule {
180    name: "gd_hci_packets_python3_gen-zip",
181    tools: [
182        "soong_zip",
183    ],
184    srcs: [
185        ":gd_hci_packets_python3_gen",
186    ],
187    out: ["gd_hci_packets_python3_gen.zip"],
188    cmd: "echo $(in) > $(genDir)/file_list.txt && " +
189        "$(location soong_zip) -j -l $(genDir)/file_list.txt -o $(out)",
190}
191
192genrule {
193    name: "gd_smp_packets_python3_gen-zip",
194    tools: [
195        "soong_zip",
196    ],
197    srcs: [
198        ":gd_smp_packets_python3_gen",
199    ],
200    out: ["gd_smp_packets_python3_gen.zip"],
201    cmd: "echo $(in) > $(genDir)/file_list.txt && " +
202        "$(location soong_zip) -j -l $(genDir)/file_list.txt -o $(out)",
203}
204
205cc_genrule {
206    name: "bluetooth_cert_test_host_deps-zip",
207    host_supported: true,
208    device_supported: false,
209    compile_multilib: "first",
210    tools: [
211        "bluetooth_stack_with_facade",
212        "bt_topshim_facade",
213        "root-canal",
214        "soong_zip",
215    ],
216    srcs: [
217        ":libbase",
218        ":libbinder",
219        ":libbinder_ndk",
220        ":libbluetooth",
221        ":libbluetooth_gd",
222        ":libc++",
223        ":libchrome",
224        ":libcrypto",
225        ":libcutils",
226        ":libevent",
227        ":libflatbuffers-cpp",
228        ":libgrpc++",
229        ":libgrpc_wrap",
230        ":liblog",
231        ":liblzma",
232        ":libprotobuf-cpp-full",
233        ":libssl",
234        ":libunwindstack",
235        ":libutils",
236        ":libz",
237        ":server_configurable_flags",
238    ],
239    out: ["bluetooth_cert_test_host_deps.zip"],
240    cmd: "echo $(in) > $(genDir)/file_list.txt && " +
241        "$(location soong_zip) -j -f $(location bluetooth_stack_with_facade) -f $(location bt_topshim_facade) -f $(location root-canal) -P lib64 -l $(genDir)/file_list.txt -o $(out)",
242}
243
244cc_genrule {
245    name: "bluetooth_cert_test_target_deps-zip",
246    compile_multilib: "first",
247    tools: [
248        "soong_zip",
249    ],
250    srcs: [
251        // executables
252        ":bluetooth_stack_with_facade",
253        // libs
254        ":[email protected]",
255        ":[email protected]",
256        ":libandroid_runtime_lazy",
257        ":libbase",
258        ":libbinder",
259        ":libbinder_ndk",
260        ":libc++",
261        ":libcrypto",
262        ":libcutils",
263        ":libgrpc++",
264        ":libgrpc_wrap",
265        ":libhidlbase",
266        ":liblog",
267        ":liblzma",
268        ":libprotobuf-cpp-full",
269        ":libssl",
270        ":libunwindstack",
271        ":libutils",
272        ":libz",
273        ":server_configurable_flags",
274    ],
275    out: ["bluetooth_cert_test_target_deps.zip"],
276    cmd: "echo $(in) > $(genDir)/file_list.txt && " +
277        "$(location soong_zip) -j -P target -l $(genDir)/file_list.txt -o $(out)",
278}
279
280genrule {
281    name: "llvm-tools-zip",
282    tools: [
283        "soong_zip",
284    ],
285    srcs: [
286        ":llvm-tools",
287    ],
288    out: ["llvm-tools.zip"],
289    cmd: "mkdir -p $(genDir)/llvm_binutils/bin && mkdir -p $(genDir)/llvm_binutils/lib/x86_64-unknown-linux-gnu && " +
290        "cp prebuilts/clang/host/linux-x86/*/bin/llvm-cov $(genDir)/llvm_binutils/bin && " +
291        "cp prebuilts/clang/host/linux-x86/*/bin/llvm-profdata $(genDir)/llvm_binutils/bin && " +
292        "cp prebuilts/clang/host/linux-x86/*/bin/llvm-symbolizer $(genDir)/llvm_binutils/bin && " +
293        "cp prebuilts/clang/host/linux-x86/*/lib/x86_64-unknown-linux-gnu/libc++.so $(genDir)/llvm_binutils/lib/x86_64-unknown-linux-gnu && " +
294        "$(location soong_zip) -C $(genDir) -D $(genDir)/llvm_binutils -o $(out)",
295}
296
297cc_genrule {
298    name: "bluetooth_cert_tests.zip",
299    host_supported: true,
300    device_supported: false,
301    compile_multilib: "first",
302    tools: [
303        "merge_zips",
304        "soong_zip",
305    ],
306    srcs: [
307        ":BlueberryFacadeAndCertGeneratedStub_py",
308        ":bluetooth_cert_test_host_deps-zip",
309        ":bluetooth_cert_test_sources-zip",
310        ":gd_hci_packets_python3_gen-zip",
311        ":gd_smp_packets_python3_gen-zip",
312        ":llvm-tools-zip",
313    ],
314    device_first_srcs: [
315        ":bluetooth_cert_test_target_deps-zip",
316    ],
317    out: ["bluetooth_cert_tests.zip"],
318    cmd: "$(location merge_zips) $(genDir)/temp.zip $(in) && " +
319        "unzip -q -d $(genDir)/files $(genDir)/temp.zip && " +
320        "for d in $$(find $(genDir)/files/blueberry -type d -name '*'); do touch -a $$d/__init__.py; done && " +
321        "$(location soong_zip) -C $(genDir)/files -D $(genDir)/files -o $(out)",
322    dist: {
323        targets: [
324            "bluetooth_stack_with_facade",
325        ],
326    },
327}
328