forked from aspect-build/toolchains_protoc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMODULE.bazel
More file actions
182 lines (161 loc) · 5.33 KB
/
MODULE.bazel
File metadata and controls
182 lines (161 loc) · 5.33 KB
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
bazel_dep(name = "toolchains_protoc", version = "0.0.0")
bazel_dep(name = "aspect_bazel_lib", version = "2.11.0")
bazel_dep(name = "aspect_rules_js", version = "2.2.0")
bazel_dep(name = "aspect_rules_py", version = "1.3.2")
bazel_dep(name = "aspect_rules_ts", version = "3.5.1")
bazel_dep(name = "platforms", version = "0.0.11")
bazel_dep(name = "protobuf", version = "29.3")
single_version_override(
module_name = "protobuf",
patch_strip = 1,
patches = [
"//third_party:protobuf/0001-bazel-Remove-hardcoded-dependency-on-protoc-from-lan.patch",
"//third_party:protobuf/0002-Switch-to-toolchains.patch",
],
version = "29.3",
)
bazel_dep(name = "rules_java", version = "8.6.3")
bazel_dep(name = "rules_proto", version = "7.1.0")
bazel_dep(name = "rules_python", version = "1.2.0-rc0")
bazel_dep(name = "rules_rust", version = "0.59.1")
bazel_dep(name = "rules_rust_prost", version = "0.59.1")
bazel_dep(name = "rules_go", version = "0.53.0")
bazel_dep(name = "rules_uv", version = "0.56.0")
# Need https://github.com/bazelbuild/rules_python/pull/2620
git_override(
module_name = "rules_python",
commit = "e95f95f75c9078f252f5b03eca18cba12d2e2166",
remote = "https://github.com/alexeagle/rules_python.git",
)
# This example is in the same repo with the ruleset, so we should point to the code at HEAD
# rather than use any release on the Bazel Central Registry.
local_path_override(
module_name = "toolchains_protoc",
path = "..",
)
####### PROTOBUF ##########
protoc = use_extension("@toolchains_protoc//protoc:extensions.bzl", "protoc")
protoc.toolchain(
google_protobuf = "com_google_protobuf",
# Demonstrate overriding the default version
version = "v28.0",
)
use_repo(protoc, "com_google_protobuf", "toolchains_protoc_hub")
register_toolchains("@toolchains_protoc_hub//:all")
# NB: the `:all` here is critical, because `proto_lang_toolchain` expands into two targets:
# - proto_lang_toolchain rule [name]
# - toolchain rule [name]_toolchain
# and the second one is valid for registration.
# Attempting to register a proto_lang_toolchain rule as a toolchain gives a baffling error like
# Misconfigured toolchains: //tools:protoc_java_toolchain is declared as a toolchain but has inappropriate dependencies.
# Declared toolchains should be created with the 'toolchain' rule and should not have dependencies that themselves require toolchains.
register_toolchains("//tools/toolchains:all")
####### PYTHON ##########
# Shows how a typical Python user fetches all the dependencies of their app, including the protobuf runtime
dev_pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
dev_pip.parse(
hub_name = "pypi",
python_version = "3.11",
requirements_lock = "//tools:requirements.txt",
)
use_repo(dev_pip, "pypi")
####### JAVA ##########
# Note: this is simpler than using rules_jvm_external with a maven installation,
# however it can cause version skew on the classpath if Coursier resolves a different version
# from the constraint solution.
# Users with a maven.install should instead do something like
# maven.install(
# artifacts = [
# "com.google.protobuf:protobuf-java:4.27.1",
# "io.grpc:grpc-all:1.51.1",
# ],
# lock_file = "//:maven_install.json",
# )
http_jar = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_jar")
http_jar(
name = "protobuf-java",
integrity = "sha256-rSOIR3s7lplCQeZHMaE2iU3J/tbeufJ21ISosXGxRQw=",
urls = ["https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java/4.28.0/protobuf-java-4.28.0.jar"],
)
####### RUST ##########
RUST_EDITION = "2021"
RUST_VERSION = "1.79.0"
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
rust.toolchain(
edition = RUST_EDITION,
versions = [RUST_VERSION],
)
use_repo(rust, "rust_toolchains")
register_toolchains("@rust_toolchains//:all")
# Proto toolchain
crate = use_extension("@rules_rust//crate_universe:extension.bzl", "crate")
# protobuf / gRPC dependencies
crate.spec(
package = "prost",
version = "0.13.1",
)
crate.spec(
default_features = False,
package = "prost-types",
version = "0.13.1",
)
crate.spec(
features = ["transport"],
package = "tonic",
version = "0.12.1",
)
crate.spec(
package = "tonic-build",
version = "0.12.1",
)
crate.spec(
package = "protoc-gen-prost",
version = "0.4.0",
)
crate.annotation(
crate = "protoc-gen-prost",
gen_binaries = ["protoc-gen-prost"],
)
crate.spec(
package = "protoc-gen-tonic",
version = "0.4.0",
)
crate.annotation(
crate = "protoc-gen-tonic",
gen_binaries = ["protoc-gen-tonic"],
)
crate.spec(
default_features = False,
features = [
"macros",
"net",
"rt-multi-thread",
"signal",
],
package = "tokio",
version = "1.38",
)
crate.from_specs()
use_repo(crate, "crates")
####### TYPESCRIPT ##########
npm = use_extension(
"@aspect_rules_js//npm:extensions.bzl",
"npm",
dev_dependency = True,
)
pnpm = use_extension("@aspect_rules_js//npm:extensions.bzl", "pnpm")
npm.npm_translate_lock(
name = "npm",
pnpm_lock = "//:pnpm-lock.yaml",
)
use_repo(npm, "npm")
use_repo(pnpm, "pnpm")
rules_ts_ext = use_extension(
"@aspect_rules_ts//ts:extensions.bzl",
"ext",
dev_dependency = True,
)
rules_ts_ext.deps(
ts_version_from = "//:package.json",
)
use_repo(rules_ts_ext, "npm_typescript")