-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathMODULE.bazel
317 lines (277 loc) · 10.7 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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
"""EngFlow example project"""
module(name = "engflow-example", version = "0.0.0")
http_file = use_repo_rule(
"@bazel_tools//tools/build_defs/repo:http.bzl", "http_file"
)
http_archive = use_repo_rule(
"@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive"
)
# Some file dependencies
http_file(
name = "emacs",
sha256 = "1439bf7f24e5769f35601dbf332e74dfc07634da6b1e9500af67188a92340a28",
urls = [
"https://storage.googleapis.com/engflow-tools-public/emacs-28.1.tar.gz",
"https://mirror.its.dal.ca/gnu/emacs/emacs-28.1.tar.gz",
"https://mirrors.kernel.org/gnu/emacs/emacs-28.1.tar.gz",
],
)
http_file(
name = "ubuntu_20.04_1.3GB",
sha256 = "5035be37a7e9abbdc09f0d257f3e33416c1a0fb322ba860d42d74aa75c3468d4",
urls = [
"https://storage.googleapis.com/engflow-tools-public/ubuntu-20.04.5-live-server-amd64.iso",
"https://mirror.math.princeton.edu/pub/ubuntu-iso/focal/ubuntu-20.04.5-live-server-amd64.iso",
"https://mirror.pit.teraswitch.com/ubuntu-releases/focal/ubuntu-20.04.5-live-server-amd64.iso",
],
)
# Abseil Python can be imported through pip_import, but it has native Bazel support too.
# bzlmod: https://github.com/abseil/abseil-py/issues/263
http_archive(
name = "io_abseil_py",
sha256 = "8a3d0830e4eb4f66c4fa907c06edf6ce1c719ced811a12e26d9d3162f8471758",
strip_prefix = "abseil-py-2.1.0",
url = "https://github.com/abseil/abseil-py/archive/refs/tags/v2.1.0.tar.gz",
)
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "engflowapis-java", version = "2025.01.17-13.50.20")
bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(
name = "protobuf",
version = "23.1",
repo_name = "com_google_protobuf",
)
# Per the instructions from:
# https://github.com/bazelbuild/apple_support?tab=readme-ov-file#bazel-7-setup
#
# If you also depend on `rules_cc`, `apple_support` must come _above_ `rules_cc`
# in your `MODULE.bazel` or `WORKSPACE` file because Bazel selects toolchains
# based on which is registered first.
bazel_dep(
name = "apple_support",
version = "1.15.1",
repo_name = "build_bazel_apple_support",
)
bazel_dep(name = "rules_cc", version = "0.0.9")
# https://github.com/googleapis/googleapis/pull/855
# https://github.com/bazelbuild/bazel-central-registry/pull/1699
bazel_dep(
name = "googleapis",
version = "0.0.0-20240326-1c8d509c5",
repo_name = "com_google_googleapis",
)
bazel_dep(name = "rules_python", version = "1.0.0")
PYTHON_VERSION = "3.12"
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
is_default = 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 = "//python:requirements_lock.txt",
)
use_repo(pip, "pip")
bazel_dep(name = "rules_proto", version = "6.0.2")
bazel_dep(name = "rules_dotnet", version = "0.15.1")
dotnet = use_extension("@rules_dotnet//dotnet:extensions.bzl", "dotnet")
dotnet.toolchain(dotnet_version = "8.0.200")
use_repo(dotnet, "dotnet_toolchains")
register_toolchains("@dotnet_toolchains//:all")
# https://github.com/bazelbuild/rules_go/blob/master/docs/go/core/bzlmod.md
bazel_dep(name = "rules_go", version = "0.48.1")
bazel_dep(name = "gazelle", version = "0.37.0")
GO_VERSION = "1.22.5"
go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(version = GO_VERSION)
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")
use_repo(go_deps, "com_github_google_go_cmp")
bazel_dep(name = "rules_java", version = "7.9.1")
# https://github.com/bazelbuild/rules_jvm_external/blob/master/docs/bzlmod.md
bazel_dep(name = "rules_jvm_external", version = "6.2")
bazel_dep(
name = "grpc-java",
version = "1.64.0",
repo_name = "io_grpc_grpc_java",
)
# Loads rules required to compile proto files
bazel_dep(name = "rules_proto_grpc", version = "5.0.0-alpha2")
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.install(
artifacts = [
"commons-cli:commons-cli:1.8.0",
"com.google.oauth-client:google-oauth-client:1.36.0",
"io.netty:netty-handler:4.1.111.Final",
],
# When updating versions, run `REPIN=1 bazel run @maven//:pin`
fail_if_repin_required = True,
lock_file = "//:maven_install.json",
strict_visibility = True,
repositories = [
"https://repo.maven.apache.org/maven2/",
],
)
use_repo(maven, "maven")
bazel_dep(name = "rules_kotlin", version = "1.9.6")
bazel_dep(name = "rules_perl", version = "0.2.0")
bazel_dep(
name = "rules_swift",
version = "1.18.0",
repo_name = "build_bazel_rules_swift"
)
bazel_dep(name = "aspect_rules_ts", version = "2.4.2")
rules_ts_ext = use_extension(
"@aspect_rules_ts//ts:extensions.bzl",
"ext",
dev_dependency = True,
)
rules_ts_ext.deps()
use_repo(rules_ts_ext, "npm_typescript")
# rules_scala is not yet bzlmod compatible:
#
# - https://github.com/bazelbuild/rules_scala/issues/1482
# - https://github.com/bazelbuild/bazel-central-registry/issues/522
#
# This is due to the following differences between the WORKSPACE and bzlmod
# models:
#
# - WORKSPACE executes http_archive, load, and any imported functions
# sequentially. This enables later expressions to refer to repos defined by
# expressions executed earlier in the WORKSPACE file. Also, WORKSPACE
# expressions can introduce repos to the global scope directly, without
# explicit import statements.
#
# - bzlmod enforces explicit repository declarations, with no expression
# referring to a repo defined in the same file. (The exception being arguments
# to register_toolchains(), and probably register_execution_platforms(), which
# don't appear to carry the risk of introducing circular definitions.)
#
# MODULE.bazel also doesn't allow load() calls, and load()s must appear at the
# beginning of an extension file, before any function definitions or calls.
#
# This enables bzlmod to build and verify an acyclic dependency graph from
# repo declarations alone, before and without executing any extension
# functions.
#
# As a result, importing the rules_scala repos into MODULE.bazel requires
# separate files:
#
# - MODULE.bazel loads the rules_scala archive as @io_bazel_rules_scala.
#
# - The //scala/extensions:config.bzl extension defines
# @io_bazel_rules_scala_config, which depends on @io_bazel_rules_scala.
#
# - The //scala/extensions:deps.bzl extension defines the repos needed by the
# Scala rules, which depend on @io_bazel_rules_scala and
# @io_bazel_rules_scala_config.
#
# The following problems occur when trying to import everything directly in
# MODULE.bazel, or in fewer extension files.
#
# ---
#
# In an extension, the http_archive call for rules_scala must still come first,
# thereby rendering later load() calls invalid. This precludes encapsulating the
# entire rules_scala configuration in a single extension.
#
# ---
#
# Defining @io_bazel_rules_scala_config using the following in MODULE.bazel:
#
# scala_config = use_repo_rule(
# "@io_bazel_rules_scala//:scala_config.bzl", "scala_config"
# )
# scala_config(name = "io_bazel_rules_scala_config")
#
# would produce:
#
# ERROR: Circular definition of repositories generated by module extensions
# and/or .bzl files:
# .-> @@_main~_repo_rules~io_bazel_rules_scala
# | extension '_repo_rules' defined in //:MODULE.bazel
# | @@_main~_repo_rules~io_bazel_rules_scala//:scala_config.bzl
# `-- @@_main~_repo_rules~io_bazel_rules_scala
# ERROR: cycles detected during target parsing
#
# ---
#
# Calling scala_config() and exporting @io_bazel_rules_scala_config from
# //scala:deps.bzl would also produce a circular definition error:
#
# ERROR: Circular definition of repositories generated by module extensions
# and/or .bzl files:
# .-> @@_main~scala_deps~io_bazel_rules_scala_config
# | extension 'scala_deps' defined in //scala:deps.bzl
# | //scala:deps.bzl
# | @@_main~_repo_rules~io_bazel_rules_scala//testing:scalatest.bzl
# | @@_main~_repo_rules~io_bazel_rules_scala//scalatest:scalatest.bzl
# | @@_main~_repo_rules~io_bazel_rules_scala//third_party/repositories:repositories.bzl
# | @@_main~scala_deps~io_bazel_rules_scala_config//:config.bzl
# `-- @@_main~scala_deps~io_bazel_rules_scala_config
# ERROR: cycles detected during target parsing
#
# This is because
# @io_bazel_rules_scala//third_party/repositories:repositories.bzl contains a
# load() statement depending on @io_bazel_rules_scala_config:
#
# load(
# "@io_bazel_rules_scala_config//:config.bzl",
# "SCALA_MAJOR_VERSION",
# "SCALA_VERSION",
# )
http_archive(
name = "io_bazel_rules_scala",
sha256 = "e734eef95cf26c0171566bdc24d83bd82bdaf8ca7873bec6ce9b0d524bdaf05d",
strip_prefix = "rules_scala-6.6.0",
url = "https://github.com/bazelbuild/rules_scala/releases/download/v6.6.0/rules_scala-v6.6.0.tar.gz",
patches = ["//scala:rules_scala-6.6.0.patch"],
patch_args = ["-p1"],
)
# This constant matches the default Scala version from rules_scala for now.
SCALA_VERSION = "2.13.12"
SCALA_VERSIONS = [SCALA_VERSION]
scala_config = use_extension("//scala/extensions:config.bzl", "scala_config")
scala_config.settings(
scala_version = SCALA_VERSION,
scala_versions = SCALA_VERSIONS,
)
use_repo(
scala_config,
"io_bazel_rules_scala_config",
)
repos = [
"io_bazel_rules_scala_scala_compiler",
"io_bazel_rules_scala_scala_library",
"io_bazel_rules_scala_scala_parser_combinators",
"io_bazel_rules_scala_scala_reflect",
"io_bazel_rules_scala_scala_xml",
"io_bazel_rules_scala_scalactic",
"io_bazel_rules_scala_scalatest",
"io_bazel_rules_scala_scalatest_core",
"io_bazel_rules_scala_scalatest_compatible",
"io_bazel_rules_scala_scalatest_featurespec",
"io_bazel_rules_scala_scalatest_flatspec",
"io_bazel_rules_scala_scalatest_freespec",
"io_bazel_rules_scala_scalatest_funspec",
"io_bazel_rules_scala_scalatest_funsuite",
"io_bazel_rules_scala_scalatest_matchers_core",
"io_bazel_rules_scala_scalatest_mustmatchers",
"io_bazel_rules_scala_scalatest_shouldmatchers",
]
toolchains = [
"@io_bazel_rules_scala//scala:toolchain",
"@io_bazel_rules_scala//testing:scalatest_toolchain",
]
scala_deps = use_extension("//scala/extensions:deps.bzl", "scala_deps")
[
(
[use_repo(scala_deps, repo + suffix) for repo in repos],
[register_toolchains(toolchain + suffix) for toolchain in toolchains],
)
# The v.replace() expression mimics the logic to generate version specific
# repo suffixes from rules_scala.
for suffix in ["_" + v.replace(".", "_") for v in SCALA_VERSIONS]
]