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