-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMODULE.bazel
285 lines (242 loc) · 9.97 KB
/
MODULE.bazel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# Update via
# bazel mod deps --lockfile_mode=update
# --lockfile_mode=refresh refreshes mutable fields
# Test via
# bazel mod deps --lockfile_mode=error
#
# See https://bazel.build/external/lockfile for more info
module(
name = "mchristen",
version = "",
)
########################################
# Generic deps
########################################
bazel_dep(name = "aspect_bazel_lib", version = "2.9.4")
########################################
# Set up rules_python and pip
########################################
bazel_dep(name = "aspect_rules_py", version = "0.7.3")
# Minimum version needs:
# feat: add interpreter_version_info to py_runtime by @mattem in #1671
bazel_dep(name = "rules_python", version = "0.34.0", dev_dependency = True)
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
# Must match interpreter_version in .bazelrc
# LINK(7e463bc3_e4d9_4464_ba39_3217c4a86004)
PYTHON_VERSION = "3.11"
python.toolchain(
configure_coverage_tool = True,
python_version = PYTHON_VERSION,
)
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
hub_name = "pip",
python_version = PYTHON_VERSION,
requirements_lock = "//:requirements_lock.txt",
)
use_repo(pip, "pip")
# TODO(#91): Allow bumping this up to 26 or greater while avoiding segfault
bazel_dep(name = "protobuf", version = "24.4")
bazel_dep(name = "rules_rust", version = "0.48.0")
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
rust.toolchain(edition = "2021")
use_repo(rust, "rust_toolchains")
register_toolchains("@rust_toolchains//:all")
crate = use_extension(
"@rules_rust//crate_universe:extension.bzl",
"crate",
)
crate.from_cargo(
name = "crate_index",
cargo_lockfile = "//:Cargo.lock",
manifests = [
"//:examples/basic/Cargo.toml",
],
)
use_repo(crate, "crate_index")
########################################
# Set up rules_oci
########################################
bazel_dep(name = "rules_oci", version = "1.7.4")
oci = use_extension("@rules_oci//oci:extensions.bzl", "oci")
oci.pull(
name = "distroless_base",
# 'latest' is not reproducible, but it's convenient.
# During the build we print a WARNING message that includes recommended 'digest' and 'platforms'
# values which you can use here in place of 'tag' to pin for reproducibility.
# tag = "latest",
digest = "sha256:9d4e5680d67c984ac9c957f66405de25634012e2d5d6dc396c4bdd2ba6ae569f",
image = "gcr.io/distroless/base",
platforms = [
"linux/amd64",
"linux/arm64/v8",
],
)
oci.pull(
name = "ubuntu_base",
# tag = "24.04",
digest = "sha256:723ad8033f109978f8c7e6421ee684efb624eb5b9251b70c6788fdb2405d050b",
image = "ubuntu",
platforms = [
"linux/amd64",
"linux/arm64/v8",
],
)
# For each oci.pull call, repeat the "name" here to expose them as dependencies.
use_repo(oci, "distroless_base", "ubuntu_base")
########################################
# Set up hermetic Buildifier tools
########################################
# This is helpful because the old version used an http_archive to fetch the buildtools
# WORKSPACE, but it is incompatible with bzlmod Go toolchains. Instead let's just use
# a prebuilt version.
bazel_dep(
name = "buildifier_prebuilt",
version = "6.4.0",
dev_dependency = True,
)
########################################
# Set up rules_js
########################################
# NOTE: We don't really use/support JS in this repo, and if you need to you'll
# have some more config to do, but we register rules_js here so we can use it to
# pull a few javascript packages used for repo tooling, like prettier for linting.
bazel_dep(name = "aspect_rules_js", version = "1.39.0")
##################
# Setup rules_lint
##################
bazel_dep(name = "aspect_rules_lint", version = "1.0.3")
# Next, follow the install instructions for
# - linting: https://github.com/aspect-build/rules_lint/blob/v1.0.3/docs/linting.md
# - formatting: https://github.com/aspect-build/rules_lint/blob/v1.0.3/docs/formatting.md
####### OPTIONAL: Customize Node.js version #########
# By default you get the node version from DEFAULT_NODE_VERSION in @rules_nodejs//nodejs:repositories.bzl
# Optionally you can pin a different node version:
# bazel_dep(name = "rules_nodejs", version = "5.8.2")
# node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node")
# node.toolchain(node_version = "16.14.2")
#################################
npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True)
pnpm = use_extension("@aspect_rules_js//npm:extensions.bzl", "pnpm", dev_dependency = True)
npm.npm_translate_lock(
name = "npm",
pnpm_lock = "//:pnpm-lock.yaml",
verify_node_modules_ignored = "//:.bazelignore",
)
use_repo(npm, "npm")
use_repo(pnpm, "pnpm")
bazel_dep(name = "rules_multirun", version = "0.9.0")
# Specify to support stackb_rules_proto in bazel 7
bazel_dep(name = "rules_apple", version = "3.7.0", repo_name = "build_bazel_rules_apple")
# Bazel rule helpers, including testing
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.7.1", dev_dependency = True) # mchristen add
# Allow platform transitions
bazel_dep(name = "rules_platform", version = "0.1.0")
# C++ Test framework
# https://github.com/catchorg/Catch2
# Consider adding listeners via https://github.com/catchorg/Catch2/blob/devel/docs/event-listeners.md
bazel_dep(name = "catch2", version = "3.6.0")
# Consider the googletest alternative: https://google.github.io/googletest/
# bazel_dep(name = "googletest", version = "1.15.2")
# Register our own toolchains
register_toolchains(
"//examples/bazel:foo_rude_toolchain",
"//examples/bazel:foo_nice_toolchain",
)
# Pigweed
######################################
bazel_dep(name = "freertos", version = "10.5.1.bcr.2")
bazel_dep(name = "nanopb", repo_name = "com_github_nanopb_nanopb")
bazel_dep(name = "pico-sdk", version = "2.0.0")
bazel_dep(name = "pigweed")
bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "pw_toolchain")
bazel_dep(name = "rules_cc")
bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
bazel_dep(name = "toolchains_llvm", version = "0.10.3")
# Python Type Checking - mypy
#############################
bazel_dep(name = "rules_mypy", version = "0.17.0")
types = use_extension("@rules_mypy//mypy:types.bzl", "types")
types.requirements(
name = "pip_types",
# `@pip` in the next line corresponds to the `hub_name` when using
# rules_python's `pip.parse(...)`.
pip_requirements = "@pip//:requirements.bzl",
# also legal to pass a `requirements.in` here
requirements_txt = "//:requirements_lock.txt",
)
use_repo(types, "pip_types")
# Module overrides
# ================
# TODO: https://pwbug.dev/349880767 - Point this back to the upstream repo once
# this PR is merged.
archive_override(
module_name = "hedron_compile_commands",
strip_prefix = "bazel-compile-commands-extractor-163521345aa6366fd1ed801b989b668b5c806f69",
urls = ["https://github.com/chadnorvell/bazel-compile-commands-extractor/archive/163521345aa6366fd1ed801b989b668b5c806f69.tar.gz"],
)
archive_override(
module_name = "rules_rust",
integrity = "sha256-+bWb47wg0VchIADaHt6L5Dma2Gn+Q589nz/MKcTi+lo=",
# Can only apply patches from local workspace
# patch_strip = 1,
# patches = [
# # Fix rustdoc test w/ proc macros
# # https://github.com/bazelbuild/rules_rust/pull/1952
# "@pigweed//pw_rust/bazel_patches:0001-rustdoc_test-Apply-prefix-stripping-to-proc_macro-de.patch",
# # Adds prototype functionality for documenting multiple crates in one
# # HTML output directory. While the approach in this patch may have
# # issues scaling to giant mono-repos, it is appropriate for embedded
# # projects and minimally invasive and should be easy to maintain. Once
# # the `rules_rust` community decides on a way to propperly support this,
# # we will migrate to that solution.
# # https://github.com/konkers/rules_rust/tree/wip/rustdoc
# "@pigweed//pw_rust/bazel_patches:0002-PROTOTYPE-Add-ability-to-document-multiple-crates-at.patch",
# ],
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.45.1/rules_rust-v0.45.1.tar.gz"],
)
# TODO: https://pwbug.dev/354274498 - nanopb is not yet in the BCR.
git_override(
module_name = "nanopb",
commit = "7c6c581bc6f7406a4f01c3b9853251ff0a68458b",
remote = "https://github.com/nanopb/nanopb.git",
)
git_override(
module_name = "pigweed",
# ROLL: Warning: this entry is automatically updated.
# ROLL: Last updated 2024-08-14.
# ROLL: By https://cr-buildbucket.appspot.com/build/8739669590315800497.
commit = "c9d5bef2f82612fa8d4be0d53b614bbc02bab62b",
remote = "https://pigweed.googlesource.com/pigweed/pigweed",
)
git_override(
module_name = "pw_toolchain",
# ROLL: Warning: this entry is automatically updated.
# ROLL: Last updated 2024-08-14.
# ROLL: By https://cr-buildbucket.appspot.com/build/8739669590315800497.
commit = "c9d5bef2f82612fa8d4be0d53b614bbc02bab62b",
remote = "https://pigweed.googlesource.com/pigweed/pigweed",
strip_prefix = "pw_toolchain_bazel",
)
# TODO: https://pwbug.dev/258836641 - Pre-release version needed for the Pico
# SDK. Remove this once rules_cc 0.10.0 is released and the Pico SDK
# MODULE.bazel declares its dependency on it.
archive_override(
module_name = "rules_cc",
integrity = "sha256-NddP6xi6LzsIHT8bMSVJ2NtoURbN+l3xpjvmIgB6aSg=",
strip_prefix = "rules_cc-1acf5213b6170f1f0133e273cb85ede0e732048f",
urls = [
"https://github.com/bazelbuild/rules_cc/archive/1acf5213b6170f1f0133e273cb85ede0e732048f.zip",
],
)
# Configure and register the toolchain.
llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm")
llvm.toolchain(
llvm_versions = {
"": "16.0.0",
"darwin-x86_64": "15.0.7",
},
)
use_repo(llvm, "llvm_toolchain", "llvm_toolchain_llvm")