xref: /aosp_15_r20/external/pigweed/pw_bluetooth_proxy/BUILD.gn (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1# Copyright 2024 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
15import("//build_overrides/pigweed.gni")
16
17import("$dir_pigweed/third_party/emboss/emboss.gni")
18import("$dir_pw_bloat/bloat.gni")
19import("$dir_pw_build/target_types.gni")
20import("$dir_pw_chrono/backend.gni")
21import("$dir_pw_docgen/docs.gni")
22import("$dir_pw_unit_test/test.gni")
23
24config("public_include_path") {
25  include_dirs = [ "public" ]
26  visibility = [ ":*" ]
27}
28
29pw_doc_group("docs") {
30  # Also, sources with doxygen comment blocks must be added to //docs/BUILD.gn
31  inputs = [ "proxy_host_test.cc" ]
32  sources = [ "docs.rst" ]
33  report_deps = [ ":use_passthrough_proxy_size_report" ]
34}
35
36pw_test_group("tests") {
37  tests = [ ":pw_bluetooth_proxy_test" ]
38}
39
40pw_source_set("pw_bluetooth_proxy") {
41  public_configs = [ ":public_include_path" ]
42  public = [
43    "public/pw_bluetooth_proxy/basic_l2cap_channel.h",
44    "public/pw_bluetooth_proxy/gatt_notify_channel.h",
45    "public/pw_bluetooth_proxy/h4_packet.h",
46    "public/pw_bluetooth_proxy/internal/acl_data_channel.h",
47    "public/pw_bluetooth_proxy/internal/gatt_notify_channel_internal.h",
48    "public/pw_bluetooth_proxy/internal/h4_storage.h",
49    "public/pw_bluetooth_proxy/internal/hci_transport.h",
50    "public/pw_bluetooth_proxy/internal/l2cap_aclu_signaling_channel.h",
51    "public/pw_bluetooth_proxy/internal/l2cap_channel_manager.h",
52    "public/pw_bluetooth_proxy/internal/l2cap_coc_internal.h",
53    "public/pw_bluetooth_proxy/internal/l2cap_leu_signaling_channel.h",
54    "public/pw_bluetooth_proxy/internal/l2cap_read_channel.h",
55    "public/pw_bluetooth_proxy/internal/l2cap_signaling_channel.h",
56    "public/pw_bluetooth_proxy/internal/l2cap_write_channel.h",
57    "public/pw_bluetooth_proxy/internal/logical_transport.h",
58    "public/pw_bluetooth_proxy/internal/rfcomm_fcs.h",
59    "public/pw_bluetooth_proxy/l2cap_coc.h",
60    "public/pw_bluetooth_proxy/proxy_host.h",
61    "public/pw_bluetooth_proxy/rfcomm_channel.h",
62  ]
63  public_deps = [
64    "//pw_bluetooth:emboss_att",
65    "//pw_bluetooth:emboss_hci_common",
66    "//pw_bluetooth:emboss_hci_data",
67    "//pw_bluetooth:emboss_hci_events",
68    "//pw_bluetooth:emboss_hci_h4",
69    "//pw_bluetooth:emboss_l2cap_frames",
70    "//pw_bluetooth:emboss_rfcomm_frames",
71    "//pw_bluetooth:emboss_util",
72    "//pw_sync:lock_annotations",
73    "//pw_sync:mutex",
74    dir_pw_containers,
75    dir_pw_function,
76    dir_pw_log,
77    dir_pw_result,
78    dir_pw_span,
79    dir_pw_status,
80  ]
81  deps = [ dir_pw_log ]
82  sources = [
83    "acl_data_channel.cc",
84    "basic_l2cap_channel.cc",
85    "gatt_notify_channel.cc",
86    "h4_storage.cc",
87    "l2cap_aclu_signaling_channel.cc",
88    "l2cap_channel_manager.cc",
89    "l2cap_coc.cc",
90    "l2cap_leu_signaling_channel.cc",
91    "l2cap_read_channel.cc",
92    "l2cap_signaling_channel.cc",
93    "l2cap_write_channel.cc",
94    "proxy_host.cc",
95    "rfcomm_channel.cc",
96    "rfcomm_fcs.cc",
97  ]
98}
99
100pw_test("pw_bluetooth_proxy_test") {
101  enable_if =
102      dir_pw_third_party_emboss != "" && pw_chrono_SYSTEM_CLOCK_BACKEND != ""
103  sources = [
104    "h4_packet_test.cc",
105    "proxy_host_test.cc",
106    "rfcomm_fcs_test.cc",
107  ]
108  include_dirs = [ "." ]
109  deps = [
110    ":pw_bluetooth_proxy",
111    "$dir_pw_third_party/fuchsia:stdcompat",
112    "//pw_bluetooth:emboss_att",
113    "//pw_bluetooth:emboss_hci_commands",
114    "//pw_bluetooth:emboss_hci_common",
115    "//pw_bluetooth:emboss_hci_events",
116    "//pw_bluetooth:emboss_hci_h4",
117    "//pw_bluetooth:emboss_util",
118  ]
119}
120
121# We depend on emboss, so we can only compute size when emboss is in the build.
122if (dir_pw_third_party_emboss != "") {
123  pw_size_diff("use_passthrough_proxy_size_report") {
124    title = "pw_bluetooth_proxy Passthrough Size Report"
125    base = "$dir_pw_bloat:bloat_base"
126    binaries = [
127      {
128        target = "size_report:use_passthrough_proxy"
129        label = "Create and use proxy as a simple passthrough"
130      },
131    ]
132  }
133} else {
134  pw_size_diff("use_passthrough_proxy_size_report") {
135    title = "pw_bluetooth_proxy Passthrough Size Report"
136    base = "$dir_pw_bloat:bloat_base"
137    binaries = [
138      {
139        target = "$dir_pw_bloat:bloat_base"
140        label = "Emboss not configured."
141      },
142    ]
143  }
144}
145