Skip to content

Commit

Permalink
use prebuilt protoc to avoid setup of a CC toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
malt3 committed Aug 29, 2024
1 parent 5c5c5d8 commit c9a62b0
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
# `bazel run @rules_bazel_integration_test//tools:update_deleted_packages`
build --deleted_packages=examples/full,examples/full/tool_test
query --deleted_packages=examples/full,examples/full/tool_test

# for stardoc
common --incompatible_enable_proto_toolchain_resolution
44 changes: 42 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,59 @@ module(
compatibility_level = 0,
)

# ✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂
# only dev_dependencies below this line - rules_gcs is lean
# ✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂✂

bazel_dep(
name = "bazel_skylib",
version = "1.7.1",
dev_dependency = True,
)
bazel_dep(
name = "rules_bazel_integration_test",
version = "0.25.0",
dev_dependency = True,
)
bazel_dep(
name = "rules_java",
version = "7.4.0",
dev_dependency = True,
)
bazel_dep(
name = "rules_proto",
version = "6.0.2",
dev_dependency = True,
)
bazel_dep(
name = "stardoc",
version = "0.7.0",
dev_dependency = True,
)
bazel_dep(
name = "rules_bazel_integration_test",
version = "0.25.0",
name = "toolchains_protoc",
version = "0.3.2",
dev_dependency = True,
)

protoc = use_extension("@toolchains_protoc//protoc:extensions.bzl", "protoc")
protoc.toolchain(
# Creates a repository to satisfy well-known-types dependencies such as
# deps=["@com_google_protobuf//:any_proto"]
google_protobuf = "com_google_protobuf",
version = "v27.0",
)

http_jar = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_jar")

http_jar(
name = "protobuf-java",
sha256 = "9072e60fe66cff5d6c0f11a1df21d8f3e4b29b5ee782b45c3fc75f59fbe2b839",
urls = ["https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java/4.27.0/protobuf-java-4.27.0.jar"],
)

register_toolchains(
"//docs/lang_toolchains:all",
dev_dependency = True,
)

Expand Down
9 changes: 9 additions & 0 deletions docs/lang_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 c9a62b0

Please sign in to comment.