blob: 8f1736f80cf1950f8a554479d594c606c2f6ba18 [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")
Nathaniel Brough68ef2a52021-07-16 13:51:19 +080022load("//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.
27pigweed_deps()
28
29load("@cipd_deps//:cipd_init.bzl", "cipd_init")
30
31cipd_init()
Nathaniel Brough82cf6872021-02-16 15:51:57 +080032
Nathaniel Broughf91e7632021-07-26 17:12:14 +080033# Set up Python support.
Nathaniel Broughb6b90d02021-05-11 11:32:17 +080034# Required by: rules_fuzzing.
35# Used in modules: None.
36http_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 Broughf91e7632021-07-26 17:12:14 +080045# Set up Starlark library.
Nathaniel Brougha1113be2021-03-07 09:05:41 +080046# 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.
51http_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
60load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
61
62bazel_skylib_workspace()
63
Nathaniel Broughf91e7632021-07-26 17:12:14 +080064# Set up upstream googletest and googlemock.
65# Required by: Pigweed.
66# Used in modules: //pw_analog, //pw_i2c.
67http_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 Broughb44d95e2021-07-15 10:39:47 +080078# Required by: All cc targets.
79# Used in modules: All cc targets.
80git_repository(
81 name = "rules_cc_toolchain",
82 commit = "dd9265e3ce0daa444911040430bd716076869b34",
83 remote = "https://github.com/silvergasp/rules_cc_toolchain.git",
84)
85
86load("@rules_cc_toolchain//:rules_cc_toolchain_deps.bzl", "rules_cc_toolchain_deps")
87
88rules_cc_toolchain_deps()
89
90load("@rules_cc_toolchain//cc_toolchain:cc_toolchain.bzl", "register_cc_toolchains")
91
92register_cc_toolchains()
93
Nathaniel Broughf91e7632021-07-26 17:12:14 +080094# Set up Protobuf rules.
Nathaniel Brougha1113be2021-03-07 09:05:41 +080095# Required by: pigweed, com_github_bazelbuild_buildtools.
96# Used in modules: //pw_protobuf.
97http_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
104load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
105
106protobuf_deps()
107
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800108# Set up tools to build custom GRPC rules.
Nathaniel Broughb4f4e7a2021-05-06 14:49:55 +0800109# Required by: pigweed.
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800110# Used in modules: //pw_protobuf.
Nathaniel Brough9d9a20d2020-08-04 16:46:56 +0800111http_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 Broughb4f4e7a2021-05-06 14:49:55 +0800118load(
119 "@rules_proto_grpc//:repositories.bzl",
120 "rules_proto_grpc_repos",
121 "rules_proto_grpc_toolchains",
122)
Nathaniel Brough9d9a20d2020-08-04 16:46:56 +0800123
124rules_proto_grpc_toolchains()
125
126rules_proto_grpc_repos()
127
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800128# Set up Bazel platforms.
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800129# Required by: pigweed.
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800130# Used in modules: //pw_build, (Assorted modules via select statements).
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800131git_repository(
132 name = "platforms",
133 commit = "d4c9d7f51a7c403814b60f66d20eeb425fbaaacb",
134 remote = "https://github.com/bazelbuild/platforms.git",
135)
136
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800137# Set up NodeJs rules.
138# Required by: pigweed.
139# Used in modules: //pw_web_ui.
Matthew Soulanille376d7972020-06-01 15:50:07 -0700140http_archive(
Nathaniel Broughb44d95e2021-07-15 10:39:47 +0800141 name = "build_bazel_rules_nodejs",
Jared Weinsteincf2ca742021-07-02 17:20:05 -0700142 sha256 = "8f5f192ba02319254aaf2cdcca00ec12eaafeb979a80a1e946773c520ae0a2c9",
143 urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/3.7.0/rules_nodejs-3.7.0.tar.gz"],
Matthew Soulanille376d7972020-06-01 15:50:07 -0700144)
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800145
146# Get the latest LTS version of Node.
147load(
148 "@build_bazel_rules_nodejs//:index.bzl",
149 "node_repositories",
150 "yarn_install",
151)
152
Matthew Soulanille376d7972020-06-01 15:50:07 -0700153node_repositories(package_json = ["//:package.json"])
154
Matthew Soulanille376d7972020-06-01 15:50:07 -0700155yarn_install(
156 name = "npm",
157 package_json = "//:package.json",
158 yarn_lock = "//:yarn.lock",
159)
160
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800161# Set up web-testing rules.
162# Required by: pigweed.
163# Used in modules: //pw_web_ui.
Nathaniel Brough9d9a20d2020-08-04 16:46:56 +0800164http_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 Brough82cf6872021-02-16 15:51:57 +0800168)
169
Nathaniel Brough9d9a20d2020-08-04 16:46:56 +0800170load("@io_bazel_rules_webtesting//web:repositories.bzl", "web_test_repositories")
171
Matthew Soulanille5e78acf2020-06-08 10:58:29 -0700172web_test_repositories()
173
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800174load(
175 "@io_bazel_rules_webtesting//web/versioned:browsers-0.3.2.bzl",
176 "browser_repositories",
177)
Matthew Soulanille5e78acf2020-06-08 10:58:29 -0700178
179browser_repositories(
180 chromium = True,
181 firefox = True,
182)
183
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800184# Set up embedded C/C++ toolchains.
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800185# Required by: pigweed.
186# Used in modules: //pw_polyfill, //pw_build (all pw_cc* targets).
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800187git_repository(
188 name = "bazel_embedded",
Nathaniel Broughb6b90d02021-05-11 11:32:17 +0800189 commit = "7dd51fc1ac7d7a9ecfe8ea8d1532c56a6ca836bc",
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800190 remote = "https://github.com/silvergasp/bazel-embedded.git",
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800191)
192
193# Instantiate Pigweed configuration for embedded toolchain,
194# this must be called before bazel_embedded_deps.
195load(
196 "//pw_build:pigweed_toolchain_upstream.bzl",
197 "toolchain_upstream_deps",
198)
199
200toolchain_upstream_deps()
201
202# Configure bazel_embedded toolchains and platforms.
203load(
204 "@bazel_embedded//:bazel_embedded_deps.bzl",
205 "bazel_embedded_deps",
206)
207
208bazel_embedded_deps()
209
210load(
211 "@bazel_embedded//platforms:execution_platforms.bzl",
212 "register_platforms",
213)
214
215register_platforms()
216
217# Fetch gcc-arm-none-eabi compiler and register for toolchain
218# resolution.
219load(
220 "@bazel_embedded//toolchains/compilers/gcc_arm_none_eabi:gcc_arm_none_repository.bzl",
221 "gcc_arm_none_compiler",
222)
223
224gcc_arm_none_compiler()
225
226load(
227 "@bazel_embedded//toolchains/gcc_arm_none_eabi:gcc_arm_none_toolchain.bzl",
228 "register_gcc_arm_none_toolchain",
229)
230
231register_gcc_arm_none_toolchain()
232
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800233# Registers platforms for use with toolchain resolution
Nathaniel Broughce910982021-02-16 15:51:57 +0800234register_execution_platforms("//pw_build/platforms:all")
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800235
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800236# Set up Golang toolchain rules.
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800237# Required by: bazel_gazelle, com_github_bazelbuild_buildtools.
238# Used in modules: None.
239http_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
248load(
249 "@io_bazel_rules_go//go:deps.bzl",
250 "go_register_toolchains",
251 "go_rules_dependencies",
252)
253
254go_rules_dependencies()
255
256go_register_toolchains()
257
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800258# Set up bazel package manager for golang.
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800259# Required by: com_github_bazelbuild_buildtools.
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800260# Used in modules: None.
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800261http_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
270load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
271
272gazelle_dependencies()
273
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800274# Set up bazel buildtools (bazel linter and formatter).
275# Required by: pigweed.
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800276# Used in modules: //:all (bazel specific tools).
277http_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 Broughfc95cca2021-04-18 22:20:26 +0800283
284load("//pw_build:target_config.bzl", "pigweed_config")
285
286# Configure Pigweeds backend.
287pigweed_config(
288 name = "pigweed_config",
289 build_file = "//targets:default_config.BUILD",
290)
Nathaniel Broughb6b90d02021-05-11 11:32:17 +0800291
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800292# Set up rules for fuzz testing.
Nathaniel Broughb6b90d02021-05-11 11:32:17 +0800293# Required by: pigweed.
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800294# Used in modules: //pw_protobuf, //pw_tokenizer, //pw_fuzzer.
Nathaniel Broughb6b90d02021-05-11 11:32:17 +0800295http_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
302load("@rules_fuzzing//fuzzing:repositories.bzl", "rules_fuzzing_dependencies")
303
304rules_fuzzing_dependencies()
305
306load("@rules_fuzzing//fuzzing:init.bzl", "rules_fuzzing_init")
307
308rules_fuzzing_init()