1# Copyright 2021 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 15workspace( 16 name = "pigweed", 17) 18 19load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 20load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository", "new_git_repository") 21load( 22 "//pw_env_setup/bazel/cipd_setup:cipd_rules.bzl", 23 "cipd_client_repository", 24 "cipd_repository", 25 "pigweed_deps", 26) 27 28# Set up Bazel platforms. 29# Required by: pigweed. 30# Used in modules: //pw_build, (Assorted modules via select statements). 31http_archive( 32 name = "platforms", 33 sha256 = "5308fc1d8865406a49427ba24a9ab53087f17f5266a7aabbfc28823f3916e1ca", 34 urls = [ 35 "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.6/platforms-0.0.6.tar.gz", 36 "https://github.com/bazelbuild/platforms/releases/download/0.0.6/platforms-0.0.6.tar.gz", 37 ], 38) 39 40# Setup CIPD client and packages. 41# Required by: pigweed. 42# Used by modules: all. 43pigweed_deps() 44 45load("@cipd_deps//:cipd_init.bzl", "cipd_init") 46 47cipd_init() 48 49cipd_client_repository() 50 51cipd_repository( 52 name = "pw_transfer_test_binaries", 53 path = "pigweed/pw_transfer_test_binaries/${os=linux}-${arch=amd64}", 54 tag = "version:pw_transfer_test_binaries_528098d588f307881af83f769207b8e6e1b57520-linux-amd64-cipd.cipd", 55) 56 57# Set up Python support. 58# Required by: rules_fuzzing, com_github_nanopb_nanopb. 59# Used in modules: None. 60http_archive( 61 name = "rules_python", 62 sha256 = "a30abdfc7126d497a7698c29c46ea9901c6392d6ed315171a6df5ce433aa4502", 63 strip_prefix = "rules_python-0.6.0", 64 url = "https://github.com/bazelbuild/rules_python/archive/0.6.0.tar.gz", 65) 66 67# Set up Starlark library. 68# Required by: io_bazel_rules_go, com_google_protobuf. 69# Used in modules: None. 70# This must be instantiated before com_google_protobuf as protobuf_deps() pulls 71# in an older version of bazel_skylib. However io_bazel_rules_go requires a 72# newer version. 73http_archive( 74 name = "bazel_skylib", # 2022-09-01 75 sha256 = "4756ab3ec46d94d99e5ed685d2d24aece484015e45af303eb3a11cab3cdc2e71", 76 strip_prefix = "bazel-skylib-1.3.0", 77 urls = ["https://github.com/bazelbuild/bazel-skylib/archive/refs/tags/1.3.0.zip"], 78) 79 80load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") 81 82bazel_skylib_workspace() 83 84# Set up upstream googletest and googlemock. 85# Required by: Pigweed. 86# Used in modules: //pw_analog, //pw_i2c. 87http_archive( 88 name = "com_google_googletest", 89 sha256 = "ad7fdba11ea011c1d925b3289cf4af2c66a352e18d4c7264392fead75e919363", 90 strip_prefix = "googletest-1.13.0", 91 urls = [ 92 "https://github.com/google/googletest/archive/refs/tags/v1.13.0.tar.gz", 93 ], 94) 95 96# Set up host hermetic host toolchain. 97# Required by: All cc targets. 98# Used in modules: All cc targets. 99git_repository( 100 name = "rules_cc_toolchain", 101 commit = "9f209fda87414285bc66accd3612575b29760fba", 102 remote = "https://github.com/bazelembedded/rules_cc_toolchain", 103 shallow_since = "1675385535 -0800", 104) 105 106load("@rules_cc_toolchain//:rules_cc_toolchain_deps.bzl", "rules_cc_toolchain_deps") 107 108rules_cc_toolchain_deps() 109 110load("@rules_cc_toolchain//cc_toolchain:cc_toolchain.bzl", "register_cc_toolchains") 111 112register_cc_toolchains() 113 114# Sets up Bazels documentation generator. 115# Required by: rules_cc_toolchain. 116# Required by modules: All 117git_repository( 118 name = "io_bazel_stardoc", 119 commit = "2b801dc9b93f73812948ee4e505805511b0f55dc", 120 remote = "https://github.com/bazelbuild/stardoc.git", 121 shallow_since = "1651081130 -0400", 122) 123 124# Set up tools to build custom GRPC rules. 125# 126# We use a fork that silences some zlib compilation warnings. 127# 128# Required by: pigweed. 129# Used in modules: //pw_protobuf. 130git_repository( 131 name = "rules_proto_grpc", 132 commit = "2fbf774a5553b773372f7b91f9b1dc06ee0da2d3", 133 remote = "https://github.com/tpudlik/rules_proto_grpc.git", 134 shallow_since = "1675375991 -0800", 135) 136 137load( 138 "@rules_proto_grpc//:repositories.bzl", 139 "rules_proto_grpc_repos", 140 "rules_proto_grpc_toolchains", 141) 142 143rules_proto_grpc_toolchains() 144 145rules_proto_grpc_repos() 146 147# Set up Protobuf rules. 148# Required by: pigweed. 149# Used in modules: //pw_protobuf. 150http_archive( 151 name = "com_google_protobuf", 152 sha256 = "c6003e1d2e7fefa78a3039f19f383b4f3a61e81be8c19356f85b6461998ad3db", 153 strip_prefix = "protobuf-3.17.3", 154 url = "https://github.com/protocolbuffers/protobuf/archive/v3.17.3.tar.gz", 155) 156 157load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") 158 159protobuf_deps() 160 161# Setup Nanopb protoc plugin. 162# Required by: Pigweed. 163# Used in modules: pw_protobuf. 164git_repository( 165 name = "com_github_nanopb_nanopb", 166 commit = "e601fca6d9ed7fb5c09e2732452753b2989f128b", 167 remote = "https://github.com/nanopb/nanopb.git", 168 shallow_since = "1641373017 +0800", 169) 170 171load("@com_github_nanopb_nanopb//:nanopb_deps.bzl", "nanopb_deps") 172 173nanopb_deps() 174 175load("@com_github_nanopb_nanopb//:python_deps.bzl", "nanopb_python_deps") 176 177nanopb_python_deps() 178 179load("@com_github_nanopb_nanopb//:nanopb_workspace.bzl", "nanopb_workspace") 180 181nanopb_workspace() 182 183# Set up embedded C/C++ toolchains. 184# Required by: pigweed. 185# Used in modules: //pw_polyfill, //pw_build (all pw_cc* targets). 186git_repository( 187 name = "bazel_embedded", 188 commit = "91dcc13ebe5df755ca2fe896ff6f7884a971d05b", 189 remote = "https://github.com/bazelembedded/bazel-embedded.git", 190 shallow_since = "1631751909 +0800", 191) 192 193# Configure bazel_embedded toolchains and platforms. 194load( 195 "@bazel_embedded//:bazel_embedded_deps.bzl", 196 "bazel_embedded_deps", 197) 198 199bazel_embedded_deps() 200 201load( 202 "@bazel_embedded//platforms:execution_platforms.bzl", 203 "register_platforms", 204) 205 206register_platforms() 207 208# Fetch gcc-arm-none-eabi compiler and register for toolchain 209# resolution. 210load( 211 "@bazel_embedded//toolchains/compilers/gcc_arm_none_eabi:gcc_arm_none_repository.bzl", 212 "gcc_arm_none_compiler", 213) 214 215gcc_arm_none_compiler() 216 217load( 218 "@bazel_embedded//toolchains/gcc_arm_none_eabi:gcc_arm_none_toolchain.bzl", 219 "register_gcc_arm_none_toolchain", 220) 221 222register_gcc_arm_none_toolchain() 223 224# Rust Support 225# 226 227git_repository( 228 name = "rules_rust", 229 # Pulls in the main branch with https://github.com/bazelbuild/rules_rust/pull/1803 230 # merged. Once a release is cut with that commit, we should switch to 231 # using a release tarbal. 232 commit = "a5853fd37053b65ee30ba4f8064b9db67c90d53f", 233 remote = "https://github.com/bazelbuild/rules_rust", 234 shallow_since = "1675302817 -0800", 235) 236 237load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_analyzer_toolchain_repository", "rust_repository_set") 238 239rules_rust_dependencies() 240 241# Here we pull in a specific toolchain. Unfortunately `rust_repository_set` 242# does not provide a way to add `target_compatible_with` options which are 243# needed to be compatible with `@bazel_embedded` (specifically 244# `@bazel_embedded//constraints/fpu:none` which is specified in 245# `//platforms`) 246# 247# See `//toolchain:rust_linux_x86_64` for how this is used. 248# 249# Note: This statement creates name mangled remotes of the form: 250# `@{name}__{triplet}_tools` 251# (example: `@rust_linux_x86_64__thumbv7m-none-eabi_tools/`) 252rust_repository_set( 253 name = "rust_linux_x86_64", 254 edition = "2021", 255 exec_triple = "x86_64-unknown-linux-gnu", 256 extra_target_triples = [ 257 "thumbv7m-none-eabi", 258 "thumbv6m-none-eabi", 259 ], 260 versions = ["1.67.0"], 261) 262 263# Registers our Rust toolchains that are compatable with `@bazel_embedded`. 264register_toolchains( 265 "//pw_toolchain:thumbv7m_rust_linux_x86_64", 266 "//pw_toolchain:thumbv6m_rust_linux_x86_64", 267) 268 269# Allows creation of a `rust-project.json` file to allow rust analyzer to work. 270load("@rules_rust//tools/rust_analyzer:deps.bzl", "rust_analyzer_dependencies") 271 272# Since we do not use rust_register_toolchains, we need to define a 273# rust_analyzer_toolchain. 274register_toolchains(rust_analyzer_toolchain_repository( 275 name = "rust_analyzer_toolchain", 276 # This should match the currently registered toolchain. 277 version = "1.67.0", 278)) 279 280rust_analyzer_dependencies() 281 282# Vendored third party rust crates. 283git_repository( 284 name = "rust_crates", 285 commit = "c39c1d1d4e4bdf2d8145beb8882af6f6e4e6dbbc", 286 remote = "https://pigweed.googlesource.com/third_party/rust_crates", 287 shallow_since = "1675359057 +0000", 288) 289 290# Registers platforms for use with toolchain resolution 291register_execution_platforms("//pw_build/platforms:all") 292 293load("//pw_build:target_config.bzl", "pigweed_config") 294 295# Configure Pigweeds backend. 296pigweed_config( 297 name = "pigweed_config", 298 build_file = "//targets:default_config.BUILD", 299) 300 301# Required by: rules_fuzzing. 302# 303# Provided here explicitly to override an old version of absl that 304# rules_fuzzing_dependencies attempts to pull in. That version has 305# many compiler warnings on newer clang versions. 306http_archive( 307 name = "com_google_absl", 308 sha256 = "3ea49a7d97421b88a8c48a0de16c16048e17725c7ec0f1d3ea2683a2a75adc21", 309 strip_prefix = "abseil-cpp-20230125.0", 310 urls = ["https://github.com/abseil/abseil-cpp/archive/refs/tags/20230125.0.tar.gz"], 311) 312 313# Set up rules for fuzz testing. 314# Required by: pigweed. 315# Used in modules: //pw_protobuf, //pw_tokenizer, //pw_fuzzer. 316http_archive( 317 name = "rules_fuzzing", 318 sha256 = "d9002dd3cd6437017f08593124fdd1b13b3473c7b929ceb0e60d317cb9346118", 319 strip_prefix = "rules_fuzzing-0.3.2", 320 urls = ["https://github.com/bazelbuild/rules_fuzzing/archive/v0.3.2.zip"], 321) 322 323load("@rules_fuzzing//fuzzing:repositories.bzl", "rules_fuzzing_dependencies") 324 325rules_fuzzing_dependencies() 326 327load("@rules_fuzzing//fuzzing:init.bzl", "rules_fuzzing_init") 328 329rules_fuzzing_init() 330 331RULES_JVM_EXTERNAL_TAG = "2.8" 332 333RULES_JVM_EXTERNAL_SHA = "79c9850690d7614ecdb72d68394f994fef7534b292c4867ce5e7dec0aa7bdfad" 334 335http_archive( 336 name = "rules_jvm_external", 337 sha256 = RULES_JVM_EXTERNAL_SHA, 338 strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG, 339 url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG, 340) 341 342load("@rules_jvm_external//:defs.bzl", "maven_install") 343 344# Pull in packages for the pw_rpc Java client with Maven. 345maven_install( 346 artifacts = [ 347 "com.google.auto.value:auto-value:1.8.2", 348 "com.google.auto.value:auto-value-annotations:1.8.2", 349 "com.google.code.findbugs:jsr305:3.0.2", 350 "com.google.flogger:flogger:0.7.1", 351 "com.google.flogger:flogger-system-backend:0.7.1", 352 "com.google.guava:guava:31.0.1-jre", 353 "com.google.truth:truth:1.1.3", 354 "org.mockito:mockito-core:4.1.0", 355 ], 356 repositories = [ 357 "https://maven.google.com/", 358 "https://jcenter.bintray.com/", 359 "https://repo1.maven.org/maven2", 360 ], 361) 362 363new_git_repository( 364 name = "micro_ecc", 365 build_file = "//:third_party/micro_ecc/BUILD.micro_ecc", 366 commit = "b335ee812bfcca4cd3fb0e2a436aab39553a555a", 367 remote = "https://github.com/kmackay/micro-ecc.git", 368 shallow_since = "1648504566 -0700", 369) 370 371git_repository( 372 name = "boringssl", 373 commit = "0fd67c76fc4bfb05a665c087ebfead77a3267f6d", 374 remote = "https://boringssl.googlesource.com/boringssl", 375 shallow_since = "1637714942 +0000", 376) 377 378http_archive( 379 name = "freertos", 380 build_file = "//:third_party/freertos/BUILD.bazel", 381 sha256 = "89af32b7568c504624f712c21fe97f7311c55fccb7ae6163cda7adde1cde7f62", 382 strip_prefix = "FreeRTOS-Kernel-10.5.1", 383 urls = ["https://github.com/FreeRTOS/FreeRTOS-Kernel/archive/refs/tags/V10.5.1.tar.gz"], 384) 385