blob: b37b8e30a6aa9c3a3963c1547c92034d726131ab [file] [log] [blame]
Nathaniel Brough82cf6872021-02-16 15:51:57 +08001# Copyright 2021 The Pigweed Authors
Rob Mohrbe98ead2019-11-14 07:16:40 -08002#
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 Soulanille376d7972020-06-01 15:50:07 -070014
15workspace(
16 name = "pigweed",
17 managed_directories = {"@npm": ["node_modules"]},
18)
19
Matthew Soulanille376d7972020-06-01 15:50:07 -070020load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
Nathaniel Brough82cf6872021-02-16 15:51:57 +080021load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
22
Nathaniel Brougha1113be2021-03-07 09:05:41 +080023# 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.
29http_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
38load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
39
40bazel_skylib_workspace()
41
42# Set up protobuf rules
43# Required by: pigweed, com_github_bazelbuild_buildtools.
44# Used in modules: //pw_protobuf.
45http_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
52load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
53
54protobuf_deps()
55
Nathaniel Brough9d9a20d2020-08-04 16:46:56 +080056# Setup tools to build custom grpc rules.
Nathaniel Broughb4f4e7a2021-05-06 14:49:55 +080057# Required by: pigweed.
Nathaniel Brough9d9a20d2020-08-04 16:46:56 +080058# Used in modules: //pw_protobuf
59http_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
Nathaniel Broughb4f4e7a2021-05-06 14:49:55 +080066load(
67 "@rules_proto_grpc//:repositories.bzl",
68 "rules_proto_grpc_repos",
69 "rules_proto_grpc_toolchains",
70)
Nathaniel Brough9d9a20d2020-08-04 16:46:56 +080071
72rules_proto_grpc_toolchains()
73
74rules_proto_grpc_repos()
75
Nathaniel Brougha1113be2021-03-07 09:05:41 +080076# Set up build_bazel_rules_nodejs.
77# Required by: pigweed.
78# Used in modules: //pw_web_ui.
Nathaniel Broughc2d57812021-04-18 22:52:00 +080079git_repository(
80 name = "platforms",
81 commit = "d4c9d7f51a7c403814b60f66d20eeb425fbaaacb",
82 remote = "https://github.com/bazelbuild/platforms.git",
83)
84
Matthew Soulanille376d7972020-06-01 15:50:07 -070085http_archive(
86 name = "build_bazel_rules_nodejs",
Matthew Soulanille83c82822020-09-10 10:59:50 -070087 sha256 = "4952ef879704ab4ad6729a29007e7094aef213ea79e9f2e94cbe1c9a753e63ef",
88 urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/2.2.0/rules_nodejs-2.2.0.tar.gz"],
Matthew Soulanille376d7972020-06-01 15:50:07 -070089)
Nathaniel Brough82cf6872021-02-16 15:51:57 +080090
91# Get the latest LTS version of Node.
92load(
93 "@build_bazel_rules_nodejs//:index.bzl",
94 "node_repositories",
95 "yarn_install",
96)
97
Matthew Soulanille376d7972020-06-01 15:50:07 -070098node_repositories(package_json = ["//:package.json"])
99
Matthew Soulanille376d7972020-06-01 15:50:07 -0700100yarn_install(
101 name = "npm",
102 package_json = "//:package.json",
103 yarn_lock = "//:yarn.lock",
104)
105
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800106# Set up Karma.
Matthew Soulanille83c82822020-09-10 10:59:50 -0700107load("@npm//@bazel/karma:package.bzl", "npm_bazel_karma_dependencies")
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800108
Matthew Soulanille5e78acf2020-06-08 10:58:29 -0700109npm_bazel_karma_dependencies()
110
Nathaniel Brough9d9a20d2020-08-04 16:46:56 +0800111http_archive(
112 name = "io_bazel_rules_webtesting",
113 sha256 = "9bb461d5ef08e850025480bab185fd269242d4e533bca75bfb748001ceb343c3",
114 urls = ["https://github.com/bazelbuild/rules_webtesting/releases/download/0.3.3/rules_webtesting.tar.gz"],
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800115)
116
Nathaniel Brough9d9a20d2020-08-04 16:46:56 +0800117load("@io_bazel_rules_webtesting//web:repositories.bzl", "web_test_repositories")
118
Matthew Soulanille5e78acf2020-06-08 10:58:29 -0700119web_test_repositories()
120
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800121load(
122 "@io_bazel_rules_webtesting//web/versioned:browsers-0.3.2.bzl",
123 "browser_repositories",
124)
Matthew Soulanille5e78acf2020-06-08 10:58:29 -0700125
126browser_repositories(
127 chromium = True,
128 firefox = True,
129)
130
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800131# Setup embedded C/C++ toolchains.
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800132# Required by: pigweed.
133# Used in modules: //pw_polyfill, //pw_build (all pw_cc* targets).
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800134git_repository(
135 name = "bazel_embedded",
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800136 commit = "d4717a6e33b88cb9fe1b6663d78656728c49b5c8",
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800137 remote = "https://github.com/silvergasp/bazel-embedded.git",
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800138)
139
140# Instantiate Pigweed configuration for embedded toolchain,
141# this must be called before bazel_embedded_deps.
142load(
143 "//pw_build:pigweed_toolchain_upstream.bzl",
144 "toolchain_upstream_deps",
145)
146
147toolchain_upstream_deps()
148
149# Configure bazel_embedded toolchains and platforms.
150load(
151 "@bazel_embedded//:bazel_embedded_deps.bzl",
152 "bazel_embedded_deps",
153)
154
155bazel_embedded_deps()
156
157load(
158 "@bazel_embedded//platforms:execution_platforms.bzl",
159 "register_platforms",
160)
161
162register_platforms()
163
164# Fetch gcc-arm-none-eabi compiler and register for toolchain
165# resolution.
166load(
167 "@bazel_embedded//toolchains/compilers/gcc_arm_none_eabi:gcc_arm_none_repository.bzl",
168 "gcc_arm_none_compiler",
169)
170
171gcc_arm_none_compiler()
172
173load(
174 "@bazel_embedded//toolchains/gcc_arm_none_eabi:gcc_arm_none_toolchain.bzl",
175 "register_gcc_arm_none_toolchain",
176)
177
178register_gcc_arm_none_toolchain()
179
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800180# Fetch LLVM/Clang host compiler and register for toolchain resolution.
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800181load(
182 "@bazel_embedded//toolchains/compilers/llvm:llvm_repository.bzl",
183 "llvm_repository",
184)
185
186llvm_repository(
187 name = "com_llvm_compiler",
188)
189
190load(
191 "@bazel_embedded//toolchains/clang:clang_toolchain.bzl",
192 "register_clang_toolchain",
193)
194
195register_clang_toolchain()
Nathaniel Broughce910982021-02-16 15:51:57 +0800196
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800197# Registers platforms for use with toolchain resolution
Nathaniel Broughce910982021-02-16 15:51:57 +0800198register_execution_platforms("//pw_build/platforms:all")
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800199
200# Setup Golang toolchain rules
201# Required by: bazel_gazelle, com_github_bazelbuild_buildtools.
202# Used in modules: None.
203http_archive(
204 name = "io_bazel_rules_go",
205 sha256 = "d1ffd055969c8f8d431e2d439813e42326961d0942bdf734d2c95dc30c369566",
206 urls = [
207 "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.5/rules_go-v0.24.5.tar.gz",
208 "https://github.com/bazelbuild/rules_go/releases/download/v0.24.5/rules_go-v0.24.5.tar.gz",
209 ],
210)
211
212load(
213 "@io_bazel_rules_go//go:deps.bzl",
214 "go_register_toolchains",
215 "go_rules_dependencies",
216)
217
218go_rules_dependencies()
219
220go_register_toolchains()
221
222# Setup bazel package manager for golang
223# Required by: com_github_bazelbuild_buildtools.
224# Used in modules: None
225http_archive(
226 name = "bazel_gazelle",
227 sha256 = "b85f48fa105c4403326e9525ad2b2cc437babaa6e15a3fc0b1dbab0ab064bc7c",
228 urls = [
229 "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.2/bazel-gazelle-v0.22.2.tar.gz",
230 "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.2/bazel-gazelle-v0.22.2.tar.gz",
231 ],
232)
233
234load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
235
236gazelle_dependencies()
237
238# Setup bazel buildtools (bazel linter and formatter)
239# Required by: pigweed
240# Used in modules: //:all (bazel specific tools).
241http_archive(
242 name = "com_github_bazelbuild_buildtools",
243 sha256 = "c28eef4d30ba1a195c6837acf6c75a4034981f5b4002dda3c5aa6e48ce023cf1",
244 strip_prefix = "buildtools-4.0.1",
245 url = "https://github.com/bazelbuild/buildtools/archive/4.0.1.tar.gz",
246)
Nathaniel Broughfc95cca2021-04-18 22:20:26 +0800247
248load("//pw_build:target_config.bzl", "pigweed_config")
249
250# Configure Pigweeds backend.
251pigweed_config(
252 name = "pigweed_config",
253 build_file = "//targets:default_config.BUILD",
254)