-
-
Notifications
You must be signed in to change notification settings - Fork 74
/
MODULE.bazel
223 lines (189 loc) · 8 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
"Declare dependencies for bzlmod, see https://bazel.build/build/bzlmod"
# We declare all of the direct dependencies of all of the code in this
# workspace. A single version of each of these is declared, implying that all of
# the code will use the same version of all of these tools and libraries listed.
# For bzlmod dependencies, this implements the "single version policy".
bazel_dep(name = "apple_support", version = "1.11.1")
bazel_dep(name = "aspect_bazel_lib", version = "2.8.0")
bazel_dep(name = "aspect_rules_js", version = "2.0.0")
bazel_dep(name = "aspect_rules_lint", version = "1.0.0-rc10")
bazel_dep(name = "aspect_rules_swc", version = "2.0.0")
bazel_dep(name = "aspect_rules_ts", version = "3.0.0")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(name = "buildifier_prebuilt", version = "6.4.0")
bazel_dep(name = "gazelle", version = "0.32.0")
bazel_dep(name = "googletest", version = "1.15.2")
bazel_dep(name = "rules_apple", version = "3.0.0")
bazel_dep(name = "rules_buf", version = "0.3.0")
bazel_dep(name = "rules_go", version = "0.48.0")
bazel_dep(name = "rules_java", version = "7.4.0")
bazel_dep(name = "rules_jvm_external", version = "4.5")
bazel_dep(name = "rules_multitool", version = "0.12.0")
bazel_dep(name = "rules_proto", version = "6.0.0")
bazel_dep(name = "rules_python", version = "0.35.0")
bazel_dep(name = "rules_python_gazelle_plugin", version = "0.35.0")
bazel_dep(name = "rules_swift", version = "1.12.0")
bazel_dep(name = "rules_swift_package_manager", version = "0.12.0")
bazel_dep(name = "rules_uv", version = "0.25.0")
bazel_dep(name = "rules_xcodeproj", version = "1.11.0")
bazel_dep(name = "sqlite3", version = "3.42.0.bcr.1") # C code for SQLite.
bazel_dep(name = "toolchains_llvm", version = "1.1.2")
bazel_dep(name = "toolchains_protoc", version = "0.3.1")
# Just like in the old WORKSPACE file approach, you can directly grab some code
# with HTTP and make it available. The syntax is slightly different,
# demonstrated here.
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_jar = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_jar")
http_archive(
name = "net_sourceforge_pmd",
build_file_content = """java_import(name = "net_sourceforge_pmd", jars = glob(["*.jar"]), visibility = ["//visibility:public"])""",
sha256 = "21acf96d43cb40d591cacccc1c20a66fc796eaddf69ea61812594447bac7a11d",
strip_prefix = "pmd-bin-6.55.0/lib",
url = "https://github.com/pmd/pmd/releases/download/pmd_releases/6.55.0/pmd-bin-6.55.0.zip",
)
http_jar(
name = "com_puppycrawl_tools_checkstyle",
sha256 = "51c34d738520c1389d71998a9ab0e6dabe0d7cf262149f3e01a7294496062e42",
url = "https://github.com/checkstyle/checkstyle/releases/download/checkstyle-10.17.0/checkstyle-10.17.0-all.jar",
)
http_jar(
name = "google-java-format",
sha256 = "33068bbbdce1099982ec1171f5e202898eb35f2919cf486141e439fc6e3a4203",
url = "https://github.com/google/google-java-format/releases/download/v1.17.0/google-java-format-1.17.0-all-deps.jar",
)
#########################
# Fetch tools
# https://blog.aspect.build/run-tools-installed-by-bazel
multitool = use_extension("@rules_multitool//multitool:extension.bzl", "multitool")
multitool.hub(lockfile = "//tools:tools.lock.json")
use_repo(multitool, "multitool")
#########################
# Hermetic C++ toolchain, to relieve the dependency on a locally installed CC etc.
llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm")
llvm.toolchain(
llvm_versions = {
"": "15.0.6",
"darwin-aarch64": "15.0.7",
"darwin-x86_64": "15.0.7",
},
)
use_repo(llvm, "llvm_toolchain", "llvm_toolchain_llvm")
#########################
# Protobuf and gRPC
# https://github.com/aspect-build/toolchains_protoc
buf = use_extension("@rules_buf//buf:extensions.bzl", "buf")
buf.toolchains(version = "v1.34.0") #see https://github.com/bufbuild/buf/releases
use_repo(buf, "rules_buf_toolchains")
# This Aspect-provided protobuf toolchain removes the need to compile ProtoC from
# source, speeding up builds where a cached protoc isn't used.
protoc = use_extension("@toolchains_protoc//protoc:extensions.bzl", "protoc")
protoc.toolchain(
google_protobuf = "com_google_protobuf",
version = "LATEST",
)
use_repo(protoc, "com_google_protobuf", "toolchains_protoc_hub")
register_toolchains("@llvm_toolchain//:all")
register_toolchains("@toolchains_protoc_hub//:all")
register_toolchains("//tools/toolchains:all")
#########################
# Python
# https://github.com/bazelbuild/rules_python/tree/main/examples/bzlmod
# This pattern is repeated across many languages: First, bzlmod is used to bring
# in language support. Then, an extension is grabbed from that language support
# repository and used to configure the language version and additional
# dependencies using a language-specific mechanism popular in the relevant
# ecosystem.
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
python_version = "3.9",
)
pip.parse(
hub_name = "pip",
python_version = "3.9",
requirements_lock = "//requirements:all.txt",
)
use_repo(pip, "pip")
#########################
# Java and other JVM languages:
# https://github.com/bazelbuild/rules_jvm_external/blob/master/examples/bzlmod/MODULE.bazel
# https://github.com/bazelbuild/rules_jvm_external#pinning-artifacts-and-integration-with-bazels-downloader
# In the Maven support variation, the dependencies are conveniently listed here
# in the MODULE.bazel file.
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.install(
artifacts = [
"com.google.protobuf:protobuf-java:4.27.1",
"io.grpc:grpc-all:1.51.1",
],
lock_file = "//:maven_install.json",
)
use_repo(
maven,
"maven",
"unpinned_maven",
)
#########################
# JavaScript and TypeScript
# https://github.com/aspect-build/rules_js/tree/main/e2e/bzlmod
# https://github.com/aspect-build/rules_ts/tree/main/e2e/bzlmod
# In keeping with the single version policy, in this example, the NPM ecosystem
# dependencies are specified at the top level rather than in each sub-project.
# However, it is possible to have multiple different sets of NPM dependencies
# across a workspace.
pnpm = use_extension("@aspect_rules_js//npm:extensions.bzl", "pnpm")
# Allows developers to get a local node_modules tree, using
# bazel run -- @pnpm//:pnpm --dir $PWD install
use_repo(pnpm, "pnpm")
npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm")
npm.npm_translate_lock(
name = "npm",
npmrc = "//:.npmrc",
pnpm_lock = "//:pnpm-lock.yaml",
)
use_repo(npm, "npm")
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")
#########################
# Go
# See https://github.com/bazelbuild/rules_go/blob/master/docs/go/core/bzlmod.md
go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(
name = "go_sdk",
version = "1.21.1",
)
use_repo(go_sdk, "go_sdk")
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")
use_repo(go_deps, "org_golang_google_grpc", "org_golang_google_protobuf")
non_module_deps = use_extension("@rules_swift//swift:extensions.bzl", "non_module_deps")
use_repo(
non_module_deps,
"build_bazel_rules_swift_index_import",
"build_bazel_rules_swift_local_config",
"com_github_apple_swift_log",
"com_github_apple_swift_nio",
"com_github_apple_swift_nio_extras",
"com_github_apple_swift_nio_http2",
"com_github_apple_swift_nio_transport_services",
"com_github_apple_swift_protobuf",
"com_github_grpc_grpc_swift",
)
#########################
# Swift
swift_deps = use_extension(
"@rules_swift_package_manager//:extensions.bzl",
"swift_deps",
)
swift_deps.from_file(
deps_index = "//:swift_deps_index.json",
)
use_repo(
swift_deps,
"swiftpkg_swifterswift",
)