1# Copyright 2019 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("@aspect_bazel_lib//lib:directory_path.bzl", "directory_path") 16load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_run_binary") 17load("@bazel_skylib//rules:copy_file.bzl", "copy_file") 18load("@hedron_compile_commands//:refresh_compile_commands.bzl", "refresh_compile_commands") 19load("@npm//:defs.bzl", "npm_link_all_packages") 20load("@pigweed//pw_build:compatibility.bzl", "incompatible_with_mcu") 21load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library") 22 23licenses(["notice"]) 24 25# Needed for releasing //pw_bluetooth_sapphire/fuchsia/bt_host. 26exports_files( 27 ["LICENSE"], 28 visibility = [":__subpackages__"], 29) 30 31exports_files( 32 [ 33 "pigweed.json", 34 "PIGWEED_MODULES", 35 "tsconfig.json", 36 ], 37 visibility = [":__subpackages__"], 38) 39 40filegroup( 41 name = "pigweed_json", 42 srcs = ["pigweed.json"], 43 visibility = [":__subpackages__"], 44) 45 46alias( 47 name = "watch", 48 actual = "//pw_watch/py:bazel", 49) 50 51# Symlink to clangd, for user convenience. 52copy_file( 53 name = "copy_clangd", 54 src = "@llvm_toolchain//:bin/clangd", 55 out = "clangd", 56 allow_symlink = True, 57) 58 59# The Fuchsia SDK is only supported on Linux hosts, so the target that 60# generates compile commands for targets built for Fuchsia is separate from 61# the more general-purpose `refresh_compile_commands` target. 62refresh_compile_commands( 63 name = "refresh_compile_commands_for_fuchsia_sdk", 64 out_dir = ".compile_commands", 65 target_compatible_with = select({ 66 "@platforms//os:linux": [], 67 "//conditions:default": ["@platforms//:incompatible"], 68 }), 69 target_groups = { 70 "fuchsia": [ 71 [ 72 "//pw_bluetooth_sapphire/fuchsia/bt_host:test_pkg", 73 "--config=fuchsia", 74 ], 75 [ 76 "//pw_bluetooth_sapphire/fuchsia/host/att:test_pkg", 77 "--config=fuchsia", 78 ], 79 [ 80 "//pw_bluetooth_sapphire/fuchsia/host/common:test_pkg", 81 "--config=fuchsia", 82 ], 83 [ 84 "//pw_bluetooth_sapphire/fuchsia/host/controllers:test_pkg", 85 "--config=fuchsia", 86 ], 87 [ 88 "//pw_bluetooth_sapphire/fuchsia/host/fidl:test_pkg", 89 "--config=fuchsia", 90 ], 91 [ 92 "//pw_bluetooth_sapphire/fuchsia/host/gap:test_pkg", 93 "--config=fuchsia", 94 ], 95 [ 96 "//pw_bluetooth_sapphire/fuchsia/host/gatt:test_pkg", 97 "--config=fuchsia", 98 ], 99 [ 100 "//pw_bluetooth_sapphire/fuchsia/host/hci:test_pkg", 101 "--config=fuchsia", 102 ], 103 [ 104 "//pw_bluetooth_sapphire/fuchsia/host/hci-spec:test_pkg", 105 "--config=fuchsia", 106 ], 107 [ 108 "//pw_bluetooth_sapphire/fuchsia/host/iso:test_pkg", 109 "--config=fuchsia", 110 ], 111 [ 112 "//pw_bluetooth_sapphire/fuchsia/host/l2cap:test_pkg", 113 "--config=fuchsia", 114 ], 115 [ 116 "//pw_bluetooth_sapphire/fuchsia/host/sco:test_pkg", 117 "--config=fuchsia", 118 ], 119 [ 120 "//pw_bluetooth_sapphire/fuchsia/host/sdp:test_pkg", 121 "--config=fuchsia", 122 ], 123 [ 124 "//pw_bluetooth_sapphire/fuchsia/host/sm:test_pkg", 125 "--config=fuchsia", 126 ], 127 [ 128 "//pw_bluetooth_sapphire/fuchsia/host/socket:test_pkg", 129 "--config=fuchsia", 130 ], 131 [ 132 "//pw_bluetooth_sapphire/fuchsia/host/testing:test_pkg", 133 "--config=fuchsia", 134 ], 135 [ 136 "//pw_bluetooth_sapphire/fuchsia/host/transport:test_pkg", 137 "--config=fuchsia", 138 ], 139 ], 140 }, 141) 142 143sphinx_docs_library( 144 name = "docs", 145 srcs = [ 146 ".bazelversion", 147 "Kconfig.zephyr", 148 ], 149 target_compatible_with = incompatible_with_mcu(), 150 visibility = ["//visibility:public"], 151) 152 153# NPM bundling via rollup 154npm_link_all_packages(name = "node_modules") 155 156directory_path( 157 name = "rollup_entry_point", 158 directory = "//:node_modules/rollup/dir", 159 path = "dist/bin/rollup", 160 target_compatible_with = incompatible_with_mcu(), 161) 162 163js_binary( 164 name = "rollup_bin", 165 entry_point = ":rollup_entry_point", 166 target_compatible_with = incompatible_with_mcu(), 167) 168 169filegroup( 170 name = "js_files", 171 srcs = glob([ 172 "ts/**/*.ts", 173 ]) + [ 174 "package.json", 175 "rollup.config.js", 176 "rollup-protos.config.js", 177 "tsconfig.json", 178 ], 179) 180 181js_run_binary( 182 name = "build_protos_builder", 183 srcs = [ 184 ":js_files", 185 ":node_modules", 186 "//pw_hdlc/ts:js_files", 187 "//pw_protobuf_compiler/ts:js_files", 188 "//pw_status/ts:js_files", 189 "//pw_tokenizer/ts:js_files", 190 ], 191 outs = ["dist/bin/build_default_protos.js"], 192 args = ["-c rollup-protos.config.js"], 193 target_compatible_with = incompatible_with_mcu(), 194 tool = ":rollup_bin", 195) 196 197js_binary( 198 name = "build_protos_binary", 199 entry_point = ":build_protos_builder", 200 target_compatible_with = incompatible_with_mcu(), 201) 202 203js_run_binary( 204 name = "build_protos", 205 srcs = [ 206 ":js_files", 207 ":node_modules", 208 "//pw_log:js_protos", 209 "//pw_protobuf:js_protos", 210 "//pw_protobuf_compiler/ts:js_files", 211 "//pw_rpc/ts:js_files", 212 "//pw_tokenizer/ts:js_files", 213 "//pw_transfer/ts:js_files", 214 ], 215 out_dirs = ["dist/protos"], 216 target_compatible_with = incompatible_with_mcu(), 217 tool = ":build_protos_binary", 218) 219 220js_run_binary( 221 name = "pw_web", 222 srcs = [ 223 ":build_protos", 224 ":js_files", 225 ":node_modules", 226 "//pw_hdlc/ts:js_files", 227 "//pw_protobuf_compiler/ts:js_files", 228 "//pw_rpc/ts:js_files", 229 "//pw_status/ts:js_files", 230 "//pw_tokenizer/ts:js_files", 231 "//pw_transfer/ts:js_files", 232 "//pw_web:js_files", 233 ], 234 outs = [ 235 "dist/index.mjs", 236 "dist/index.mjs.map", 237 "dist/index.umd.js", 238 "dist/index.umd.js.map", 239 "dist/logging.mjs", 240 "dist/logging.umd.js", 241 "dist/logging.umd.js.map", 242 "dist/proto_collection.umd.js", 243 "dist/proto_collection.umd.js.map", 244 "dist/pw_console.mjs", 245 "dist/pw_console.umd.js", 246 "dist/pw_console.umd.js.map", 247 ], 248 args = ["-c"], 249 target_compatible_with = incompatible_with_mcu(), 250 tool = ":rollup_bin", 251) 252 253filegroup( 254 name = "clang_tidy_config", 255 srcs = [".clang-tidy"], 256 visibility = ["//visibility:public"], 257) 258