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_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 = [ "emboss_test.cc" ] 32 sources = [ "docs.rst" ] 33 34 report_deps = [ 35 ":emboss_size_report", 36 ":emboss_size_report_diff", 37 ] 38} 39 40pw_source_set("pw_bluetooth") { 41 public_configs = [ ":public_include_path" ] 42 public = [ 43 "public/pw_bluetooth/address.h", 44 "public/pw_bluetooth/assigned_uuids.h", 45 "public/pw_bluetooth/constants.h", 46 "public/pw_bluetooth/controller.h", 47 "public/pw_bluetooth/gatt/client.h", 48 "public/pw_bluetooth/gatt/constants.h", 49 "public/pw_bluetooth/gatt/error.h", 50 "public/pw_bluetooth/gatt/server.h", 51 "public/pw_bluetooth/gatt/types.h", 52 "public/pw_bluetooth/host.h", 53 "public/pw_bluetooth/internal/hex.h", 54 "public/pw_bluetooth/internal/raii_ptr.h", 55 "public/pw_bluetooth/low_energy/advertising_data.h", 56 "public/pw_bluetooth/low_energy/bond_data.h", 57 "public/pw_bluetooth/low_energy/central.h", 58 "public/pw_bluetooth/low_energy/connection.h", 59 "public/pw_bluetooth/low_energy/peripheral.h", 60 "public/pw_bluetooth/low_energy/security_mode.h", 61 "public/pw_bluetooth/pairing_delegate.h", 62 "public/pw_bluetooth/peer.h", 63 "public/pw_bluetooth/result.h", 64 "public/pw_bluetooth/types.h", 65 "public/pw_bluetooth/uuid.h", 66 "public/pw_bluetooth/vendor.h", 67 ] 68 public_deps = [ 69 "$dir_pw_chrono:system_clock", 70 "$dir_pw_string:string", 71 dir_pw_containers, 72 dir_pw_function, 73 dir_pw_result, 74 dir_pw_span, 75 dir_pw_status, 76 ] 77} 78 79if (dir_pw_third_party_emboss != "") { 80 config("emboss_include_path") { 81 include_dirs = [ 82 "$target_gen_dir/public", 83 84 # Emboss headers (.emb.h) need to look for imported Emboss file headers in 85 # Pigweed's root gen directory. This is *not* root_gen_dir in 86 # external repositories depending on Pigweed. 87 "$target_gen_dir/..", 88 ] 89 visibility = [ ":*" ] 90 } 91 92 emboss_cc_library("emboss_hci_android") { 93 public_configs = [ ":emboss_include_path" ] 94 source = "public/pw_bluetooth/hci_android.emb" 95 imports = [ "public/pw_bluetooth/hci_common.emb" ] 96 import_dirs = [ "public" ] 97 deps = [ ":emboss_hci_common" ] 98 } 99 100 emboss_cc_library("emboss_hci_common") { 101 public_configs = [ ":emboss_include_path" ] 102 source = "public/pw_bluetooth/hci_common.emb" 103 } 104 105 emboss_cc_library("emboss_hci_commands") { 106 public_configs = [ ":emboss_include_path" ] 107 source = "public/pw_bluetooth/hci_commands.emb" 108 imports = [ "public/pw_bluetooth/hci_common.emb" ] 109 import_dirs = [ "public" ] 110 deps = [ ":emboss_hci_common" ] 111 } 112 113 emboss_cc_library("emboss_hci_data") { 114 public_configs = [ ":emboss_include_path" ] 115 source = "public/pw_bluetooth/hci_data.emb" 116 } 117 118 emboss_cc_library("emboss_hci_events") { 119 public_configs = [ ":emboss_include_path" ] 120 source = "public/pw_bluetooth/hci_events.emb" 121 imports = [ "public/pw_bluetooth/hci_common.emb" ] 122 import_dirs = [ "public" ] 123 deps = [ ":emboss_hci_common" ] 124 } 125 126 emboss_cc_library("emboss_hci_h4") { 127 public_configs = [ ":emboss_include_path" ] 128 source = "public/pw_bluetooth/hci_h4.emb" 129 imports = [ "public/pw_bluetooth/hci_h4.emb" ] 130 import_dirs = [ "public" ] 131 } 132 133 emboss_cc_library("emboss_hci_test") { 134 public_configs = [ ":emboss_include_path" ] 135 source = "public/pw_bluetooth/hci_test.emb" 136 imports = [ "public/pw_bluetooth/hci_common.emb" ] 137 import_dirs = [ "public" ] 138 deps = [ ":emboss_hci_common" ] 139 } 140 141 emboss_cc_library("emboss_l2cap_frames") { 142 public_configs = [ ":emboss_include_path" ] 143 source = "public/pw_bluetooth/l2cap_frames.emb" 144 } 145 146 group("emboss_hci_group") { 147 public_configs = [ ":emboss_include_path" ] 148 public_deps = [ 149 ":emboss_hci_android", 150 ":emboss_hci_commands", 151 ":emboss_hci_common", 152 ":emboss_hci_data", 153 ":emboss_hci_events", 154 ":emboss_hci_h4", 155 ] 156 } 157} else { 158 group("emboss_hci_android") { 159 } 160 group("emboss_hci_common") { 161 } 162 group("emboss_hci_commands") { 163 } 164 group("emboss_hci_data") { 165 } 166 group("emboss_hci_events") { 167 } 168 group("emboss_hci_h4") { 169 } 170 group("emboss_hci_test") { 171 } 172 group("emboss_hci_group") { 173 } 174 group("emboss_l2cap_frames") { 175 } 176} 177 178pw_test_group("tests") { 179 enable_if = pw_chrono_SYSTEM_CLOCK_BACKEND != "" 180 tests = [ 181 ":address_test", 182 ":api_test", 183 ":result_test", 184 ":uuid_test", 185 ":emboss_test", 186 ] 187} 188 189pw_test("address_test") { 190 sources = [ "address_test.cc" ] 191 deps = [ ":pw_bluetooth" ] 192} 193 194pw_test("api_test") { 195 sources = [ "api_test.cc" ] 196 deps = [ ":pw_bluetooth" ] 197} 198 199pw_test("result_test") { 200 sources = [ "result_test.cc" ] 201 deps = [ ":pw_bluetooth" ] 202} 203 204pw_test("uuid_test") { 205 sources = [ "uuid_test.cc" ] 206 deps = [ ":pw_bluetooth" ] 207} 208 209pw_test("emboss_test") { 210 enable_if = dir_pw_third_party_emboss != "" 211 sources = [ "emboss_test.cc" ] 212 deps = [ 213 # All emboss targets are listed (even if they don't have explicit tests) to 214 # ensure they are compiled. 215 ":emboss_hci_group", 216 ":emboss_hci_test", 217 ":emboss_l2cap_frames", 218 "$dir_pw_third_party/fuchsia:stdcompat", 219 ] 220} 221 222if (dir_pw_third_party_emboss != "") { 223 pw_size_diff("emboss_size_report") { 224 title = "pw_bluetooth Emboss Size Report" 225 base = "$dir_pw_bloat:bloat_base" 226 binaries = [ 227 { 228 target = "size_report:make_view_and_write" 229 label = "Make view and write field" 230 }, 231 ] 232 } 233 234 pw_size_diff("emboss_size_report_diff") { 235 title = "pw_bluetooth Emboss Size Report diff" 236 base = "size_report:make_view_and_write" 237 binaries = [ 238 { 239 target = "size_report:make_2_views_and_write" 240 label = "Size difference when adding a second view" 241 }, 242 ] 243 } 244} else { 245 pw_size_diff("emboss_size_report") { 246 title = "pw_bluetooth Emboss Size Report" 247 base = "$dir_pw_bloat:bloat_base" 248 binaries = [ 249 { 250 target = "$dir_pw_bloat:bloat_base" 251 label = "Emboss not configured." 252 }, 253 ] 254 } 255 256 pw_size_diff("emboss_size_report_diff") { 257 title = "pw_bluetooth Emboss Size Report diff" 258 base = "$dir_pw_bloat:bloat_base" 259 binaries = [ 260 { 261 target = "$dir_pw_bloat:bloat_base" 262 label = "Emboss not configured." 263 }, 264 ] 265 } 266} 267