• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2022 The Pigweed Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14
15load("@com_google_emboss//:build_defs.bzl", "emboss_cc_library")
16load("@rules_cc//cc:cc_library.bzl", "cc_library")
17load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
18load("//pw_build:compatibility.bzl", "incompatible_with_mcu")
19load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")
20
21package(
22    default_visibility = ["//visibility:public"],
23    features = ["-layering_check"],
24)
25
26licenses(["notice"])
27
28label_flag(
29    name = "config",
30    build_setting_default = "//pw_build:default_module_config",
31)
32
33cc_library(
34    name = "pw_bluetooth",
35    hdrs = [
36        "public/pw_bluetooth/address.h",
37        "public/pw_bluetooth/assigned_uuids.h",
38        "public/pw_bluetooth/config.h",
39        "public/pw_bluetooth/constants.h",
40        "public/pw_bluetooth/controller.h",
41        "public/pw_bluetooth/gatt/client.h",
42        "public/pw_bluetooth/gatt/constants.h",
43        "public/pw_bluetooth/gatt/error.h",
44        "public/pw_bluetooth/gatt/server.h",
45        "public/pw_bluetooth/gatt/types.h",
46        "public/pw_bluetooth/host.h",
47        "public/pw_bluetooth/internal/hex.h",
48        "public/pw_bluetooth/internal/raii_ptr.h",
49        "public/pw_bluetooth/low_energy/advertising_data.h",
50        "public/pw_bluetooth/low_energy/bond_data.h",
51        "public/pw_bluetooth/low_energy/central.h",
52        "public/pw_bluetooth/low_energy/connection.h",
53        "public/pw_bluetooth/low_energy/peripheral.h",
54        "public/pw_bluetooth/low_energy/security_mode.h",
55        "public/pw_bluetooth/pairing_delegate.h",
56        "public/pw_bluetooth/peer.h",
57        "public/pw_bluetooth/result.h",
58        "public/pw_bluetooth/types.h",
59        "public/pw_bluetooth/uuid.h",
60        "public/pw_bluetooth/vendor.h",
61    ],
62    includes = ["public"],
63    deps = [
64        "//pw_assert:assert",
65        "//pw_chrono:system_clock",
66        "//pw_containers:vector",
67        "//pw_function",
68        "//pw_multibuf",
69        "//pw_result",
70        "//pw_status",
71        "//pw_string:string",
72    ],
73)
74
75cc_library(
76    name = "pw_bluetooth2",
77    hdrs = [
78        "public/pw_bluetooth/address.h",
79        "public/pw_bluetooth/assigned_uuids.h",
80        "public/pw_bluetooth/config.h",
81        "public/pw_bluetooth/constants.h",
82        "public/pw_bluetooth/controller2.h",
83        "public/pw_bluetooth/gatt/client2.h",
84        "public/pw_bluetooth/gatt/constants.h",
85        "public/pw_bluetooth/gatt/error.h",
86        "public/pw_bluetooth/gatt/server2.h",
87        "public/pw_bluetooth/gatt/types.h",
88        "public/pw_bluetooth/internal/hex.h",
89        "public/pw_bluetooth/internal/raii_ptr.h",
90        "public/pw_bluetooth/low_energy/advertising_data.h",
91        "public/pw_bluetooth/low_energy/bond_data2.h",
92        "public/pw_bluetooth/low_energy/central2.h",
93        "public/pw_bluetooth/low_energy/channel.h",
94        "public/pw_bluetooth/low_energy/connection2.h",
95        "public/pw_bluetooth/low_energy/peripheral2.h",
96        "public/pw_bluetooth/low_energy/phy.h",
97        "public/pw_bluetooth/low_energy/security_mode.h",
98        "public/pw_bluetooth/pairing_delegate2.h",
99        "public/pw_bluetooth/peer.h",
100        "public/pw_bluetooth/types.h",
101        "public/pw_bluetooth/uuid.h",
102        "public/pw_bluetooth/vendor.h",
103    ],
104    includes = ["public"],
105    deps = [
106        ":config",
107        "//pw_assert:assert",
108        "//pw_async2:dispatcher",
109        "//pw_async2:once_sender",
110        "//pw_channel",
111        "//pw_chrono:system_clock",
112        "//pw_containers:vector",
113        "//pw_function",
114        "//pw_multibuf",
115        "//pw_result",
116        "//pw_result:expected",
117        "//pw_span",
118        "//pw_status",
119        "//pw_string:string",
120    ],
121)
122
123cc_library(
124    name = "snoop",
125    srcs = [
126        "snoop.cc",
127    ],
128    hdrs = [
129        "public/pw_bluetooth/snoop.h",
130    ],
131    implementation_deps = ["//pw_assert:check"],
132    includes = ["public"],
133    deps = [
134        ":emboss_snoop",
135        ":emboss_util",
136        "//pw_bluetooth_proxy",
137        "//pw_chrono:system_clock",
138        "//pw_containers:inline_var_len_entry_queue",
139        "//pw_hex_dump",
140        "//pw_log",
141        "//pw_result",
142        "//pw_span",
143        "//pw_sync:mutex",
144        "//pw_sync:virtual_basic_lockable",
145    ],
146)
147
148cc_library(
149    name = "emboss_util",
150    hdrs = [
151        "public/pw_bluetooth/emboss_util.h",
152    ],
153    includes = ["public"],
154    deps = [
155        "//pw_result",
156        "//pw_span",
157        "//pw_status",
158    ],
159)
160
161pw_cc_test(
162    name = "address_test",
163    srcs = [
164        "address_test.cc",
165    ],
166    deps = [
167        ":pw_bluetooth",
168    ],
169)
170
171pw_cc_test(
172    name = "api_test",
173    srcs = [
174        "api_test.cc",
175    ],
176    deps = [
177        ":pw_bluetooth",
178    ],
179)
180
181pw_cc_test(
182    name = "api2_test",
183    srcs = [
184        "api2_test.cc",
185    ],
186    deps = [
187        ":pw_bluetooth2",
188    ],
189)
190
191pw_cc_test(
192    name = "result_test",
193    srcs = [
194        "result_test.cc",
195    ],
196    deps = [
197        ":pw_bluetooth",
198    ],
199)
200
201pw_cc_test(
202    name = "snoop_test",
203    srcs = [
204        "snoop_test.cc",
205    ],
206    deps = [
207        ":snoop",
208        "//pw_chrono:simulated_system_clock",
209        "//pw_hex_dump:log_bytes",
210    ],
211)
212
213pw_cc_test(
214    name = "uuid_test",
215    srcs = [
216        "uuid_test.cc",
217    ],
218    deps = [
219        ":pw_bluetooth",
220    ],
221)
222
223emboss_cc_library(
224    name = "_emboss_a2dp_aac",
225    srcs = ["public/pw_bluetooth/a2dp_aac.emb"],
226    enable_enum_traits = False,
227    import_dirs = ["public"],
228    visibility = ["//visibility:private"],
229)
230
231emboss_cc_library(
232    name = "_emboss_a2dp_sbc",
233    srcs = ["public/pw_bluetooth/a2dp_sbc.emb"],
234    enable_enum_traits = False,
235    import_dirs = ["public"],
236    visibility = ["//visibility:private"],
237)
238
239emboss_cc_library(
240    name = "_emboss_avdtp",
241    srcs = ["public/pw_bluetooth/avdtp.emb"],
242    enable_enum_traits = False,
243    import_dirs = ["public"],
244    visibility = ["//visibility:private"],
245)
246
247emboss_cc_library(
248    name = "_emboss_att",
249    srcs = ["public/pw_bluetooth/att.emb"],
250    enable_enum_traits = False,
251    import_dirs = ["public"],
252    visibility = ["//visibility:private"],
253    deps = [
254        ":_emboss_hci_data",
255        ":_emboss_l2cap_frames",
256    ],
257)
258
259cc_library(
260    name = "emboss_a2dp_aac",
261    deps = [":_emboss_a2dp_aac"],
262)
263
264cc_library(
265    name = "emboss_a2dp_sbc",
266    deps = [":_emboss_a2dp_sbc"],
267)
268
269cc_library(
270    name = "emboss_avdtp",
271    includes = ["public"],
272    deps = [":_emboss_avdtp"],
273)
274
275cc_library(
276    name = "emboss_att",
277    includes = ["public"],
278    deps = [":_emboss_att"],
279)
280
281emboss_cc_library(
282    name = "_emboss_hci_android",
283    srcs = ["public/pw_bluetooth/hci_android.emb"],
284    enable_enum_traits = False,
285    import_dirs = ["public"],
286    visibility = ["//visibility:private"],
287    deps = [":_emboss_hci_common"],
288)
289
290# emboss_cc_library doesn't support includes, so we need to wrap it.
291cc_library(
292    name = "emboss_hci_android",
293    includes = ["public"],
294    deps = [":_emboss_hci_android"],
295)
296
297emboss_cc_library(
298    name = "_emboss_hci_common",
299    srcs = ["public/pw_bluetooth/hci_common.emb"],
300    enable_enum_traits = False,
301    visibility = ["//visibility:private"],
302)
303
304cc_library(
305    name = "emboss_hci_common",
306    includes = ["public"],
307    deps = [":_emboss_hci_common"],
308)
309
310emboss_cc_library(
311    name = "_emboss_hci_commands",
312    srcs = ["public/pw_bluetooth/hci_commands.emb"],
313    enable_enum_traits = False,
314    import_dirs = ["public"],
315    visibility = ["//visibility:private"],
316    deps = [":_emboss_hci_common"],
317)
318
319cc_library(
320    name = "emboss_hci_commands",
321    includes = ["public"],
322    deps = [":_emboss_hci_commands"],
323)
324
325emboss_cc_library(
326    name = "_emboss_hci_data",
327    srcs = ["public/pw_bluetooth/hci_data.emb"],
328    enable_enum_traits = False,
329    visibility = ["//visibility:private"],
330    deps = [":_emboss_hci_common"],
331)
332
333cc_library(
334    name = "emboss_hci_data",
335    includes = ["public"],
336    deps = [":_emboss_hci_data"],
337)
338
339emboss_cc_library(
340    name = "_emboss_hci_events",
341    srcs = ["public/pw_bluetooth/hci_events.emb"],
342    enable_enum_traits = False,
343    import_dirs = ["public"],
344    visibility = ["//visibility:private"],
345    deps = [":_emboss_hci_common"],
346)
347
348cc_library(
349    name = "emboss_hci_events",
350    includes = ["public"],
351    deps = [":_emboss_hci_events"],
352)
353
354emboss_cc_library(
355    name = "_emboss_hci_h4",
356    srcs = ["public/pw_bluetooth/hci_h4.emb"],
357    enable_enum_traits = False,
358    import_dirs = ["public"],
359    visibility = ["//visibility:private"],
360)
361
362cc_library(
363    name = "emboss_hci_h4",
364    includes = ["public"],
365    deps = [":_emboss_hci_h4"],
366)
367
368emboss_cc_library(
369    name = "_emboss_hci_test",
370    srcs = ["public/pw_bluetooth/hci_test.emb"],
371    enable_enum_traits = False,
372    import_dirs = ["public"],
373    visibility = ["//visibility:private"],
374    deps = [":_emboss_hci_common"],
375)
376
377cc_library(
378    name = "emboss_hci_test",
379    includes = ["public"],
380    deps = [":_emboss_hci_test"],
381)
382
383emboss_cc_library(
384    name = "_emboss_l2cap_frames",
385    srcs = ["public/pw_bluetooth/l2cap_frames.emb"],
386    enable_enum_traits = False,
387    visibility = ["//visibility:private"],
388)
389
390cc_library(
391    name = "emboss_l2cap_frames",
392    includes = ["public"],
393    deps = [":_emboss_l2cap_frames"],
394)
395
396emboss_cc_library(
397    name = "_emboss_rfcomm_frames",
398    srcs = ["public/pw_bluetooth/rfcomm_frames.emb"],
399    enable_enum_traits = False,
400    visibility = ["//visibility:private"],
401)
402
403cc_library(
404    name = "emboss_rfcomm_frames",
405    includes = ["public"],
406    deps = [":_emboss_rfcomm_frames"],
407)
408
409cc_library(
410    name = "emboss_hci",
411    deps = [
412        ":emboss_hci_android",
413        ":emboss_hci_commands",
414        ":emboss_hci_common",
415        ":emboss_hci_data",
416        ":emboss_hci_events",
417        ":emboss_hci_h4",
418    ],
419)
420
421emboss_cc_library(
422    name = "_emboss_snoop",
423    srcs = ["public/pw_bluetooth/snoop.emb"],
424    enable_enum_traits = False,
425    visibility = ["//visibility:private"],
426)
427
428cc_library(
429    name = "emboss_snoop",
430    includes = ["public"],
431    deps = [":_emboss_snoop"],
432)
433
434pw_cc_test(
435    name = "emboss_test",
436    srcs = ["emboss_test.cc"],
437    deps = [
438        # All emboss targets are listed (even if they don't have explicit tests)
439        # to ensure they are compiled.
440        ":emboss_att",
441        ":emboss_hci",
442        ":emboss_hci_test",
443        ":emboss_l2cap_frames",
444        ":emboss_rfcomm_frames",
445        "//third_party/fuchsia:stdcompat",
446    ],
447)
448
449pw_cc_test(
450    name = "emboss_util_test",
451    srcs = [
452        "emboss_util_test.cc",
453    ],
454    deps = [
455        ":emboss_hci_test",
456        ":emboss_util",
457    ],
458)
459
460# Bazel support for Emboss has not been fully configured yet, but we need to
461# satisfy presubmit.
462filegroup(
463    name = "emboss_files",
464    srcs = [
465        "size_report/make_2_views_and_write.cc",
466        "size_report/make_view_and_write.cc",
467    ],
468)
469
470filegroup(
471    name = "doxygen",
472    srcs = [
473        "public/pw_bluetooth/controller2.h",
474        "public/pw_bluetooth/gatt/client2.h",
475        "public/pw_bluetooth/gatt/server2.h",
476        "public/pw_bluetooth/low_energy/central2.h",
477        "public/pw_bluetooth/low_energy/channel.h",
478        "public/pw_bluetooth/low_energy/connection2.h",
479        "public/pw_bluetooth/low_energy/peripheral2.h",
480    ],
481)
482
483sphinx_docs_library(
484    name = "docs",
485    srcs = [
486        "docs.rst",
487        "emboss_test.cc",
488    ],
489    prefix = "pw_bluetooth/",
490    target_compatible_with = incompatible_with_mcu(),
491)
492