Nathaniel Brough | 82cf687 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 1 | # Copyright 2021 The Pigweed Authors |
Rob Mohr | be98ead | 2019-11-14 07:16:40 -0800 | [diff] [blame] | 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. |
Matthew Soulanille | 376d797 | 2020-06-01 15:50:07 -0700 | [diff] [blame] | 14 | |
| 15 | workspace( |
| 16 | name = "pigweed", |
| 17 | managed_directories = {"@npm": ["node_modules"]}, |
| 18 | ) |
| 19 | |
Matthew Soulanille | 376d797 | 2020-06-01 15:50:07 -0700 | [diff] [blame] | 20 | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") |
Nathaniel Brough | 82cf687 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 21 | load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") |
Nathaniel Brough | 68ef2a5 | 2021-07-16 13:51:19 +0800 | [diff] [blame] | 22 | load("//pw_env_setup/bazel/cipd_setup:cipd_rules.bzl", "pigweed_deps") |
| 23 | |
| 24 | # Setup CIPD client and packages. |
| 25 | # Required by: pigweed. |
| 26 | # Used by modules: all. |
| 27 | pigweed_deps() |
| 28 | |
| 29 | load("@cipd_deps//:cipd_init.bzl", "cipd_init") |
| 30 | |
| 31 | cipd_init() |
Nathaniel Brough | 82cf687 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 32 | |
Nathaniel Brough | f91e763 | 2021-07-26 17:12:14 +0800 | [diff] [blame] | 33 | # Set up Python support. |
Nathaniel Brough | b6b90d0 | 2021-05-11 11:32:17 +0800 | [diff] [blame] | 34 | # Required by: rules_fuzzing. |
| 35 | # Used in modules: None. |
| 36 | http_archive( |
| 37 | name = "rules_python", |
Anthony DiGirolamo | d63bd74 | 2021-08-19 16:13:30 -0700 | [diff] [blame] | 38 | sha256 = "934c9ceb552e84577b0faf1e5a2f0450314985b4d8712b2b70717dc679fdc01b", |
| 39 | url = "https://github.com/bazelbuild/rules_python/releases/download/0.3.0/rules_python-0.3.0.tar.gz", |
Nathaniel Brough | b6b90d0 | 2021-05-11 11:32:17 +0800 | [diff] [blame] | 40 | ) |
| 41 | |
Nathaniel Brough | f91e763 | 2021-07-26 17:12:14 +0800 | [diff] [blame] | 42 | # Set up Starlark library. |
Nathaniel Brough | a1113be | 2021-03-07 09:05:41 +0800 | [diff] [blame] | 43 | # Required by: io_bazel_rules_go, com_google_protobuf. |
| 44 | # Used in modules: None. |
| 45 | # This must be instantiated before com_google_protobuf as protobuf_deps() pulls |
| 46 | # in an older version of bazel_skylib. However io_bazel_rules_go requires a |
| 47 | # newer version. |
| 48 | http_archive( |
| 49 | name = "bazel_skylib", |
| 50 | sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c", |
| 51 | urls = [ |
| 52 | "https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz", |
| 53 | "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz", |
| 54 | ], |
| 55 | ) |
| 56 | |
| 57 | load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") |
| 58 | |
| 59 | bazel_skylib_workspace() |
| 60 | |
Nathaniel Brough | f91e763 | 2021-07-26 17:12:14 +0800 | [diff] [blame] | 61 | # Set up upstream googletest and googlemock. |
| 62 | # Required by: Pigweed. |
| 63 | # Used in modules: //pw_analog, //pw_i2c. |
| 64 | http_archive( |
| 65 | name = "com_google_googletest", |
| 66 | sha256 = "9dc9157a9a1551ec7a7e43daea9a694a0bb5fb8bec81235d8a1e6ef64c716dcb", |
| 67 | strip_prefix = "googletest-release-1.10.0", |
| 68 | urls = [ |
| 69 | "https://mirror.bazel.build/github.com/google/googletest/archive/release-1.10.0.tar.gz", |
| 70 | "https://github.com/google/googletest/archive/release-1.10.0.tar.gz", |
| 71 | ], |
| 72 | ) |
| 73 | |
| 74 | # Set up host hermetic host toolchain. |
Nathaniel Brough | b44d95e | 2021-07-15 10:39:47 +0800 | [diff] [blame] | 75 | # Required by: All cc targets. |
| 76 | # Used in modules: All cc targets. |
| 77 | git_repository( |
| 78 | name = "rules_cc_toolchain", |
Nathaniel Brough | f9cc041 | 2021-08-17 09:32:32 +0800 | [diff] [blame] | 79 | commit = "80b51ba81f14eebe06684efa25261f6dc46e9b29", |
Nathaniel Brough | b44d95e | 2021-07-15 10:39:47 +0800 | [diff] [blame] | 80 | remote = "https://github.com/silvergasp/rules_cc_toolchain.git", |
| 81 | ) |
| 82 | |
| 83 | load("@rules_cc_toolchain//:rules_cc_toolchain_deps.bzl", "rules_cc_toolchain_deps") |
| 84 | |
| 85 | rules_cc_toolchain_deps() |
| 86 | |
| 87 | load("@rules_cc_toolchain//cc_toolchain:cc_toolchain.bzl", "register_cc_toolchains") |
| 88 | |
| 89 | register_cc_toolchains() |
| 90 | |
Nathaniel Brough | f91e763 | 2021-07-26 17:12:14 +0800 | [diff] [blame] | 91 | # Set up Protobuf rules. |
Nathaniel Brough | a1113be | 2021-03-07 09:05:41 +0800 | [diff] [blame] | 92 | # Required by: pigweed, com_github_bazelbuild_buildtools. |
| 93 | # Used in modules: //pw_protobuf. |
| 94 | http_archive( |
| 95 | name = "com_google_protobuf", |
Anthony DiGirolamo | d63bd74 | 2021-08-19 16:13:30 -0700 | [diff] [blame] | 96 | sha256 = "c6003e1d2e7fefa78a3039f19f383b4f3a61e81be8c19356f85b6461998ad3db", |
| 97 | strip_prefix = "protobuf-3.17.3", |
| 98 | url = "https://github.com/protocolbuffers/protobuf/archive/v3.17.3.tar.gz", |
Nathaniel Brough | a1113be | 2021-03-07 09:05:41 +0800 | [diff] [blame] | 99 | ) |
| 100 | |
| 101 | load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") |
| 102 | |
| 103 | protobuf_deps() |
| 104 | |
Nathaniel Brough | f91e763 | 2021-07-26 17:12:14 +0800 | [diff] [blame] | 105 | # Set up tools to build custom GRPC rules. |
Nathaniel Brough | b4f4e7a | 2021-05-06 14:49:55 +0800 | [diff] [blame] | 106 | # Required by: pigweed. |
Nathaniel Brough | f91e763 | 2021-07-26 17:12:14 +0800 | [diff] [blame] | 107 | # Used in modules: //pw_protobuf. |
Nathaniel Brough | 9d9a20d | 2020-08-04 16:46:56 +0800 | [diff] [blame] | 108 | http_archive( |
| 109 | name = "rules_proto_grpc", |
Jared Weinstein | 27ab4e1 | 2021-08-16 14:52:33 -0700 | [diff] [blame] | 110 | sha256 = "7954abbb6898830cd10ac9714fbcacf092299fda00ed2baf781172f545120419", |
| 111 | strip_prefix = "rules_proto_grpc-3.1.1", |
| 112 | urls = ["https://github.com/rules-proto-grpc/rules_proto_grpc/archive/3.1.1.tar.gz"], |
Nathaniel Brough | 9d9a20d | 2020-08-04 16:46:56 +0800 | [diff] [blame] | 113 | ) |
| 114 | |
Nathaniel Brough | b4f4e7a | 2021-05-06 14:49:55 +0800 | [diff] [blame] | 115 | load( |
| 116 | "@rules_proto_grpc//:repositories.bzl", |
| 117 | "rules_proto_grpc_repos", |
| 118 | "rules_proto_grpc_toolchains", |
| 119 | ) |
Nathaniel Brough | 9d9a20d | 2020-08-04 16:46:56 +0800 | [diff] [blame] | 120 | |
| 121 | rules_proto_grpc_toolchains() |
| 122 | |
| 123 | rules_proto_grpc_repos() |
| 124 | |
Nathaniel Brough | f91e763 | 2021-07-26 17:12:14 +0800 | [diff] [blame] | 125 | # Set up Bazel platforms. |
Nathaniel Brough | a1113be | 2021-03-07 09:05:41 +0800 | [diff] [blame] | 126 | # Required by: pigweed. |
Nathaniel Brough | f91e763 | 2021-07-26 17:12:14 +0800 | [diff] [blame] | 127 | # Used in modules: //pw_build, (Assorted modules via select statements). |
Nathaniel Brough | c2d5781 | 2021-04-18 22:52:00 +0800 | [diff] [blame] | 128 | git_repository( |
| 129 | name = "platforms", |
| 130 | commit = "d4c9d7f51a7c403814b60f66d20eeb425fbaaacb", |
| 131 | remote = "https://github.com/bazelbuild/platforms.git", |
| 132 | ) |
| 133 | |
Nathaniel Brough | f91e763 | 2021-07-26 17:12:14 +0800 | [diff] [blame] | 134 | # Set up NodeJs rules. |
| 135 | # Required by: pigweed. |
| 136 | # Used in modules: //pw_web_ui. |
Matthew Soulanille | 376d797 | 2020-06-01 15:50:07 -0700 | [diff] [blame] | 137 | http_archive( |
Nathaniel Brough | b44d95e | 2021-07-15 10:39:47 +0800 | [diff] [blame] | 138 | name = "build_bazel_rules_nodejs", |
Jared Weinstein | cf2ca74 | 2021-07-02 17:20:05 -0700 | [diff] [blame] | 139 | sha256 = "8f5f192ba02319254aaf2cdcca00ec12eaafeb979a80a1e946773c520ae0a2c9", |
| 140 | urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/3.7.0/rules_nodejs-3.7.0.tar.gz"], |
Matthew Soulanille | 376d797 | 2020-06-01 15:50:07 -0700 | [diff] [blame] | 141 | ) |
Nathaniel Brough | 82cf687 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 142 | |
| 143 | # Get the latest LTS version of Node. |
| 144 | load( |
| 145 | "@build_bazel_rules_nodejs//:index.bzl", |
| 146 | "node_repositories", |
| 147 | "yarn_install", |
| 148 | ) |
| 149 | |
Matthew Soulanille | 376d797 | 2020-06-01 15:50:07 -0700 | [diff] [blame] | 150 | node_repositories(package_json = ["//:package.json"]) |
| 151 | |
Matthew Soulanille | 376d797 | 2020-06-01 15:50:07 -0700 | [diff] [blame] | 152 | yarn_install( |
| 153 | name = "npm", |
| 154 | package_json = "//:package.json", |
| 155 | yarn_lock = "//:yarn.lock", |
| 156 | ) |
| 157 | |
Nathaniel Brough | f91e763 | 2021-07-26 17:12:14 +0800 | [diff] [blame] | 158 | # Set up web-testing rules. |
| 159 | # Required by: pigweed. |
| 160 | # Used in modules: //pw_web_ui. |
Nathaniel Brough | 9d9a20d | 2020-08-04 16:46:56 +0800 | [diff] [blame] | 161 | http_archive( |
| 162 | name = "io_bazel_rules_webtesting", |
| 163 | sha256 = "9bb461d5ef08e850025480bab185fd269242d4e533bca75bfb748001ceb343c3", |
| 164 | urls = ["https://github.com/bazelbuild/rules_webtesting/releases/download/0.3.3/rules_webtesting.tar.gz"], |
Nathaniel Brough | 82cf687 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 165 | ) |
| 166 | |
Nathaniel Brough | 9d9a20d | 2020-08-04 16:46:56 +0800 | [diff] [blame] | 167 | load("@io_bazel_rules_webtesting//web:repositories.bzl", "web_test_repositories") |
| 168 | |
Matthew Soulanille | 5e78acf | 2020-06-08 10:58:29 -0700 | [diff] [blame] | 169 | web_test_repositories() |
| 170 | |
Nathaniel Brough | 82cf687 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 171 | load( |
| 172 | "@io_bazel_rules_webtesting//web/versioned:browsers-0.3.2.bzl", |
| 173 | "browser_repositories", |
| 174 | ) |
Matthew Soulanille | 5e78acf | 2020-06-08 10:58:29 -0700 | [diff] [blame] | 175 | |
| 176 | browser_repositories( |
| 177 | chromium = True, |
| 178 | firefox = True, |
| 179 | ) |
| 180 | |
Nathaniel Brough | f91e763 | 2021-07-26 17:12:14 +0800 | [diff] [blame] | 181 | # Set up embedded C/C++ toolchains. |
Nathaniel Brough | a1113be | 2021-03-07 09:05:41 +0800 | [diff] [blame] | 182 | # Required by: pigweed. |
| 183 | # Used in modules: //pw_polyfill, //pw_build (all pw_cc* targets). |
Nathaniel Brough | 82cf687 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 184 | git_repository( |
| 185 | name = "bazel_embedded", |
Nathaniel Brough | b371831 | 2021-09-16 08:26:34 +0800 | [diff] [blame] | 186 | commit = "17c93d5fa52c4c78860b8bbd327325fba6c85555", |
Nathaniel Brough | 82cf687 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 187 | remote = "https://github.com/silvergasp/bazel-embedded.git", |
Nathaniel Brough | 82cf687 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 188 | ) |
| 189 | |
| 190 | # Instantiate Pigweed configuration for embedded toolchain, |
| 191 | # this must be called before bazel_embedded_deps. |
| 192 | load( |
| 193 | "//pw_build:pigweed_toolchain_upstream.bzl", |
| 194 | "toolchain_upstream_deps", |
| 195 | ) |
| 196 | |
| 197 | toolchain_upstream_deps() |
| 198 | |
| 199 | # Configure bazel_embedded toolchains and platforms. |
| 200 | load( |
| 201 | "@bazel_embedded//:bazel_embedded_deps.bzl", |
| 202 | "bazel_embedded_deps", |
| 203 | ) |
| 204 | |
| 205 | bazel_embedded_deps() |
| 206 | |
| 207 | load( |
| 208 | "@bazel_embedded//platforms:execution_platforms.bzl", |
| 209 | "register_platforms", |
| 210 | ) |
| 211 | |
| 212 | register_platforms() |
| 213 | |
| 214 | # Fetch gcc-arm-none-eabi compiler and register for toolchain |
| 215 | # resolution. |
| 216 | load( |
| 217 | "@bazel_embedded//toolchains/compilers/gcc_arm_none_eabi:gcc_arm_none_repository.bzl", |
| 218 | "gcc_arm_none_compiler", |
| 219 | ) |
| 220 | |
| 221 | gcc_arm_none_compiler() |
| 222 | |
| 223 | load( |
| 224 | "@bazel_embedded//toolchains/gcc_arm_none_eabi:gcc_arm_none_toolchain.bzl", |
| 225 | "register_gcc_arm_none_toolchain", |
| 226 | ) |
| 227 | |
| 228 | register_gcc_arm_none_toolchain() |
| 229 | |
Nathaniel Brough | a1113be | 2021-03-07 09:05:41 +0800 | [diff] [blame] | 230 | # Registers platforms for use with toolchain resolution |
Nathaniel Brough | ce91098 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 231 | register_execution_platforms("//pw_build/platforms:all") |
Nathaniel Brough | a1113be | 2021-03-07 09:05:41 +0800 | [diff] [blame] | 232 | |
Nathaniel Brough | f91e763 | 2021-07-26 17:12:14 +0800 | [diff] [blame] | 233 | # Set up Golang toolchain rules. |
Nathaniel Brough | a1113be | 2021-03-07 09:05:41 +0800 | [diff] [blame] | 234 | # Required by: bazel_gazelle, com_github_bazelbuild_buildtools. |
| 235 | # Used in modules: None. |
| 236 | http_archive( |
| 237 | name = "io_bazel_rules_go", |
| 238 | sha256 = "d1ffd055969c8f8d431e2d439813e42326961d0942bdf734d2c95dc30c369566", |
| 239 | urls = [ |
| 240 | "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.5/rules_go-v0.24.5.tar.gz", |
| 241 | "https://github.com/bazelbuild/rules_go/releases/download/v0.24.5/rules_go-v0.24.5.tar.gz", |
| 242 | ], |
| 243 | ) |
| 244 | |
| 245 | load( |
| 246 | "@io_bazel_rules_go//go:deps.bzl", |
| 247 | "go_register_toolchains", |
| 248 | "go_rules_dependencies", |
| 249 | ) |
| 250 | |
| 251 | go_rules_dependencies() |
| 252 | |
| 253 | go_register_toolchains() |
| 254 | |
Nathaniel Brough | f91e763 | 2021-07-26 17:12:14 +0800 | [diff] [blame] | 255 | # Set up bazel package manager for golang. |
Nathaniel Brough | a1113be | 2021-03-07 09:05:41 +0800 | [diff] [blame] | 256 | # Required by: com_github_bazelbuild_buildtools. |
Nathaniel Brough | f91e763 | 2021-07-26 17:12:14 +0800 | [diff] [blame] | 257 | # Used in modules: None. |
Nathaniel Brough | a1113be | 2021-03-07 09:05:41 +0800 | [diff] [blame] | 258 | http_archive( |
| 259 | name = "bazel_gazelle", |
| 260 | sha256 = "b85f48fa105c4403326e9525ad2b2cc437babaa6e15a3fc0b1dbab0ab064bc7c", |
| 261 | urls = [ |
| 262 | "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.2/bazel-gazelle-v0.22.2.tar.gz", |
| 263 | "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.2/bazel-gazelle-v0.22.2.tar.gz", |
| 264 | ], |
| 265 | ) |
| 266 | |
| 267 | load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") |
| 268 | |
| 269 | gazelle_dependencies() |
| 270 | |
Nathaniel Brough | f91e763 | 2021-07-26 17:12:14 +0800 | [diff] [blame] | 271 | # Set up bazel buildtools (bazel linter and formatter). |
| 272 | # Required by: pigweed. |
Nathaniel Brough | a1113be | 2021-03-07 09:05:41 +0800 | [diff] [blame] | 273 | # Used in modules: //:all (bazel specific tools). |
| 274 | http_archive( |
| 275 | name = "com_github_bazelbuild_buildtools", |
| 276 | sha256 = "c28eef4d30ba1a195c6837acf6c75a4034981f5b4002dda3c5aa6e48ce023cf1", |
| 277 | strip_prefix = "buildtools-4.0.1", |
| 278 | url = "https://github.com/bazelbuild/buildtools/archive/4.0.1.tar.gz", |
| 279 | ) |
Nathaniel Brough | fc95cca | 2021-04-18 22:20:26 +0800 | [diff] [blame] | 280 | |
| 281 | load("//pw_build:target_config.bzl", "pigweed_config") |
| 282 | |
| 283 | # Configure Pigweeds backend. |
| 284 | pigweed_config( |
| 285 | name = "pigweed_config", |
| 286 | build_file = "//targets:default_config.BUILD", |
| 287 | ) |
Nathaniel Brough | b6b90d0 | 2021-05-11 11:32:17 +0800 | [diff] [blame] | 288 | |
Nathaniel Brough | f91e763 | 2021-07-26 17:12:14 +0800 | [diff] [blame] | 289 | # Set up rules for fuzz testing. |
Nathaniel Brough | b6b90d0 | 2021-05-11 11:32:17 +0800 | [diff] [blame] | 290 | # Required by: pigweed. |
Nathaniel Brough | f91e763 | 2021-07-26 17:12:14 +0800 | [diff] [blame] | 291 | # Used in modules: //pw_protobuf, //pw_tokenizer, //pw_fuzzer. |
Nathaniel Brough | b6b90d0 | 2021-05-11 11:32:17 +0800 | [diff] [blame] | 292 | http_archive( |
| 293 | name = "rules_fuzzing", |
| 294 | sha256 = "94f25c7a18db0502ace26a3ef7d0a25fd7c195c4e9770ddd1b1ec718e8936091", |
| 295 | strip_prefix = "rules_fuzzing-0.1.3", |
| 296 | urls = ["https://github.com/bazelbuild/rules_fuzzing/archive/v0.1.3.zip"], |
| 297 | ) |
| 298 | |
| 299 | load("@rules_fuzzing//fuzzing:repositories.bzl", "rules_fuzzing_dependencies") |
| 300 | |
| 301 | rules_fuzzing_dependencies() |
| 302 | |
| 303 | load("@rules_fuzzing//fuzzing:init.bzl", "rules_fuzzing_init") |
| 304 | |
| 305 | rules_fuzzing_init() |