blob: e95aa1b97015ba8bfef8b9d8c64d2b8147d979dd [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.
Ted Pudlike4b69452022-02-04 23:52:03 +000034# Required by: rules_fuzzing, com_github_nanopb_nanopb.
Nathaniel Broughb6b90d02021-05-11 11:32:17 +080035# Used in modules: None.
36http_archive(
37 name = "rules_python",
Ted Pudlike4b69452022-02-04 23:52:03 +000038 sha256 = "a30abdfc7126d497a7698c29c46ea9901c6392d6ed315171a6df5ce433aa4502",
39 strip_prefix = "rules_python-0.6.0",
40 url = "https://github.com/bazelbuild/rules_python/archive/0.6.0.tar.gz",
Nathaniel Broughb6b90d02021-05-11 11:32:17 +080041)
42
Nathaniel Broughf91e7632021-07-26 17:12:14 +080043# Set up Starlark library.
Nathaniel Brougha1113be2021-03-07 09:05:41 +080044# Required by: io_bazel_rules_go, com_google_protobuf.
45# Used in modules: None.
46# This must be instantiated before com_google_protobuf as protobuf_deps() pulls
47# in an older version of bazel_skylib. However io_bazel_rules_go requires a
48# newer version.
49http_archive(
50 name = "bazel_skylib",
51 sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c",
52 urls = [
53 "https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz",
54 "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz",
55 ],
56)
57
58load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
59
60bazel_skylib_workspace()
61
Nathaniel Broughf91e7632021-07-26 17:12:14 +080062# Set up upstream googletest and googlemock.
63# Required by: Pigweed.
64# Used in modules: //pw_analog, //pw_i2c.
65http_archive(
66 name = "com_google_googletest",
67 sha256 = "9dc9157a9a1551ec7a7e43daea9a694a0bb5fb8bec81235d8a1e6ef64c716dcb",
68 strip_prefix = "googletest-release-1.10.0",
69 urls = [
70 "https://mirror.bazel.build/github.com/google/googletest/archive/release-1.10.0.tar.gz",
71 "https://github.com/google/googletest/archive/release-1.10.0.tar.gz",
72 ],
73)
74
75# Set up host hermetic host toolchain.
Nathaniel Broughb44d95e2021-07-15 10:39:47 +080076# Required by: All cc targets.
77# Used in modules: All cc targets.
78git_repository(
79 name = "rules_cc_toolchain",
Nathaniel Broughf9cc0412021-08-17 09:32:32 +080080 commit = "80b51ba81f14eebe06684efa25261f6dc46e9b29",
Nathaniel Brougha7dd32e2021-12-13 15:30:02 +080081 remote = "https://github.com/bazelembedded/rules_cc_toolchain.git",
Nathaniel Broughb44d95e2021-07-15 10:39:47 +080082)
83
84load("@rules_cc_toolchain//:rules_cc_toolchain_deps.bzl", "rules_cc_toolchain_deps")
85
86rules_cc_toolchain_deps()
87
88load("@rules_cc_toolchain//cc_toolchain:cc_toolchain.bzl", "register_cc_toolchains")
89
90register_cc_toolchains()
91
Nathaniel Broughf91e7632021-07-26 17:12:14 +080092# Set up Protobuf rules.
Nathaniel Brougha1113be2021-03-07 09:05:41 +080093# Required by: pigweed, com_github_bazelbuild_buildtools.
94# Used in modules: //pw_protobuf.
95http_archive(
96 name = "com_google_protobuf",
Anthony DiGirolamod63bd742021-08-19 16:13:30 -070097 sha256 = "c6003e1d2e7fefa78a3039f19f383b4f3a61e81be8c19356f85b6461998ad3db",
98 strip_prefix = "protobuf-3.17.3",
99 url = "https://github.com/protocolbuffers/protobuf/archive/v3.17.3.tar.gz",
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800100)
101
102load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
103
104protobuf_deps()
105
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800106# Set up tools to build custom GRPC rules.
Nathaniel Broughb4f4e7a2021-05-06 14:49:55 +0800107# Required by: pigweed.
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800108# Used in modules: //pw_protobuf.
Nathaniel Brough9d9a20d2020-08-04 16:46:56 +0800109http_archive(
110 name = "rules_proto_grpc",
Jared Weinstein27ab4e12021-08-16 14:52:33 -0700111 sha256 = "7954abbb6898830cd10ac9714fbcacf092299fda00ed2baf781172f545120419",
112 strip_prefix = "rules_proto_grpc-3.1.1",
113 urls = ["https://github.com/rules-proto-grpc/rules_proto_grpc/archive/3.1.1.tar.gz"],
Nathaniel Brough9d9a20d2020-08-04 16:46:56 +0800114)
115
Nathaniel Broughb4f4e7a2021-05-06 14:49:55 +0800116load(
117 "@rules_proto_grpc//:repositories.bzl",
118 "rules_proto_grpc_repos",
119 "rules_proto_grpc_toolchains",
120)
Nathaniel Brough9d9a20d2020-08-04 16:46:56 +0800121
122rules_proto_grpc_toolchains()
123
124rules_proto_grpc_repos()
125
Ted Pudlike4b69452022-02-04 23:52:03 +0000126# Set up Protobuf rules.
127# Required by: pigweed, com_github_bazelbuild_buildtools.
128# Used in modules: //pw_protobuf.
129http_archive(
130 name = "com_google_protobuf",
131 sha256 = "c6003e1d2e7fefa78a3039f19f383b4f3a61e81be8c19356f85b6461998ad3db",
132 strip_prefix = "protobuf-3.17.3",
133 url = "https://github.com/protocolbuffers/protobuf/archive/v3.17.3.tar.gz",
134)
135
136load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
137
138protobuf_deps()
139
140# Setup Nanopb protoc plugin.
141# Required by: Pigweed.
142# Used in modules: pw_protobuf.
143git_repository(
144 name = "com_github_nanopb_nanopb",
145 commit = "e601fca6d9ed7fb5c09e2732452753b2989f128b",
146 remote = "https://github.com/nanopb/nanopb.git",
147)
148
149load("@com_github_nanopb_nanopb//:nanopb_deps.bzl", "nanopb_deps")
150
151nanopb_deps()
152
153load("@com_github_nanopb_nanopb//:python_deps.bzl", "nanopb_python_deps")
154
155nanopb_python_deps()
156
157load("@com_github_nanopb_nanopb//:nanopb_workspace.bzl", "nanopb_workspace")
158
159nanopb_workspace()
160
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800161# Set up Bazel platforms.
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800162# Required by: pigweed.
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800163# Used in modules: //pw_build, (Assorted modules via select statements).
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800164git_repository(
165 name = "platforms",
166 commit = "d4c9d7f51a7c403814b60f66d20eeb425fbaaacb",
167 remote = "https://github.com/bazelbuild/platforms.git",
168)
169
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800170# Set up NodeJs rules.
171# Required by: pigweed.
172# Used in modules: //pw_web_ui.
Matthew Soulanille376d7972020-06-01 15:50:07 -0700173http_archive(
Nathaniel Broughb44d95e2021-07-15 10:39:47 +0800174 name = "build_bazel_rules_nodejs",
Paul Mathieu6ce48022021-09-14 10:36:10 -0700175 sha256 = "b32a4713b45095e9e1921a7fcb1adf584bc05959f3336e7351bcf77f015a2d7c",
176 urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/4.1.0/rules_nodejs-4.1.0.tar.gz"],
Matthew Soulanille376d7972020-06-01 15:50:07 -0700177)
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800178
179# Get the latest LTS version of Node.
180load(
181 "@build_bazel_rules_nodejs//:index.bzl",
182 "node_repositories",
183 "yarn_install",
184)
185
Matthew Soulanille376d7972020-06-01 15:50:07 -0700186node_repositories(package_json = ["//:package.json"])
187
Matthew Soulanille376d7972020-06-01 15:50:07 -0700188yarn_install(
189 name = "npm",
190 package_json = "//:package.json",
191 yarn_lock = "//:yarn.lock",
192)
193
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800194# Set up web-testing rules.
195# Required by: pigweed.
196# Used in modules: //pw_web_ui.
Nathaniel Brough9d9a20d2020-08-04 16:46:56 +0800197http_archive(
198 name = "io_bazel_rules_webtesting",
199 sha256 = "9bb461d5ef08e850025480bab185fd269242d4e533bca75bfb748001ceb343c3",
200 urls = ["https://github.com/bazelbuild/rules_webtesting/releases/download/0.3.3/rules_webtesting.tar.gz"],
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800201)
202
Nathaniel Brough9d9a20d2020-08-04 16:46:56 +0800203load("@io_bazel_rules_webtesting//web:repositories.bzl", "web_test_repositories")
204
Matthew Soulanille5e78acf2020-06-08 10:58:29 -0700205web_test_repositories()
206
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800207load(
208 "@io_bazel_rules_webtesting//web/versioned:browsers-0.3.2.bzl",
209 "browser_repositories",
210)
Matthew Soulanille5e78acf2020-06-08 10:58:29 -0700211
212browser_repositories(
213 chromium = True,
214 firefox = True,
215)
216
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800217# Set up embedded C/C++ toolchains.
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800218# Required by: pigweed.
219# Used in modules: //pw_polyfill, //pw_build (all pw_cc* targets).
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800220git_repository(
221 name = "bazel_embedded",
Nathaniel Broughb3718312021-09-16 08:26:34 +0800222 commit = "17c93d5fa52c4c78860b8bbd327325fba6c85555",
Nathaniel Brougha7dd32e2021-12-13 15:30:02 +0800223 remote = "https://github.com/bazelembedded/bazel-embedded.git",
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800224)
225
226# Instantiate Pigweed configuration for embedded toolchain,
227# this must be called before bazel_embedded_deps.
228load(
229 "//pw_build:pigweed_toolchain_upstream.bzl",
230 "toolchain_upstream_deps",
231)
232
233toolchain_upstream_deps()
234
235# Configure bazel_embedded toolchains and platforms.
236load(
237 "@bazel_embedded//:bazel_embedded_deps.bzl",
238 "bazel_embedded_deps",
239)
240
241bazel_embedded_deps()
242
243load(
244 "@bazel_embedded//platforms:execution_platforms.bzl",
245 "register_platforms",
246)
247
248register_platforms()
249
250# Fetch gcc-arm-none-eabi compiler and register for toolchain
251# resolution.
252load(
253 "@bazel_embedded//toolchains/compilers/gcc_arm_none_eabi:gcc_arm_none_repository.bzl",
254 "gcc_arm_none_compiler",
255)
256
257gcc_arm_none_compiler()
258
259load(
260 "@bazel_embedded//toolchains/gcc_arm_none_eabi:gcc_arm_none_toolchain.bzl",
261 "register_gcc_arm_none_toolchain",
262)
263
264register_gcc_arm_none_toolchain()
265
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800266# Registers platforms for use with toolchain resolution
Nathaniel Broughce910982021-02-16 15:51:57 +0800267register_execution_platforms("//pw_build/platforms:all")
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800268
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800269# Set up Golang toolchain rules.
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800270# Required by: bazel_gazelle, com_github_bazelbuild_buildtools.
271# Used in modules: None.
272http_archive(
273 name = "io_bazel_rules_go",
274 sha256 = "d1ffd055969c8f8d431e2d439813e42326961d0942bdf734d2c95dc30c369566",
275 urls = [
276 "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.5/rules_go-v0.24.5.tar.gz",
277 "https://github.com/bazelbuild/rules_go/releases/download/v0.24.5/rules_go-v0.24.5.tar.gz",
278 ],
279)
280
281load(
282 "@io_bazel_rules_go//go:deps.bzl",
283 "go_register_toolchains",
284 "go_rules_dependencies",
285)
286
287go_rules_dependencies()
288
289go_register_toolchains()
290
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800291# Set up bazel package manager for golang.
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800292# Required by: com_github_bazelbuild_buildtools.
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800293# Used in modules: None.
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800294http_archive(
295 name = "bazel_gazelle",
296 sha256 = "b85f48fa105c4403326e9525ad2b2cc437babaa6e15a3fc0b1dbab0ab064bc7c",
297 urls = [
298 "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.2/bazel-gazelle-v0.22.2.tar.gz",
299 "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.2/bazel-gazelle-v0.22.2.tar.gz",
300 ],
301)
302
303load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
304
305gazelle_dependencies()
306
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800307# Set up bazel buildtools (bazel linter and formatter).
308# Required by: pigweed.
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800309# Used in modules: //:all (bazel specific tools).
310http_archive(
311 name = "com_github_bazelbuild_buildtools",
312 sha256 = "c28eef4d30ba1a195c6837acf6c75a4034981f5b4002dda3c5aa6e48ce023cf1",
313 strip_prefix = "buildtools-4.0.1",
314 url = "https://github.com/bazelbuild/buildtools/archive/4.0.1.tar.gz",
315)
Nathaniel Broughfc95cca2021-04-18 22:20:26 +0800316
317load("//pw_build:target_config.bzl", "pigweed_config")
318
319# Configure Pigweeds backend.
320pigweed_config(
321 name = "pigweed_config",
322 build_file = "//targets:default_config.BUILD",
323)
Nathaniel Broughb6b90d02021-05-11 11:32:17 +0800324
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800325# Set up rules for fuzz testing.
Nathaniel Broughb6b90d02021-05-11 11:32:17 +0800326# Required by: pigweed.
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800327# Used in modules: //pw_protobuf, //pw_tokenizer, //pw_fuzzer.
Nathaniel Broughb6b90d02021-05-11 11:32:17 +0800328http_archive(
329 name = "rules_fuzzing",
330 sha256 = "94f25c7a18db0502ace26a3ef7d0a25fd7c195c4e9770ddd1b1ec718e8936091",
331 strip_prefix = "rules_fuzzing-0.1.3",
332 urls = ["https://github.com/bazelbuild/rules_fuzzing/archive/v0.1.3.zip"],
333)
334
335load("@rules_fuzzing//fuzzing:repositories.bzl", "rules_fuzzing_dependencies")
336
337rules_fuzzing_dependencies()
338
339load("@rules_fuzzing//fuzzing:init.bzl", "rules_fuzzing_init")
340
341rules_fuzzing_init()
Paul Mathieu29f5e732021-10-05 18:04:09 -0700342
343# esbuild setup
344load("@build_bazel_rules_nodejs//toolchains/esbuild:esbuild_repositories.bzl", "esbuild_repositories")
345
346esbuild_repositories(npm_repository = "npm") # Note, npm is the default value for npm_repository
Wyatt Hepler3b4f89a2021-12-06 16:18:53 -0800347
348RULES_JVM_EXTERNAL_TAG = "2.8"
349
350RULES_JVM_EXTERNAL_SHA = "79c9850690d7614ecdb72d68394f994fef7534b292c4867ce5e7dec0aa7bdfad"
351
352http_archive(
353 name = "rules_jvm_external",
354 sha256 = RULES_JVM_EXTERNAL_SHA,
355 strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
356 url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG,
357)
358
359load("@rules_jvm_external//:defs.bzl", "maven_install")
360
361# Pull in packages for the pw_rpc Java client with Maven.
362maven_install(
363 artifacts = [
364 "com.google.auto.value:auto-value:1.8.2",
365 "com.google.auto.value:auto-value-annotations:1.8.2",
366 "com.google.code.findbugs:jsr305:3.0.2",
367 "com.google.flogger:flogger:0.7.1",
368 "com.google.flogger:flogger-system-backend:0.7.1",
369 "com.google.guava:guava:31.0.1-jre",
370 "com.google.truth:truth:1.1.3",
371 "org.mockito:mockito-core:4.1.0",
372 ],
373 repositories = [
374 "https://maven.google.com/",
375 "https://jcenter.bintray.com/",
376 "https://repo1.maven.org/maven2",
377 ],
378)