blob: 9c2506773f92224ca48f0d17d33aa4cb42acfde1 [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.
57# Regquired by: pigweed.
58# 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
66load("@rules_proto_grpc//:repositories.bzl", "rules_proto_grpc_repos", "rules_proto_grpc_toolchains")
67
68rules_proto_grpc_toolchains()
69
70rules_proto_grpc_repos()
71
Nathaniel Brougha1113be2021-03-07 09:05:41 +080072# Set up build_bazel_rules_nodejs.
73# Required by: pigweed.
74# Used in modules: //pw_web_ui.
Nathaniel Broughc2d57812021-04-18 22:52:00 +080075git_repository(
76 name = "platforms",
77 commit = "d4c9d7f51a7c403814b60f66d20eeb425fbaaacb",
78 remote = "https://github.com/bazelbuild/platforms.git",
79)
80
Matthew Soulanille376d7972020-06-01 15:50:07 -070081http_archive(
82 name = "build_bazel_rules_nodejs",
Matthew Soulanille83c82822020-09-10 10:59:50 -070083 sha256 = "4952ef879704ab4ad6729a29007e7094aef213ea79e9f2e94cbe1c9a753e63ef",
84 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 -070085)
Nathaniel Brough82cf6872021-02-16 15:51:57 +080086
87# Get the latest LTS version of Node.
88load(
89 "@build_bazel_rules_nodejs//:index.bzl",
90 "node_repositories",
91 "yarn_install",
92)
93
Matthew Soulanille376d7972020-06-01 15:50:07 -070094node_repositories(package_json = ["//:package.json"])
95
Matthew Soulanille376d7972020-06-01 15:50:07 -070096yarn_install(
97 name = "npm",
98 package_json = "//:package.json",
99 yarn_lock = "//:yarn.lock",
100)
101
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800102# Set up Karma.
Matthew Soulanille83c82822020-09-10 10:59:50 -0700103load("@npm//@bazel/karma:package.bzl", "npm_bazel_karma_dependencies")
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800104
Matthew Soulanille5e78acf2020-06-08 10:58:29 -0700105npm_bazel_karma_dependencies()
106
Nathaniel Brough9d9a20d2020-08-04 16:46:56 +0800107http_archive(
108 name = "io_bazel_rules_webtesting",
109 sha256 = "9bb461d5ef08e850025480bab185fd269242d4e533bca75bfb748001ceb343c3",
110 urls = ["https://github.com/bazelbuild/rules_webtesting/releases/download/0.3.3/rules_webtesting.tar.gz"],
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800111)
112
Nathaniel Brough9d9a20d2020-08-04 16:46:56 +0800113load("@io_bazel_rules_webtesting//web:repositories.bzl", "web_test_repositories")
114
Matthew Soulanille5e78acf2020-06-08 10:58:29 -0700115web_test_repositories()
116
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800117load(
118 "@io_bazel_rules_webtesting//web/versioned:browsers-0.3.2.bzl",
119 "browser_repositories",
120)
Matthew Soulanille5e78acf2020-06-08 10:58:29 -0700121
122browser_repositories(
123 chromium = True,
124 firefox = True,
125)
126
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800127# Setup embedded C/C++ toolchains.
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800128# Required by: pigweed.
129# Used in modules: //pw_polyfill, //pw_build (all pw_cc* targets).
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800130git_repository(
131 name = "bazel_embedded",
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800132 commit = "d4717a6e33b88cb9fe1b6663d78656728c49b5c8",
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800133 remote = "https://github.com/silvergasp/bazel-embedded.git",
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800134)
135
136# Instantiate Pigweed configuration for embedded toolchain,
137# this must be called before bazel_embedded_deps.
138load(
139 "//pw_build:pigweed_toolchain_upstream.bzl",
140 "toolchain_upstream_deps",
141)
142
143toolchain_upstream_deps()
144
145# Configure bazel_embedded toolchains and platforms.
146load(
147 "@bazel_embedded//:bazel_embedded_deps.bzl",
148 "bazel_embedded_deps",
149)
150
151bazel_embedded_deps()
152
153load(
154 "@bazel_embedded//platforms:execution_platforms.bzl",
155 "register_platforms",
156)
157
158register_platforms()
159
160# Fetch gcc-arm-none-eabi compiler and register for toolchain
161# resolution.
162load(
163 "@bazel_embedded//toolchains/compilers/gcc_arm_none_eabi:gcc_arm_none_repository.bzl",
164 "gcc_arm_none_compiler",
165)
166
167gcc_arm_none_compiler()
168
169load(
170 "@bazel_embedded//toolchains/gcc_arm_none_eabi:gcc_arm_none_toolchain.bzl",
171 "register_gcc_arm_none_toolchain",
172)
173
174register_gcc_arm_none_toolchain()
175
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800176# Fetch LLVM/Clang host compiler and register for toolchain resolution.
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800177load(
178 "@bazel_embedded//toolchains/compilers/llvm:llvm_repository.bzl",
179 "llvm_repository",
180)
181
182llvm_repository(
183 name = "com_llvm_compiler",
184)
185
186load(
187 "@bazel_embedded//toolchains/clang:clang_toolchain.bzl",
188 "register_clang_toolchain",
189)
190
191register_clang_toolchain()
Nathaniel Broughce910982021-02-16 15:51:57 +0800192
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800193# Registers platforms for use with toolchain resolution
Nathaniel Broughce910982021-02-16 15:51:57 +0800194register_execution_platforms("//pw_build/platforms:all")
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800195
196# Setup Golang toolchain rules
197# Required by: bazel_gazelle, com_github_bazelbuild_buildtools.
198# Used in modules: None.
199http_archive(
200 name = "io_bazel_rules_go",
201 sha256 = "d1ffd055969c8f8d431e2d439813e42326961d0942bdf734d2c95dc30c369566",
202 urls = [
203 "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.5/rules_go-v0.24.5.tar.gz",
204 "https://github.com/bazelbuild/rules_go/releases/download/v0.24.5/rules_go-v0.24.5.tar.gz",
205 ],
206)
207
208load(
209 "@io_bazel_rules_go//go:deps.bzl",
210 "go_register_toolchains",
211 "go_rules_dependencies",
212)
213
214go_rules_dependencies()
215
216go_register_toolchains()
217
218# Setup bazel package manager for golang
219# Required by: com_github_bazelbuild_buildtools.
220# Used in modules: None
221http_archive(
222 name = "bazel_gazelle",
223 sha256 = "b85f48fa105c4403326e9525ad2b2cc437babaa6e15a3fc0b1dbab0ab064bc7c",
224 urls = [
225 "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.2/bazel-gazelle-v0.22.2.tar.gz",
226 "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.2/bazel-gazelle-v0.22.2.tar.gz",
227 ],
228)
229
230load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
231
232gazelle_dependencies()
233
234# Setup bazel buildtools (bazel linter and formatter)
235# Required by: pigweed
236# Used in modules: //:all (bazel specific tools).
237http_archive(
238 name = "com_github_bazelbuild_buildtools",
239 sha256 = "c28eef4d30ba1a195c6837acf6c75a4034981f5b4002dda3c5aa6e48ce023cf1",
240 strip_prefix = "buildtools-4.0.1",
241 url = "https://github.com/bazelbuild/buildtools/archive/4.0.1.tar.gz",
242)
Nathaniel Broughfc95cca2021-04-18 22:20:26 +0800243
244load("//pw_build:target_config.bzl", "pigweed_config")
245
246# Configure Pigweeds backend.
247pigweed_config(
248 name = "pigweed_config",
249 build_file = "//targets:default_config.BUILD",
250)