blob: 73dd700d2b85731bddee08a605014e1094cdb3e9 [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",
Anthony DiGirolamod63bd742021-08-19 16:13:30 -070038 sha256 = "934c9ceb552e84577b0faf1e5a2f0450314985b4d8712b2b70717dc679fdc01b",
39 url = "https://github.com/bazelbuild/rules_python/releases/download/0.3.0/rules_python-0.3.0.tar.gz",
Nathaniel Broughb6b90d02021-05-11 11:32:17 +080040)
41
Nathaniel Broughf91e7632021-07-26 17:12:14 +080042# Set up Starlark library.
Nathaniel Brougha1113be2021-03-07 09:05:41 +080043# Required by: io_bazel_rules_go, com_google_protobuf.
44# Used in modules: None.
45# This must be instantiated before com_google_protobuf as protobuf_deps() pulls
46# in an older version of bazel_skylib. However io_bazel_rules_go requires a
47# newer version.
48http_archive(
49 name = "bazel_skylib",
50 sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c",
51 urls = [
52 "https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz",
53 "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz",
54 ],
55)
56
57load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
58
59bazel_skylib_workspace()
60
Nathaniel Broughf91e7632021-07-26 17:12:14 +080061# Set up upstream googletest and googlemock.
62# Required by: Pigweed.
63# Used in modules: //pw_analog, //pw_i2c.
64http_archive(
65 name = "com_google_googletest",
66 sha256 = "9dc9157a9a1551ec7a7e43daea9a694a0bb5fb8bec81235d8a1e6ef64c716dcb",
67 strip_prefix = "googletest-release-1.10.0",
68 urls = [
69 "https://mirror.bazel.build/github.com/google/googletest/archive/release-1.10.0.tar.gz",
70 "https://github.com/google/googletest/archive/release-1.10.0.tar.gz",
71 ],
72)
73
74# Set up host hermetic host toolchain.
Nathaniel Broughb44d95e2021-07-15 10:39:47 +080075# Required by: All cc targets.
76# Used in modules: All cc targets.
77git_repository(
78 name = "rules_cc_toolchain",
Nathaniel Broughf9cc0412021-08-17 09:32:32 +080079 commit = "80b51ba81f14eebe06684efa25261f6dc46e9b29",
Nathaniel Broughb44d95e2021-07-15 10:39:47 +080080 remote = "https://github.com/silvergasp/rules_cc_toolchain.git",
81)
82
83load("@rules_cc_toolchain//:rules_cc_toolchain_deps.bzl", "rules_cc_toolchain_deps")
84
85rules_cc_toolchain_deps()
86
87load("@rules_cc_toolchain//cc_toolchain:cc_toolchain.bzl", "register_cc_toolchains")
88
89register_cc_toolchains()
90
Nathaniel Broughf91e7632021-07-26 17:12:14 +080091# Set up Protobuf rules.
Nathaniel Brougha1113be2021-03-07 09:05:41 +080092# Required by: pigweed, com_github_bazelbuild_buildtools.
93# Used in modules: //pw_protobuf.
94http_archive(
95 name = "com_google_protobuf",
Anthony DiGirolamod63bd742021-08-19 16:13:30 -070096 sha256 = "c6003e1d2e7fefa78a3039f19f383b4f3a61e81be8c19356f85b6461998ad3db",
97 strip_prefix = "protobuf-3.17.3",
98 url = "https://github.com/protocolbuffers/protobuf/archive/v3.17.3.tar.gz",
Nathaniel Brougha1113be2021-03-07 09:05:41 +080099)
100
101load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
102
103protobuf_deps()
104
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800105# Set up tools to build custom GRPC rules.
Nathaniel Broughb4f4e7a2021-05-06 14:49:55 +0800106# Required by: pigweed.
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800107# Used in modules: //pw_protobuf.
Nathaniel Brough9d9a20d2020-08-04 16:46:56 +0800108http_archive(
109 name = "rules_proto_grpc",
Jared Weinstein27ab4e12021-08-16 14:52:33 -0700110 sha256 = "7954abbb6898830cd10ac9714fbcacf092299fda00ed2baf781172f545120419",
111 strip_prefix = "rules_proto_grpc-3.1.1",
112 urls = ["https://github.com/rules-proto-grpc/rules_proto_grpc/archive/3.1.1.tar.gz"],
Nathaniel Brough9d9a20d2020-08-04 16:46:56 +0800113)
114
Nathaniel Broughb4f4e7a2021-05-06 14:49:55 +0800115load(
116 "@rules_proto_grpc//:repositories.bzl",
117 "rules_proto_grpc_repos",
118 "rules_proto_grpc_toolchains",
119)
Nathaniel Brough9d9a20d2020-08-04 16:46:56 +0800120
121rules_proto_grpc_toolchains()
122
123rules_proto_grpc_repos()
124
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800125# Set up Bazel platforms.
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800126# Required by: pigweed.
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800127# Used in modules: //pw_build, (Assorted modules via select statements).
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800128git_repository(
129 name = "platforms",
130 commit = "d4c9d7f51a7c403814b60f66d20eeb425fbaaacb",
131 remote = "https://github.com/bazelbuild/platforms.git",
132)
133
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800134# Set up NodeJs rules.
135# Required by: pigweed.
136# Used in modules: //pw_web_ui.
Matthew Soulanille376d7972020-06-01 15:50:07 -0700137http_archive(
Nathaniel Broughb44d95e2021-07-15 10:39:47 +0800138 name = "build_bazel_rules_nodejs",
Jared Weinsteincf2ca742021-07-02 17:20:05 -0700139 sha256 = "8f5f192ba02319254aaf2cdcca00ec12eaafeb979a80a1e946773c520ae0a2c9",
140 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 -0700141)
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800142
143# Get the latest LTS version of Node.
144load(
145 "@build_bazel_rules_nodejs//:index.bzl",
146 "node_repositories",
147 "yarn_install",
148)
149
Matthew Soulanille376d7972020-06-01 15:50:07 -0700150node_repositories(package_json = ["//:package.json"])
151
Matthew Soulanille376d7972020-06-01 15:50:07 -0700152yarn_install(
153 name = "npm",
154 package_json = "//:package.json",
155 yarn_lock = "//:yarn.lock",
156)
157
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800158# Set up web-testing rules.
159# Required by: pigweed.
160# Used in modules: //pw_web_ui.
Nathaniel Brough9d9a20d2020-08-04 16:46:56 +0800161http_archive(
162 name = "io_bazel_rules_webtesting",
163 sha256 = "9bb461d5ef08e850025480bab185fd269242d4e533bca75bfb748001ceb343c3",
164 urls = ["https://github.com/bazelbuild/rules_webtesting/releases/download/0.3.3/rules_webtesting.tar.gz"],
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800165)
166
Nathaniel Brough9d9a20d2020-08-04 16:46:56 +0800167load("@io_bazel_rules_webtesting//web:repositories.bzl", "web_test_repositories")
168
Matthew Soulanille5e78acf2020-06-08 10:58:29 -0700169web_test_repositories()
170
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800171load(
172 "@io_bazel_rules_webtesting//web/versioned:browsers-0.3.2.bzl",
173 "browser_repositories",
174)
Matthew Soulanille5e78acf2020-06-08 10:58:29 -0700175
176browser_repositories(
177 chromium = True,
178 firefox = True,
179)
180
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800181# Set up embedded C/C++ toolchains.
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800182# Required by: pigweed.
183# Used in modules: //pw_polyfill, //pw_build (all pw_cc* targets).
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800184git_repository(
185 name = "bazel_embedded",
Nathaniel Broughb3718312021-09-16 08:26:34 +0800186 commit = "17c93d5fa52c4c78860b8bbd327325fba6c85555",
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800187 remote = "https://github.com/silvergasp/bazel-embedded.git",
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800188)
189
190# Instantiate Pigweed configuration for embedded toolchain,
191# this must be called before bazel_embedded_deps.
192load(
193 "//pw_build:pigweed_toolchain_upstream.bzl",
194 "toolchain_upstream_deps",
195)
196
197toolchain_upstream_deps()
198
199# Configure bazel_embedded toolchains and platforms.
200load(
201 "@bazel_embedded//:bazel_embedded_deps.bzl",
202 "bazel_embedded_deps",
203)
204
205bazel_embedded_deps()
206
207load(
208 "@bazel_embedded//platforms:execution_platforms.bzl",
209 "register_platforms",
210)
211
212register_platforms()
213
214# Fetch gcc-arm-none-eabi compiler and register for toolchain
215# resolution.
216load(
217 "@bazel_embedded//toolchains/compilers/gcc_arm_none_eabi:gcc_arm_none_repository.bzl",
218 "gcc_arm_none_compiler",
219)
220
221gcc_arm_none_compiler()
222
223load(
224 "@bazel_embedded//toolchains/gcc_arm_none_eabi:gcc_arm_none_toolchain.bzl",
225 "register_gcc_arm_none_toolchain",
226)
227
228register_gcc_arm_none_toolchain()
229
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800230# Registers platforms for use with toolchain resolution
Nathaniel Broughce910982021-02-16 15:51:57 +0800231register_execution_platforms("//pw_build/platforms:all")
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800232
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800233# Set up Golang toolchain rules.
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800234# Required by: bazel_gazelle, com_github_bazelbuild_buildtools.
235# Used in modules: None.
236http_archive(
237 name = "io_bazel_rules_go",
238 sha256 = "d1ffd055969c8f8d431e2d439813e42326961d0942bdf734d2c95dc30c369566",
239 urls = [
240 "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.5/rules_go-v0.24.5.tar.gz",
241 "https://github.com/bazelbuild/rules_go/releases/download/v0.24.5/rules_go-v0.24.5.tar.gz",
242 ],
243)
244
245load(
246 "@io_bazel_rules_go//go:deps.bzl",
247 "go_register_toolchains",
248 "go_rules_dependencies",
249)
250
251go_rules_dependencies()
252
253go_register_toolchains()
254
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800255# Set up bazel package manager for golang.
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800256# Required by: com_github_bazelbuild_buildtools.
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800257# Used in modules: None.
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800258http_archive(
259 name = "bazel_gazelle",
260 sha256 = "b85f48fa105c4403326e9525ad2b2cc437babaa6e15a3fc0b1dbab0ab064bc7c",
261 urls = [
262 "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.2/bazel-gazelle-v0.22.2.tar.gz",
263 "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.2/bazel-gazelle-v0.22.2.tar.gz",
264 ],
265)
266
267load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
268
269gazelle_dependencies()
270
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800271# Set up bazel buildtools (bazel linter and formatter).
272# Required by: pigweed.
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800273# Used in modules: //:all (bazel specific tools).
274http_archive(
275 name = "com_github_bazelbuild_buildtools",
276 sha256 = "c28eef4d30ba1a195c6837acf6c75a4034981f5b4002dda3c5aa6e48ce023cf1",
277 strip_prefix = "buildtools-4.0.1",
278 url = "https://github.com/bazelbuild/buildtools/archive/4.0.1.tar.gz",
279)
Nathaniel Broughfc95cca2021-04-18 22:20:26 +0800280
281load("//pw_build:target_config.bzl", "pigweed_config")
282
283# Configure Pigweeds backend.
284pigweed_config(
285 name = "pigweed_config",
286 build_file = "//targets:default_config.BUILD",
287)
Nathaniel Broughb6b90d02021-05-11 11:32:17 +0800288
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800289# Set up rules for fuzz testing.
Nathaniel Broughb6b90d02021-05-11 11:32:17 +0800290# Required by: pigweed.
Nathaniel Broughf91e7632021-07-26 17:12:14 +0800291# Used in modules: //pw_protobuf, //pw_tokenizer, //pw_fuzzer.
Nathaniel Broughb6b90d02021-05-11 11:32:17 +0800292http_archive(
293 name = "rules_fuzzing",
294 sha256 = "94f25c7a18db0502ace26a3ef7d0a25fd7c195c4e9770ddd1b1ec718e8936091",
295 strip_prefix = "rules_fuzzing-0.1.3",
296 urls = ["https://github.com/bazelbuild/rules_fuzzing/archive/v0.1.3.zip"],
297)
298
299load("@rules_fuzzing//fuzzing:repositories.bzl", "rules_fuzzing_dependencies")
300
301rules_fuzzing_dependencies()
302
303load("@rules_fuzzing//fuzzing:init.bzl", "rules_fuzzing_init")
304
305rules_fuzzing_init()