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 15import("//build_overrides/pigweed.gni") 16 17import("$dir_pigweed/third_party/emboss/build_defs.gni") 18import("$dir_pw_async2/backend.gni") 19import("$dir_pw_bloat/bloat.gni") 20import("$dir_pw_build/module_config.gni") 21import("$dir_pw_build/target_types.gni") 22import("$dir_pw_chrono/backend.gni") 23import("$dir_pw_docgen/docs.gni") 24import("$dir_pw_unit_test/test.gni") 25 26declare_args() { 27 # The build target that overrides the default configuration options for this 28 # module. This should point to a source set that provides defines through a 29 # public config (which may -include a file or add defines directly). 30 pw_bluetooth_CONFIG = pw_build_DEFAULT_MODULE_CONFIG 31} 32 33pw_source_set("config") { 34 public = [ "public/pw_bluetooth/config.h" ] 35 public_configs = [ ":public_include_path" ] 36 public_deps = [ pw_bluetooth_CONFIG ] 37} 38 39config("public_include_path") { 40 include_dirs = [ "public" ] 41 visibility = [ ":*" ] 42} 43 44pw_doc_group("docs") { 45 # Also, sources with doxygen comment blocks must be added to //docs/BUILD.gn 46 inputs = [ "emboss_test.cc" ] 47 sources = [ "docs.rst" ] 48 49 report_deps = [ 50 ":emboss_size_report", 51 ":emboss_size_report_diff", 52 ] 53} 54 55pw_source_set("pw_bluetooth") { 56 public_configs = [ ":public_include_path" ] 57 public = [ 58 "public/pw_bluetooth/address.h", 59 "public/pw_bluetooth/assigned_uuids.h", 60 "public/pw_bluetooth/constants.h", 61 "public/pw_bluetooth/controller.h", 62 "public/pw_bluetooth/gatt/client.h", 63 "public/pw_bluetooth/gatt/constants.h", 64 "public/pw_bluetooth/gatt/error.h", 65 "public/pw_bluetooth/gatt/server.h", 66 "public/pw_bluetooth/gatt/types.h", 67 "public/pw_bluetooth/host.h", 68 "public/pw_bluetooth/internal/hex.h", 69 "public/pw_bluetooth/internal/raii_ptr.h", 70 "public/pw_bluetooth/low_energy/advertising_data.h", 71 "public/pw_bluetooth/low_energy/bond_data.h", 72 "public/pw_bluetooth/low_energy/central.h", 73 "public/pw_bluetooth/low_energy/channel.h", 74 "public/pw_bluetooth/low_energy/connection.h", 75 "public/pw_bluetooth/low_energy/peripheral.h", 76 "public/pw_bluetooth/low_energy/security_mode.h", 77 "public/pw_bluetooth/pairing_delegate.h", 78 "public/pw_bluetooth/peer.h", 79 "public/pw_bluetooth/result.h", 80 "public/pw_bluetooth/types.h", 81 "public/pw_bluetooth/uuid.h", 82 "public/pw_bluetooth/vendor.h", 83 ] 84 public_deps = [ 85 ":config", 86 "$dir_pw_chrono:system_clock", 87 "$dir_pw_string:string", 88 dir_pw_containers, 89 dir_pw_function, 90 dir_pw_multibuf, 91 dir_pw_result, 92 dir_pw_span, 93 dir_pw_status, 94 ] 95} 96 97pw_source_set("pw_bluetooth2") { 98 public_configs = [ ":public_include_path" ] 99 public = [ 100 "public/pw_bluetooth/address.h", 101 "public/pw_bluetooth/assigned_uuids.h", 102 "public/pw_bluetooth/constants.h", 103 "public/pw_bluetooth/controller2.h", 104 "public/pw_bluetooth/gatt/client2.h", 105 "public/pw_bluetooth/gatt/constants.h", 106 "public/pw_bluetooth/gatt/error.h", 107 "public/pw_bluetooth/gatt/server2.h", 108 "public/pw_bluetooth/gatt/types.h", 109 "public/pw_bluetooth/internal/hex.h", 110 "public/pw_bluetooth/internal/raii_ptr.h", 111 "public/pw_bluetooth/low_energy/advertising_data.h", 112 "public/pw_bluetooth/low_energy/bond_data2.h", 113 "public/pw_bluetooth/low_energy/central2.h", 114 "public/pw_bluetooth/low_energy/channel.h", 115 "public/pw_bluetooth/low_energy/connection2.h", 116 "public/pw_bluetooth/low_energy/peripheral2.h", 117 "public/pw_bluetooth/low_energy/phy.h", 118 "public/pw_bluetooth/low_energy/security_mode.h", 119 "public/pw_bluetooth/pairing_delegate2.h", 120 "public/pw_bluetooth/peer.h", 121 "public/pw_bluetooth/types.h", 122 "public/pw_bluetooth/uuid.h", 123 "public/pw_bluetooth/vendor.h", 124 ] 125 public_deps = [ 126 ":config", 127 "$dir_pw_async2:dispatcher", 128 "$dir_pw_async2:once_sender", 129 "$dir_pw_chrono:system_clock", 130 "$dir_pw_result:expected", 131 "$dir_pw_string:string", 132 dir_pw_channel, 133 dir_pw_containers, 134 dir_pw_function, 135 dir_pw_multibuf, 136 dir_pw_result, 137 dir_pw_span, 138 dir_pw_status, 139 ] 140} 141 142pw_source_set("emboss_util") { 143 public_configs = [ ":public_include_path" ] 144 public = [ "public/pw_bluetooth/emboss_util.h" ] 145 public_deps = [ 146 dir_pw_result, 147 dir_pw_span, 148 dir_pw_status, 149 ] 150} 151 152if (dir_pw_third_party_emboss != "") { 153 config("emboss_include_path") { 154 include_dirs = [ 155 "$target_gen_dir/public", 156 157 # Emboss headers (.emb.h) need to look for imported Emboss file headers in 158 # Pigweed's root gen directory. This is *not* root_gen_dir in 159 # external repositories depending on Pigweed. 160 "$target_gen_dir/..", 161 ] 162 visibility = [ ":*" ] 163 } 164 165 emboss_cc_library("emboss_att") { 166 public_configs = [ ":emboss_include_path" ] 167 source = "public/pw_bluetooth/att.emb" 168 imports = [ 169 "public/pw_bluetooth/hci_data.emb", 170 "public/pw_bluetooth/l2cap_frames.emb", 171 ] 172 import_dirs = [ "public" ] 173 deps = [ 174 ":emboss_hci_data", 175 ":emboss_l2cap_frames", 176 ] 177 } 178 179 emboss_cc_library("emboss_hci_android") { 180 public_configs = [ ":emboss_include_path" ] 181 source = "public/pw_bluetooth/hci_android.emb" 182 imports = [ "public/pw_bluetooth/hci_common.emb" ] 183 import_dirs = [ "public" ] 184 deps = [ ":emboss_hci_common" ] 185 } 186 187 emboss_cc_library("emboss_hci_common") { 188 public_configs = [ ":emboss_include_path" ] 189 source = "public/pw_bluetooth/hci_common.emb" 190 } 191 192 emboss_cc_library("emboss_hci_commands") { 193 public_configs = [ ":emboss_include_path" ] 194 source = "public/pw_bluetooth/hci_commands.emb" 195 imports = [ "public/pw_bluetooth/hci_common.emb" ] 196 import_dirs = [ "public" ] 197 deps = [ ":emboss_hci_common" ] 198 } 199 200 emboss_cc_library("emboss_hci_data") { 201 public_configs = [ ":emboss_include_path" ] 202 source = "public/pw_bluetooth/hci_data.emb" 203 } 204 205 emboss_cc_library("emboss_hci_events") { 206 public_configs = [ ":emboss_include_path" ] 207 source = "public/pw_bluetooth/hci_events.emb" 208 imports = [ "public/pw_bluetooth/hci_common.emb" ] 209 import_dirs = [ "public" ] 210 deps = [ ":emboss_hci_common" ] 211 } 212 213 emboss_cc_library("emboss_hci_h4") { 214 public_configs = [ ":emboss_include_path" ] 215 source = "public/pw_bluetooth/hci_h4.emb" 216 imports = [ "public/pw_bluetooth/hci_h4.emb" ] 217 import_dirs = [ "public" ] 218 } 219 220 emboss_cc_library("emboss_hci_test") { 221 public_configs = [ ":emboss_include_path" ] 222 source = "public/pw_bluetooth/hci_test.emb" 223 imports = [ "public/pw_bluetooth/hci_common.emb" ] 224 import_dirs = [ "public" ] 225 deps = [ ":emboss_hci_common" ] 226 } 227 228 emboss_cc_library("emboss_l2cap_frames") { 229 public_configs = [ ":emboss_include_path" ] 230 source = "public/pw_bluetooth/l2cap_frames.emb" 231 } 232 233 emboss_cc_library("emboss_rfcomm_frames") { 234 public_configs = [ ":emboss_include_path" ] 235 source = "public/pw_bluetooth/rfcomm_frames.emb" 236 } 237 238 group("emboss_hci_group") { 239 public_configs = [ ":emboss_include_path" ] 240 public_deps = [ 241 ":emboss_hci_android", 242 ":emboss_hci_commands", 243 ":emboss_hci_common", 244 ":emboss_hci_data", 245 ":emboss_hci_events", 246 ":emboss_hci_h4", 247 ] 248 } 249} else { 250 group("emboss_att") { 251 } 252 group("emboss_hci_android") { 253 } 254 group("emboss_hci_common") { 255 } 256 group("emboss_hci_commands") { 257 } 258 group("emboss_hci_data") { 259 } 260 group("emboss_hci_events") { 261 } 262 group("emboss_hci_h4") { 263 } 264 group("emboss_hci_test") { 265 } 266 group("emboss_hci_group") { 267 } 268 group("emboss_l2cap_frames") { 269 } 270 group("emboss_rfcomm_frames") { 271 } 272} 273 274pw_test_group("tests") { 275 enable_if = pw_chrono_SYSTEM_CLOCK_BACKEND != "" 276 tests = [ 277 ":address_test", 278 ":api_test", 279 ":api2_test", 280 ":result_test", 281 ":uuid_test", 282 ":emboss_test", 283 ":emboss_util_test", 284 ] 285} 286 287pw_test("address_test") { 288 sources = [ "address_test.cc" ] 289 deps = [ ":pw_bluetooth" ] 290} 291 292pw_test("api_test") { 293 sources = [ "api_test.cc" ] 294 deps = [ ":pw_bluetooth" ] 295} 296 297pw_test("emboss_util_test") { 298 enable_if = 299 dir_pw_third_party_emboss != "" && pw_chrono_SYSTEM_CLOCK_BACKEND != "" 300 sources = [ "emboss_util_test.cc" ] 301 include_dirs = [ "." ] 302 deps = [ 303 ":emboss_hci_test", 304 ":emboss_util", 305 ] 306} 307 308pw_test("api2_test") { 309 enable_if = pw_async2_DISPATCHER_BACKEND != "" 310 sources = [ "api2_test.cc" ] 311 deps = [ ":pw_bluetooth2" ] 312} 313 314pw_test("result_test") { 315 sources = [ "result_test.cc" ] 316 deps = [ ":pw_bluetooth" ] 317} 318 319pw_test("uuid_test") { 320 sources = [ "uuid_test.cc" ] 321 deps = [ ":pw_bluetooth" ] 322} 323 324pw_test("emboss_test") { 325 enable_if = dir_pw_third_party_emboss != "" 326 sources = [ "emboss_test.cc" ] 327 deps = [ 328 # All emboss targets are listed (even if they don't have explicit tests) to 329 # ensure they are compiled. 330 ":emboss_att", 331 ":emboss_hci_group", 332 ":emboss_hci_test", 333 ":emboss_l2cap_frames", 334 ":emboss_rfcomm_frames", 335 "$dir_pw_third_party/fuchsia:stdcompat", 336 ] 337} 338 339if (dir_pw_third_party_emboss != "") { 340 pw_size_diff("emboss_size_report") { 341 title = "pw_bluetooth Emboss Size Report" 342 base = "$dir_pw_bloat:bloat_base" 343 binaries = [ 344 { 345 target = "size_report:make_view_and_write" 346 label = "Make view and write field" 347 }, 348 ] 349 } 350 351 pw_size_diff("emboss_size_report_diff") { 352 title = "pw_bluetooth Emboss Size Report diff" 353 base = "size_report:make_view_and_write" 354 binaries = [ 355 { 356 target = "size_report:make_2_views_and_write" 357 label = "Size difference when adding a second view" 358 }, 359 ] 360 } 361} else { 362 pw_size_diff("emboss_size_report") { 363 title = "pw_bluetooth Emboss Size Report" 364 base = "$dir_pw_bloat:bloat_base" 365 binaries = [ 366 { 367 target = "$dir_pw_bloat:bloat_base" 368 label = "Emboss not configured." 369 }, 370 ] 371 } 372 373 pw_size_diff("emboss_size_report_diff") { 374 title = "pw_bluetooth Emboss Size Report diff" 375 base = "$dir_pw_bloat:bloat_base" 376 binaries = [ 377 { 378 target = "$dir_pw_bloat:bloat_base" 379 label = "Emboss not configured." 380 }, 381 ] 382 } 383} 384