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 15load("@fuchsia_infra//infra:infra.bzl", "fuchsia_cipd_releases") 16load( 17 "@fuchsia_sdk//fuchsia:defs.bzl", 18 "fuchsia_cc_binary", 19 "fuchsia_cc_test", 20 "fuchsia_component", 21 "fuchsia_component_manifest", 22 "fuchsia_package", 23 "fuchsia_platforms", 24 "fuchsia_structured_config_cpp_elf_lib", 25 "fuchsia_structured_config_values", 26 "fuchsia_unittest_package", 27) 28load( 29 "@fuchsia_sdk//fuchsia:licenses.bzl", 30 "fuchsia_licenses_collection", 31 "fuchsia_licenses_spdx", 32) 33load("//pw_bluetooth_sapphire/fuchsia:fuchsia_api_level.bzl", "FUCHSIA_API_LEVEL") 34load("//pw_build:compatibility.bzl", "incompatible_with_mcu") 35 36package( 37 default_applicable_licenses = ["//pw_bluetooth_sapphire/fuchsia:license_fuchsia"], 38 default_visibility = ["//pw_bluetooth_sapphire/fuchsia:__pkg__"], 39) 40 41exports_files(["README.fuchsia.md"]) 42 43cc_library( 44 name = "sources", 45 srcs = [ 46 "host.cc", 47 "util.cc", 48 ], 49 hdrs = [ 50 "host.h", 51 "util.h", 52 ], 53 # `fuchsia_cc_binary` does not understand Pigweed's sanitizer features, e.g. 54 # //pw_toolchain/host_clang:asan_feature. This leads to link errors if the 55 # binary is linked against FuzzTest, as the latter expects the sanitizer to 56 # provide the SanitizerCoverage implementation. Since the binary is not 57 # intended to be a fuzzer, it can just be excluded from fuzzing builds. 58 target_compatible_with = select({ 59 "//pw_toolchain/host_clang:fuzztest_enabled": ["@platforms//:incompatible"], 60 "//conditions:default": [], 61 }), 62 deps = [ 63 ":bt_host_config", 64 "//pw_async_fuchsia:dispatcher", 65 "//pw_bluetooth_sapphire/fuchsia/host/controllers", 66 "//pw_bluetooth_sapphire/fuchsia/host/fidl", 67 "//pw_bluetooth_sapphire/fuchsia/lib/fidl", 68 "//pw_bluetooth_sapphire/host:stack", 69 "//pw_bluetooth_sapphire/host/common", 70 "//pw_bluetooth_sapphire/host/gap", 71 "//pw_bluetooth_sapphire/host/gatt", 72 "//pw_random_fuchsia:zircon_random_generator", 73 "@fuchsia_sdk//fidl/fuchsia.bluetooth.host:fuchsia.bluetooth.host_cpp", 74 "@fuchsia_sdk//fidl/fuchsia.bluetooth.host:fuchsia.bluetooth.host_hlcpp", 75 "@fuchsia_sdk//fidl/fuchsia.hardware.bluetooth:fuchsia.hardware.bluetooth_hlcpp", 76 "@fuchsia_sdk//fidl/fuchsia.process.lifecycle:fuchsia.process.lifecycle_hlcpp", 77 "@fuchsia_sdk//pkg/async-loop-cpp", 78 "@fuchsia_sdk//pkg/async-loop-default", 79 "@fuchsia_sdk//pkg/fit", 80 "@fuchsia_sdk//pkg/inspect", 81 "@fuchsia_sdk//pkg/sys_cpp", 82 "@fuchsia_sdk//pkg/trace", 83 "@fuchsia_sdk//pkg/zx", 84 ], 85) 86 87fuchsia_cc_binary( 88 name = "bt_host_bin", 89 srcs = ["main.cc"], 90 bin_name = "bt_host", 91 # TODO: b/367805596 - Remove when dynamic linking size budget issues are resolved. 92 features = ["static_cpp_standard_library"], 93 deps = [ 94 ":sources", 95 "//pw_log_fuchsia", 96 ], 97) 98 99fuchsia_component_manifest( 100 name = "manifest", 101 src = "meta/bt-host.cml", 102) 103 104fuchsia_structured_config_cpp_elf_lib( 105 name = "bt_host_config", 106 cm_label = ":manifest", 107) 108 109fuchsia_structured_config_values( 110 name = "default_config_values", 111 cm_label = ":manifest", 112 cvf_output_name = "bt-host", 113 values = { 114 "device_path": "/dev/class/bt-hci/000", 115 "legacy_pairing_enabled": False, 116 }, 117) 118 119fuchsia_component( 120 name = "component", 121 component_name = "bt-host", 122 manifest = ":manifest", 123 moniker = "core/bluetooth-core/bt-host-collection:bt-host_000", 124 deps = [":bt_host_bin"], 125) 126 127fuchsia_cc_test( 128 name = "host_test", 129 testonly = True, 130 srcs = ["host_test.cc"], 131 death_unittest = True, 132 deps = [ 133 ":sources", 134 "//pw_bluetooth_sapphire/fuchsia/host/fidl:fake_vendor_server", 135 "//pw_bluetooth_sapphire/host/testing", 136 "//pw_bluetooth_sapphire/host/testing:gtest_main", 137 "//pw_bluetooth_sapphire/host/testing:loop_fixture", 138 ], 139) 140 141fuchsia_unittest_package( 142 name = "test_pkg", 143 package_name = "bt-host-unittests", 144 testonly = True, 145 fuchsia_api_level = FUCHSIA_API_LEVEL, 146 platform = fuchsia_platforms.x64, 147 unit_tests = [ 148 ":host_test", 149 ], 150) 151 152fuchsia_package( 153 name = "pkg.x64", 154 package_name = "bt-host", 155 components = [ 156 ":component", 157 ], 158 fuchsia_api_level = FUCHSIA_API_LEVEL, 159 platform = fuchsia_platforms.x64, 160 resources = [":default_config_values"], 161) 162 163fuchsia_package( 164 name = "pkg.arm64", 165 package_name = "bt-host", 166 components = [ 167 ":component", 168 ], 169 fuchsia_api_level = FUCHSIA_API_LEVEL, 170 platform = fuchsia_platforms.arm64, 171 resources = [":default_config_values"], 172) 173 174fuchsia_package( 175 name = "pkg.riscv64", 176 package_name = "bt-host", 177 components = [ 178 ":component", 179 ], 180 fuchsia_api_level = FUCHSIA_API_LEVEL, 181 platform = fuchsia_platforms.riscv64, 182 resources = [":default_config_values"], 183) 184 185fuchsia_licenses_collection( 186 name = "bt_host_x64_pkg_licenses_collection", 187 root_target = ":pkg.x64", 188) 189 190fuchsia_licenses_collection( 191 name = "bt_host_arm64_pkg_licenses_collection", 192 root_target = ":pkg.arm64", 193) 194 195fuchsia_licenses_collection( 196 name = "bt_host_riscv64_pkg_licenses_collection", 197 root_target = ":pkg.riscv64", 198) 199 200fuchsia_licenses_spdx( 201 name = "bt_host_x64_licenses.spdx.json", 202 document_namespace = "https://pigweed.dev/pw_bluetooth_sapphire/", 203 licenses = ":bt_host_x64_pkg_licenses_collection", 204 licenses_cross_refs_base_url = "https://pigweed.googlesource.com/pigweed/pigweed/+/refs/heads/main/pw_bluetooth_sapphire/fuchsia/", 205 root_package_homepage = "https://pigweed.dev/pw_bluetooth_sapphire/", 206 root_package_name = "bt-host", 207) 208 209fuchsia_licenses_spdx( 210 name = "bt_host_arm64_licenses.spdx.json", 211 document_namespace = "https://pigweed.dev/pw_bluetooth_sapphire/", 212 licenses = ":bt_host_arm64_pkg_licenses_collection", 213 licenses_cross_refs_base_url = "https://pigweed.googlesource.com/pigweed/pigweed/+/refs/heads/main/pw_bluetooth_sapphire/fuchsia/", 214 root_package_homepage = "https://pigweed.dev/pw_bluetooth_sapphire/", 215 root_package_name = "bt-host", 216) 217 218fuchsia_licenses_spdx( 219 name = "bt_host_riscv64_licenses.spdx.json", 220 document_namespace = "https://pigweed.dev/pw_bluetooth_sapphire/", 221 licenses = ":bt_host_riscv64_pkg_licenses_collection", 222 licenses_cross_refs_base_url = "https://pigweed.googlesource.com/pigweed/pigweed/+/refs/heads/main/pw_bluetooth_sapphire/fuchsia/", 223 root_package_homepage = "https://pigweed.dev/pw_bluetooth_sapphire/", 224 root_package_name = "bt-host", 225) 226 227fuchsia_cipd_releases( 228 name = "bt_host_x64_cipd", 229 cipd_prefix = "fuchsia/prebuilt/bt-host", 230 extra_content = { 231 ":README.fuchsia.md": "README.fuchsia", 232 ":bt_host_x64_licenses.spdx.json": "licenses.spdx.json", 233 }, 234 pkg = ":pkg.x64", 235 # TODO: b/354711360 - fuchsia_cipd_releases appears to be misconfigured 236 # when cross-compiling, 237 target_compatible_with = incompatible_with_mcu(), 238) 239 240fuchsia_cipd_releases( 241 name = "bt_host_arm64_cipd", 242 cipd_prefix = "fuchsia/prebuilt/bt-host", 243 extra_content = { 244 ":README.fuchsia.md": "README.fuchsia", 245 ":bt_host_arm64_licenses.spdx.json": "licenses.spdx.json", 246 }, 247 pkg = ":pkg.arm64", 248 # TODO: b/354711360 - fuchsia_cipd_releases appears to be misconfigured 249 # when cross-compiling, 250 target_compatible_with = incompatible_with_mcu(), 251) 252 253fuchsia_cipd_releases( 254 name = "bt_host_riscv64_cipd", 255 cipd_prefix = "fuchsia/prebuilt/bt-host", 256 extra_content = { 257 ":README.fuchsia.md": "README.fuchsia", 258 ":bt_host_riscv64_licenses.spdx.json": "licenses.spdx.json", 259 }, 260 pkg = ":pkg.riscv64", 261 # TODO: b/354711360 - fuchsia_cipd_releases appears to be misconfigured 262 # when cross-compiling, 263 target_compatible_with = incompatible_with_mcu(), 264) 265