blob: 677be5259279af99592d4934ba456d70e05e87c9 [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
56# Set up build_bazel_rules_nodejs.
57# Required by: pigweed.
58# Used in modules: //pw_web_ui.
Matthew Soulanille376d7972020-06-01 15:50:07 -070059http_archive(
60 name = "build_bazel_rules_nodejs",
Matthew Soulanille83c82822020-09-10 10:59:50 -070061 sha256 = "4952ef879704ab4ad6729a29007e7094aef213ea79e9f2e94cbe1c9a753e63ef",
62 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 -070063)
Nathaniel Brough82cf6872021-02-16 15:51:57 +080064
65# Get the latest LTS version of Node.
66load(
67 "@build_bazel_rules_nodejs//:index.bzl",
68 "node_repositories",
69 "yarn_install",
70)
71
Matthew Soulanille376d7972020-06-01 15:50:07 -070072node_repositories(package_json = ["//:package.json"])
73
Matthew Soulanille376d7972020-06-01 15:50:07 -070074yarn_install(
75 name = "npm",
76 package_json = "//:package.json",
77 yarn_lock = "//:yarn.lock",
78)
79
Nathaniel Brough82cf6872021-02-16 15:51:57 +080080# Set up Karma.
Matthew Soulanille83c82822020-09-10 10:59:50 -070081load("@npm//@bazel/karma:package.bzl", "npm_bazel_karma_dependencies")
Nathaniel Brough82cf6872021-02-16 15:51:57 +080082
Matthew Soulanille5e78acf2020-06-08 10:58:29 -070083npm_bazel_karma_dependencies()
84
Nathaniel Brough82cf6872021-02-16 15:51:57 +080085load(
86 "@io_bazel_rules_webtesting//web:repositories.bzl",
87 "web_test_repositories",
88)
89
Matthew Soulanille5e78acf2020-06-08 10:58:29 -070090web_test_repositories()
91
Nathaniel Brough82cf6872021-02-16 15:51:57 +080092load(
93 "@io_bazel_rules_webtesting//web/versioned:browsers-0.3.2.bzl",
94 "browser_repositories",
95)
Matthew Soulanille5e78acf2020-06-08 10:58:29 -070096
97browser_repositories(
98 chromium = True,
99 firefox = True,
100)
101
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800102# Setup embedded C/C++ toolchains.
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800103# Required by: pigweed.
104# Used in modules: //pw_polyfill, //pw_build (all pw_cc* targets).
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800105git_repository(
106 name = "bazel_embedded",
107 commit = "89c05fa415218abd2e24fa7016cb7903317d606b",
108 remote = "https://github.com/silvergasp/bazel-embedded.git",
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800109)
110
111# Instantiate Pigweed configuration for embedded toolchain,
112# this must be called before bazel_embedded_deps.
113load(
114 "//pw_build:pigweed_toolchain_upstream.bzl",
115 "toolchain_upstream_deps",
116)
117
118toolchain_upstream_deps()
119
120# Configure bazel_embedded toolchains and platforms.
121load(
122 "@bazel_embedded//:bazel_embedded_deps.bzl",
123 "bazel_embedded_deps",
124)
125
126bazel_embedded_deps()
127
128load(
129 "@bazel_embedded//platforms:execution_platforms.bzl",
130 "register_platforms",
131)
132
133register_platforms()
134
135# Fetch gcc-arm-none-eabi compiler and register for toolchain
136# resolution.
137load(
138 "@bazel_embedded//toolchains/compilers/gcc_arm_none_eabi:gcc_arm_none_repository.bzl",
139 "gcc_arm_none_compiler",
140)
141
142gcc_arm_none_compiler()
143
144load(
145 "@bazel_embedded//toolchains/gcc_arm_none_eabi:gcc_arm_none_toolchain.bzl",
146 "register_gcc_arm_none_toolchain",
147)
148
149register_gcc_arm_none_toolchain()
150
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800151# Fetch LLVM/Clang host compiler and register for toolchain resolution.
Nathaniel Brough82cf6872021-02-16 15:51:57 +0800152load(
153 "@bazel_embedded//toolchains/compilers/llvm:llvm_repository.bzl",
154 "llvm_repository",
155)
156
157llvm_repository(
158 name = "com_llvm_compiler",
159)
160
161load(
162 "@bazel_embedded//toolchains/clang:clang_toolchain.bzl",
163 "register_clang_toolchain",
164)
165
166register_clang_toolchain()
Nathaniel Broughce910982021-02-16 15:51:57 +0800167
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800168# Registers platforms for use with toolchain resolution
Nathaniel Broughce910982021-02-16 15:51:57 +0800169register_execution_platforms("//pw_build/platforms:all")
Nathaniel Brougha1113be2021-03-07 09:05:41 +0800170
171# Setup Golang toolchain rules
172# Required by: bazel_gazelle, com_github_bazelbuild_buildtools.
173# Used in modules: None.
174http_archive(
175 name = "io_bazel_rules_go",
176 sha256 = "d1ffd055969c8f8d431e2d439813e42326961d0942bdf734d2c95dc30c369566",
177 urls = [
178 "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.5/rules_go-v0.24.5.tar.gz",
179 "https://github.com/bazelbuild/rules_go/releases/download/v0.24.5/rules_go-v0.24.5.tar.gz",
180 ],
181)
182
183load(
184 "@io_bazel_rules_go//go:deps.bzl",
185 "go_register_toolchains",
186 "go_rules_dependencies",
187)
188
189go_rules_dependencies()
190
191go_register_toolchains()
192
193# Setup bazel package manager for golang
194# Required by: com_github_bazelbuild_buildtools.
195# Used in modules: None
196http_archive(
197 name = "bazel_gazelle",
198 sha256 = "b85f48fa105c4403326e9525ad2b2cc437babaa6e15a3fc0b1dbab0ab064bc7c",
199 urls = [
200 "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.2/bazel-gazelle-v0.22.2.tar.gz",
201 "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.2/bazel-gazelle-v0.22.2.tar.gz",
202 ],
203)
204
205load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
206
207gazelle_dependencies()
208
209# Setup bazel buildtools (bazel linter and formatter)
210# Required by: pigweed
211# Used in modules: //:all (bazel specific tools).
212http_archive(
213 name = "com_github_bazelbuild_buildtools",
214 sha256 = "c28eef4d30ba1a195c6837acf6c75a4034981f5b4002dda3c5aa6e48ce023cf1",
215 strip_prefix = "buildtools-4.0.1",
216 url = "https://github.com/bazelbuild/buildtools/archive/4.0.1.tar.gz",
217)