Skip to content

Commit 27abcdb

Browse files
committed
refactor: enable protoc toolchains
1 parent 0c2b009 commit 27abcdb

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

.bazelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ common --@aspect_rules_ts//ts:default_to_tsc_transpiler
1414
# We have some empty globs in this repo
1515
common --noincompatible_disallow_empty_glob
1616

17+
# Never Compile protoc Again
18+
common --incompatible_enable_proto_toolchain_resolution
19+
1720
# verbose
1821
common:verbose --@aspect_rules_ts//ts:verbose --worker_verbose
1922

MODULE.bazel

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@ bazel_dep(name = "gazelle", version = "0.36.0", dev_dependency = True, repo_name
2828
bazel_dep(name = "rules_go", version = "0.46.0", dev_dependency = True, repo_name = "io_bazel_rules_go")
2929
bazel_dep(name = "rules_nodejs", version = "6.1.0", dev_dependency = True)
3030
bazel_dep(name = "stardoc", version = "0.6.2", dev_dependency = True, repo_name = "io_bazel_stardoc")
31+
bazel_dep(name = "toolchains_protoc", version = "0.3.0", dev_dependency = True)
32+
33+
# Should not be required, stardoc leaks a dependency
34+
bazel_dep(name = "rules_java", version = "7.6.1", dev_dependency = True)
35+
36+
register_toolchains("//tools/toolchains:all")
37+
38+
# pick up fix: https://github.com/bazelbuild/stardoc/pull/221
39+
git_override(
40+
module_name = "stardoc",
41+
commit = "3baa5d1761970c6285d2ac9c3adccfaac42f54c5",
42+
remote = "https://github.com/bazelbuild/stardoc.git",
43+
)
3144

3245
npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True)
3346
npm.npm_translate_lock(

WORKSPACE.bzlmod

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_jar")
12
load("//.github/workflows:deps.bzl", "aspect_workflows_github_actions_deps")
23

34
aspect_workflows_github_actions_deps()
@@ -9,3 +10,10 @@ load(
910
)
1011

1112
fetch_shfmt()
13+
14+
# Needed for stardoc to compile from Java sources
15+
http_jar(
16+
name = "protobuf-java",
17+
integrity = "sha256-kHLmD+Zs/11sDxGh3yHY8+Sym17ngrRcP8dfWfviuDk=",
18+
urls = ["https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java/4.27.0/protobuf-java-4.27.0.jar"],
19+
)

tools/toolchains/BUILD.bazel

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain")
2+
3+
proto_lang_toolchain(
4+
name = "protoc_java_toolchain",
5+
command_line = "--java_out=%s",
6+
progress_message = "Generating Java proto_library %{label}",
7+
runtime = "@protobuf-java//jar",
8+
toolchain_type = "@rules_java//java/proto:toolchain_type",
9+
)

0 commit comments

Comments
 (0)