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") |
| 22 | |
Nathaniel Brough | a1113be | 2021-03-07 09:05:41 +0800 | [diff] [blame] | 23 | # Set up Starlark library |
| 24 | # Required by: io_bazel_rules_go, com_google_protobuf. |
| 25 | # Used in modules: None. |
| 26 | # This must be instantiated before com_google_protobuf as protobuf_deps() pulls |
| 27 | # in an older version of bazel_skylib. However io_bazel_rules_go requires a |
| 28 | # newer version. |
| 29 | http_archive( |
| 30 | name = "bazel_skylib", |
| 31 | sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c", |
| 32 | urls = [ |
| 33 | "https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz", |
| 34 | "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz", |
| 35 | ], |
| 36 | ) |
| 37 | |
| 38 | load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") |
| 39 | |
| 40 | bazel_skylib_workspace() |
| 41 | |
| 42 | # Set up protobuf rules |
| 43 | # Required by: pigweed, com_github_bazelbuild_buildtools. |
| 44 | # Used in modules: //pw_protobuf. |
| 45 | http_archive( |
| 46 | name = "com_google_protobuf", |
| 47 | sha256 = "71030a04aedf9f612d2991c1c552317038c3c5a2b578ac4745267a45e7037c29", |
| 48 | strip_prefix = "protobuf-3.12.3", |
| 49 | url = "https://github.com/protocolbuffers/protobuf/archive/v3.12.3.tar.gz", |
| 50 | ) |
| 51 | |
| 52 | load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") |
| 53 | |
| 54 | protobuf_deps() |
| 55 | |
Nathaniel Brough | 9d9a20d | 2020-08-04 16:46:56 +0800 | [diff] [blame] | 56 | # Setup tools to build custom grpc rules. |
| 57 | # Regquired by: pigweed. |
| 58 | # Used in modules: //pw_protobuf |
| 59 | http_archive( |
| 60 | name = "rules_proto_grpc", |
| 61 | sha256 = "5f0f2fc0199810c65a2de148a52ba0aff14d631d4e8202f41aff6a9d590a471b", |
| 62 | strip_prefix = "rules_proto_grpc-1.0.2", |
| 63 | urls = ["https://github.com/rules-proto-grpc/rules_proto_grpc/archive/1.0.2.tar.gz"], |
| 64 | ) |
| 65 | |
| 66 | load("@rules_proto_grpc//:repositories.bzl", "rules_proto_grpc_repos", "rules_proto_grpc_toolchains") |
| 67 | |
| 68 | rules_proto_grpc_toolchains() |
| 69 | |
| 70 | rules_proto_grpc_repos() |
| 71 | |
Nathaniel Brough | a1113be | 2021-03-07 09:05:41 +0800 | [diff] [blame] | 72 | # Set up build_bazel_rules_nodejs. |
| 73 | # Required by: pigweed. |
| 74 | # Used in modules: //pw_web_ui. |
Nathaniel Brough | c2d5781 | 2021-04-18 22:52:00 +0800 | [diff] [blame] | 75 | git_repository( |
| 76 | name = "platforms", |
| 77 | commit = "d4c9d7f51a7c403814b60f66d20eeb425fbaaacb", |
| 78 | remote = "https://github.com/bazelbuild/platforms.git", |
| 79 | ) |
| 80 | |
Matthew Soulanille | 376d797 | 2020-06-01 15:50:07 -0700 | [diff] [blame] | 81 | http_archive( |
| 82 | name = "build_bazel_rules_nodejs", |
Matthew Soulanille | 83c8282 | 2020-09-10 10:59:50 -0700 | [diff] [blame] | 83 | sha256 = "4952ef879704ab4ad6729a29007e7094aef213ea79e9f2e94cbe1c9a753e63ef", |
| 84 | urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/2.2.0/rules_nodejs-2.2.0.tar.gz"], |
Matthew Soulanille | 376d797 | 2020-06-01 15:50:07 -0700 | [diff] [blame] | 85 | ) |
Nathaniel Brough | 82cf687 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 86 | |
| 87 | # Get the latest LTS version of Node. |
| 88 | load( |
| 89 | "@build_bazel_rules_nodejs//:index.bzl", |
| 90 | "node_repositories", |
| 91 | "yarn_install", |
| 92 | ) |
| 93 | |
Matthew Soulanille | 376d797 | 2020-06-01 15:50:07 -0700 | [diff] [blame] | 94 | node_repositories(package_json = ["//:package.json"]) |
| 95 | |
Matthew Soulanille | 376d797 | 2020-06-01 15:50:07 -0700 | [diff] [blame] | 96 | yarn_install( |
| 97 | name = "npm", |
| 98 | package_json = "//:package.json", |
| 99 | yarn_lock = "//:yarn.lock", |
| 100 | ) |
| 101 | |
Nathaniel Brough | 82cf687 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 102 | # Set up Karma. |
Matthew Soulanille | 83c8282 | 2020-09-10 10:59:50 -0700 | [diff] [blame] | 103 | load("@npm//@bazel/karma:package.bzl", "npm_bazel_karma_dependencies") |
Nathaniel Brough | 82cf687 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 104 | |
Matthew Soulanille | 5e78acf | 2020-06-08 10:58:29 -0700 | [diff] [blame] | 105 | npm_bazel_karma_dependencies() |
| 106 | |
Nathaniel Brough | 9d9a20d | 2020-08-04 16:46:56 +0800 | [diff] [blame] | 107 | http_archive( |
| 108 | name = "io_bazel_rules_webtesting", |
| 109 | sha256 = "9bb461d5ef08e850025480bab185fd269242d4e533bca75bfb748001ceb343c3", |
| 110 | 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] | 111 | ) |
| 112 | |
Nathaniel Brough | 9d9a20d | 2020-08-04 16:46:56 +0800 | [diff] [blame] | 113 | load("@io_bazel_rules_webtesting//web:repositories.bzl", "web_test_repositories") |
| 114 | |
Matthew Soulanille | 5e78acf | 2020-06-08 10:58:29 -0700 | [diff] [blame] | 115 | web_test_repositories() |
| 116 | |
Nathaniel Brough | 82cf687 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 117 | load( |
| 118 | "@io_bazel_rules_webtesting//web/versioned:browsers-0.3.2.bzl", |
| 119 | "browser_repositories", |
| 120 | ) |
Matthew Soulanille | 5e78acf | 2020-06-08 10:58:29 -0700 | [diff] [blame] | 121 | |
| 122 | browser_repositories( |
| 123 | chromium = True, |
| 124 | firefox = True, |
| 125 | ) |
| 126 | |
Nathaniel Brough | 82cf687 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 127 | # Setup embedded C/C++ toolchains. |
Nathaniel Brough | a1113be | 2021-03-07 09:05:41 +0800 | [diff] [blame] | 128 | # Required by: pigweed. |
| 129 | # Used in modules: //pw_polyfill, //pw_build (all pw_cc* targets). |
Nathaniel Brough | 82cf687 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 130 | git_repository( |
| 131 | name = "bazel_embedded", |
Nathaniel Brough | c2d5781 | 2021-04-18 22:52:00 +0800 | [diff] [blame] | 132 | commit = "d4717a6e33b88cb9fe1b6663d78656728c49b5c8", |
Nathaniel Brough | 82cf687 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 133 | remote = "https://github.com/silvergasp/bazel-embedded.git", |
Nathaniel Brough | 82cf687 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 134 | ) |
| 135 | |
| 136 | # Instantiate Pigweed configuration for embedded toolchain, |
| 137 | # this must be called before bazel_embedded_deps. |
| 138 | load( |
| 139 | "//pw_build:pigweed_toolchain_upstream.bzl", |
| 140 | "toolchain_upstream_deps", |
| 141 | ) |
| 142 | |
| 143 | toolchain_upstream_deps() |
| 144 | |
| 145 | # Configure bazel_embedded toolchains and platforms. |
| 146 | load( |
| 147 | "@bazel_embedded//:bazel_embedded_deps.bzl", |
| 148 | "bazel_embedded_deps", |
| 149 | ) |
| 150 | |
| 151 | bazel_embedded_deps() |
| 152 | |
| 153 | load( |
| 154 | "@bazel_embedded//platforms:execution_platforms.bzl", |
| 155 | "register_platforms", |
| 156 | ) |
| 157 | |
| 158 | register_platforms() |
| 159 | |
| 160 | # Fetch gcc-arm-none-eabi compiler and register for toolchain |
| 161 | # resolution. |
| 162 | load( |
| 163 | "@bazel_embedded//toolchains/compilers/gcc_arm_none_eabi:gcc_arm_none_repository.bzl", |
| 164 | "gcc_arm_none_compiler", |
| 165 | ) |
| 166 | |
| 167 | gcc_arm_none_compiler() |
| 168 | |
| 169 | load( |
| 170 | "@bazel_embedded//toolchains/gcc_arm_none_eabi:gcc_arm_none_toolchain.bzl", |
| 171 | "register_gcc_arm_none_toolchain", |
| 172 | ) |
| 173 | |
| 174 | register_gcc_arm_none_toolchain() |
| 175 | |
Nathaniel Brough | a1113be | 2021-03-07 09:05:41 +0800 | [diff] [blame] | 176 | # Fetch LLVM/Clang host compiler and register for toolchain resolution. |
Nathaniel Brough | 82cf687 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 177 | load( |
| 178 | "@bazel_embedded//toolchains/compilers/llvm:llvm_repository.bzl", |
| 179 | "llvm_repository", |
| 180 | ) |
| 181 | |
| 182 | llvm_repository( |
| 183 | name = "com_llvm_compiler", |
| 184 | ) |
| 185 | |
| 186 | load( |
| 187 | "@bazel_embedded//toolchains/clang:clang_toolchain.bzl", |
| 188 | "register_clang_toolchain", |
| 189 | ) |
| 190 | |
| 191 | register_clang_toolchain() |
Nathaniel Brough | ce91098 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 192 | |
Nathaniel Brough | a1113be | 2021-03-07 09:05:41 +0800 | [diff] [blame] | 193 | # Registers platforms for use with toolchain resolution |
Nathaniel Brough | ce91098 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 194 | register_execution_platforms("//pw_build/platforms:all") |
Nathaniel Brough | a1113be | 2021-03-07 09:05:41 +0800 | [diff] [blame] | 195 | |
| 196 | # Setup Golang toolchain rules |
| 197 | # Required by: bazel_gazelle, com_github_bazelbuild_buildtools. |
| 198 | # Used in modules: None. |
| 199 | http_archive( |
| 200 | name = "io_bazel_rules_go", |
| 201 | sha256 = "d1ffd055969c8f8d431e2d439813e42326961d0942bdf734d2c95dc30c369566", |
| 202 | urls = [ |
| 203 | "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.5/rules_go-v0.24.5.tar.gz", |
| 204 | "https://github.com/bazelbuild/rules_go/releases/download/v0.24.5/rules_go-v0.24.5.tar.gz", |
| 205 | ], |
| 206 | ) |
| 207 | |
| 208 | load( |
| 209 | "@io_bazel_rules_go//go:deps.bzl", |
| 210 | "go_register_toolchains", |
| 211 | "go_rules_dependencies", |
| 212 | ) |
| 213 | |
| 214 | go_rules_dependencies() |
| 215 | |
| 216 | go_register_toolchains() |
| 217 | |
| 218 | # Setup bazel package manager for golang |
| 219 | # Required by: com_github_bazelbuild_buildtools. |
| 220 | # Used in modules: None |
| 221 | http_archive( |
| 222 | name = "bazel_gazelle", |
| 223 | sha256 = "b85f48fa105c4403326e9525ad2b2cc437babaa6e15a3fc0b1dbab0ab064bc7c", |
| 224 | urls = [ |
| 225 | "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.2/bazel-gazelle-v0.22.2.tar.gz", |
| 226 | "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.2/bazel-gazelle-v0.22.2.tar.gz", |
| 227 | ], |
| 228 | ) |
| 229 | |
| 230 | load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") |
| 231 | |
| 232 | gazelle_dependencies() |
| 233 | |
| 234 | # Setup bazel buildtools (bazel linter and formatter) |
| 235 | # Required by: pigweed |
| 236 | # Used in modules: //:all (bazel specific tools). |
| 237 | http_archive( |
| 238 | name = "com_github_bazelbuild_buildtools", |
| 239 | sha256 = "c28eef4d30ba1a195c6837acf6c75a4034981f5b4002dda3c5aa6e48ce023cf1", |
| 240 | strip_prefix = "buildtools-4.0.1", |
| 241 | url = "https://github.com/bazelbuild/buildtools/archive/4.0.1.tar.gz", |
| 242 | ) |
Nathaniel Brough | fc95cca | 2021-04-18 22:20:26 +0800 | [diff] [blame] | 243 | |
| 244 | load("//pw_build:target_config.bzl", "pigweed_config") |
| 245 | |
| 246 | # Configure Pigweeds backend. |
| 247 | pigweed_config( |
| 248 | name = "pigweed_config", |
| 249 | build_file = "//targets:default_config.BUILD", |
| 250 | ) |