Skip to content

Commit

Permalink
refactor: enable protoc toolchains
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeagle committed May 29, 2024
1 parent 0c2b009 commit 27abcdb
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ common --@aspect_rules_ts//ts:default_to_tsc_transpiler
# We have some empty globs in this repo
common --noincompatible_disallow_empty_glob

# Never Compile protoc Again
common --incompatible_enable_proto_toolchain_resolution

# verbose
common:verbose --@aspect_rules_ts//ts:verbose --worker_verbose

Expand Down
13 changes: 13 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ bazel_dep(name = "gazelle", version = "0.36.0", dev_dependency = True, repo_name
bazel_dep(name = "rules_go", version = "0.46.0", dev_dependency = True, repo_name = "io_bazel_rules_go")
bazel_dep(name = "rules_nodejs", version = "6.1.0", dev_dependency = True)
bazel_dep(name = "stardoc", version = "0.6.2", dev_dependency = True, repo_name = "io_bazel_stardoc")
bazel_dep(name = "toolchains_protoc", version = "0.3.0", dev_dependency = True)

# Should not be required, stardoc leaks a dependency
bazel_dep(name = "rules_java", version = "7.6.1", dev_dependency = True)

register_toolchains("//tools/toolchains:all")

# pick up fix: https://github.com/bazelbuild/stardoc/pull/221
git_override(
module_name = "stardoc",
commit = "3baa5d1761970c6285d2ac9c3adccfaac42f54c5",
remote = "https://github.com/bazelbuild/stardoc.git",
)

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True)
npm.npm_translate_lock(
Expand Down
8 changes: 8 additions & 0 deletions WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_jar")
load("//.github/workflows:deps.bzl", "aspect_workflows_github_actions_deps")

aspect_workflows_github_actions_deps()
Expand All @@ -9,3 +10,10 @@ load(
)

fetch_shfmt()

# Needed for stardoc to compile from Java sources
http_jar(
name = "protobuf-java",
integrity = "sha256-kHLmD+Zs/11sDxGh3yHY8+Sym17ngrRcP8dfWfviuDk=",
urls = ["https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java/4.27.0/protobuf-java-4.27.0.jar"],
)
9 changes: 9 additions & 0 deletions tools/toolchains/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain")

proto_lang_toolchain(
name = "protoc_java_toolchain",
command_line = "--java_out=%s",
progress_message = "Generating Java proto_library %{label}",
runtime = "@protobuf-java//jar",
toolchain_type = "@rules_java//java/proto:toolchain_type",
)

0 comments on commit 27abcdb

Please sign in to comment.