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 | |
| 56 | # Set up build_bazel_rules_nodejs. |
| 57 | # Required by: pigweed. |
| 58 | # Used in modules: //pw_web_ui. |
Matthew Soulanille | 376d797 | 2020-06-01 15:50:07 -0700 | [diff] [blame] | 59 | http_archive( |
| 60 | name = "build_bazel_rules_nodejs", |
Matthew Soulanille | 83c8282 | 2020-09-10 10:59:50 -0700 | [diff] [blame] | 61 | sha256 = "4952ef879704ab4ad6729a29007e7094aef213ea79e9f2e94cbe1c9a753e63ef", |
| 62 | 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] | 63 | ) |
Nathaniel Brough | 82cf687 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 64 | |
| 65 | # Get the latest LTS version of Node. |
| 66 | load( |
| 67 | "@build_bazel_rules_nodejs//:index.bzl", |
| 68 | "node_repositories", |
| 69 | "yarn_install", |
| 70 | ) |
| 71 | |
Matthew Soulanille | 376d797 | 2020-06-01 15:50:07 -0700 | [diff] [blame] | 72 | node_repositories(package_json = ["//:package.json"]) |
| 73 | |
Matthew Soulanille | 376d797 | 2020-06-01 15:50:07 -0700 | [diff] [blame] | 74 | yarn_install( |
| 75 | name = "npm", |
| 76 | package_json = "//:package.json", |
| 77 | yarn_lock = "//:yarn.lock", |
| 78 | ) |
| 79 | |
Nathaniel Brough | 82cf687 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 80 | # Set up Karma. |
Matthew Soulanille | 83c8282 | 2020-09-10 10:59:50 -0700 | [diff] [blame] | 81 | load("@npm//@bazel/karma:package.bzl", "npm_bazel_karma_dependencies") |
Nathaniel Brough | 82cf687 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 82 | |
Matthew Soulanille | 5e78acf | 2020-06-08 10:58:29 -0700 | [diff] [blame] | 83 | npm_bazel_karma_dependencies() |
| 84 | |
Nathaniel Brough | 82cf687 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 85 | load( |
| 86 | "@io_bazel_rules_webtesting//web:repositories.bzl", |
| 87 | "web_test_repositories", |
| 88 | ) |
| 89 | |
Matthew Soulanille | 5e78acf | 2020-06-08 10:58:29 -0700 | [diff] [blame] | 90 | web_test_repositories() |
| 91 | |
Nathaniel Brough | 82cf687 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 92 | load( |
| 93 | "@io_bazel_rules_webtesting//web/versioned:browsers-0.3.2.bzl", |
| 94 | "browser_repositories", |
| 95 | ) |
Matthew Soulanille | 5e78acf | 2020-06-08 10:58:29 -0700 | [diff] [blame] | 96 | |
| 97 | browser_repositories( |
| 98 | chromium = True, |
| 99 | firefox = True, |
| 100 | ) |
| 101 | |
Nathaniel Brough | 82cf687 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 102 | # Setup embedded C/C++ toolchains. |
Nathaniel Brough | a1113be | 2021-03-07 09:05:41 +0800 | [diff] [blame^] | 103 | # Required by: pigweed. |
| 104 | # Used in modules: //pw_polyfill, //pw_build (all pw_cc* targets). |
Nathaniel Brough | 82cf687 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 105 | git_repository( |
| 106 | name = "bazel_embedded", |
| 107 | commit = "89c05fa415218abd2e24fa7016cb7903317d606b", |
| 108 | remote = "https://github.com/silvergasp/bazel-embedded.git", |
Nathaniel Brough | 82cf687 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 109 | ) |
| 110 | |
| 111 | # Instantiate Pigweed configuration for embedded toolchain, |
| 112 | # this must be called before bazel_embedded_deps. |
| 113 | load( |
| 114 | "//pw_build:pigweed_toolchain_upstream.bzl", |
| 115 | "toolchain_upstream_deps", |
| 116 | ) |
| 117 | |
| 118 | toolchain_upstream_deps() |
| 119 | |
| 120 | # Configure bazel_embedded toolchains and platforms. |
| 121 | load( |
| 122 | "@bazel_embedded//:bazel_embedded_deps.bzl", |
| 123 | "bazel_embedded_deps", |
| 124 | ) |
| 125 | |
| 126 | bazel_embedded_deps() |
| 127 | |
| 128 | load( |
| 129 | "@bazel_embedded//platforms:execution_platforms.bzl", |
| 130 | "register_platforms", |
| 131 | ) |
| 132 | |
| 133 | register_platforms() |
| 134 | |
| 135 | # Fetch gcc-arm-none-eabi compiler and register for toolchain |
| 136 | # resolution. |
| 137 | load( |
| 138 | "@bazel_embedded//toolchains/compilers/gcc_arm_none_eabi:gcc_arm_none_repository.bzl", |
| 139 | "gcc_arm_none_compiler", |
| 140 | ) |
| 141 | |
| 142 | gcc_arm_none_compiler() |
| 143 | |
| 144 | load( |
| 145 | "@bazel_embedded//toolchains/gcc_arm_none_eabi:gcc_arm_none_toolchain.bzl", |
| 146 | "register_gcc_arm_none_toolchain", |
| 147 | ) |
| 148 | |
| 149 | register_gcc_arm_none_toolchain() |
| 150 | |
Nathaniel Brough | a1113be | 2021-03-07 09:05:41 +0800 | [diff] [blame^] | 151 | # Fetch LLVM/Clang host compiler and register for toolchain resolution. |
Nathaniel Brough | 82cf687 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 152 | load( |
| 153 | "@bazel_embedded//toolchains/compilers/llvm:llvm_repository.bzl", |
| 154 | "llvm_repository", |
| 155 | ) |
| 156 | |
| 157 | llvm_repository( |
| 158 | name = "com_llvm_compiler", |
| 159 | ) |
| 160 | |
| 161 | load( |
| 162 | "@bazel_embedded//toolchains/clang:clang_toolchain.bzl", |
| 163 | "register_clang_toolchain", |
| 164 | ) |
| 165 | |
| 166 | register_clang_toolchain() |
Nathaniel Brough | ce91098 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 167 | |
Nathaniel Brough | a1113be | 2021-03-07 09:05:41 +0800 | [diff] [blame^] | 168 | # Registers platforms for use with toolchain resolution |
Nathaniel Brough | ce91098 | 2021-02-16 15:51:57 +0800 | [diff] [blame] | 169 | register_execution_platforms("//pw_build/platforms:all") |
Nathaniel Brough | a1113be | 2021-03-07 09:05:41 +0800 | [diff] [blame^] | 170 | |
| 171 | # Setup Golang toolchain rules |
| 172 | # Required by: bazel_gazelle, com_github_bazelbuild_buildtools. |
| 173 | # Used in modules: None. |
| 174 | http_archive( |
| 175 | name = "io_bazel_rules_go", |
| 176 | sha256 = "d1ffd055969c8f8d431e2d439813e42326961d0942bdf734d2c95dc30c369566", |
| 177 | urls = [ |
| 178 | "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.5/rules_go-v0.24.5.tar.gz", |
| 179 | "https://github.com/bazelbuild/rules_go/releases/download/v0.24.5/rules_go-v0.24.5.tar.gz", |
| 180 | ], |
| 181 | ) |
| 182 | |
| 183 | load( |
| 184 | "@io_bazel_rules_go//go:deps.bzl", |
| 185 | "go_register_toolchains", |
| 186 | "go_rules_dependencies", |
| 187 | ) |
| 188 | |
| 189 | go_rules_dependencies() |
| 190 | |
| 191 | go_register_toolchains() |
| 192 | |
| 193 | # Setup bazel package manager for golang |
| 194 | # Required by: com_github_bazelbuild_buildtools. |
| 195 | # Used in modules: None |
| 196 | http_archive( |
| 197 | name = "bazel_gazelle", |
| 198 | sha256 = "b85f48fa105c4403326e9525ad2b2cc437babaa6e15a3fc0b1dbab0ab064bc7c", |
| 199 | urls = [ |
| 200 | "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.2/bazel-gazelle-v0.22.2.tar.gz", |
| 201 | "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.2/bazel-gazelle-v0.22.2.tar.gz", |
| 202 | ], |
| 203 | ) |
| 204 | |
| 205 | load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") |
| 206 | |
| 207 | gazelle_dependencies() |
| 208 | |
| 209 | # Setup bazel buildtools (bazel linter and formatter) |
| 210 | # Required by: pigweed |
| 211 | # Used in modules: //:all (bazel specific tools). |
| 212 | http_archive( |
| 213 | name = "com_github_bazelbuild_buildtools", |
| 214 | sha256 = "c28eef4d30ba1a195c6837acf6c75a4034981f5b4002dda3c5aa6e48ce023cf1", |
| 215 | strip_prefix = "buildtools-4.0.1", |
| 216 | url = "https://github.com/bazelbuild/buildtools/archive/4.0.1.tar.gz", |
| 217 | ) |