Skip to content

Commit

Permalink
Make Stardoc work with --incompatible_enable_proto_toolchain_resolution.
Browse files Browse the repository at this point in the history
  • Loading branch information
lberki committed Jun 21, 2024
1 parent 018dee5 commit 05510e0
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 26 deletions.
9 changes: 7 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ module(
)

bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(name = "rules_java", version = "6.3.0")
bazel_dep(name = "rules_jvm_external", version = "5.2")
bazel_dep(name = "rules_java", version = "7.4.0")
bazel_dep(name = "rules_jvm_external", version = "6.1")
bazel_dep(name = "rules_license", version = "0.0.7")
bazel_dep(name = "rules_proto", version = "6.0.2")
bazel_dep(name = "toolchains_protoc", version = "0.3.1")

# Maven artifacts required by Stardoc; keep consistent with deps.bzl
STARDOC_MAVEN_ARTIFACTS = [
Expand All @@ -17,6 +19,7 @@ STARDOC_MAVEN_ARTIFACTS = [
"com.google.guava:guava:31.1-jre",
"com.google.truth:truth:1.1.3",
"junit:junit:4.13.2",
"com.google.protobuf:protobuf-java:4.27.1",
]

maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
Expand All @@ -34,3 +37,5 @@ use_repo(maven, "stardoc_maven")

# Dev-only and test-only dependencies
bazel_dep(name = "rules_pkg", version = "0.10.1", dev_dependency = True)

register_toolchains("//toolchains:all")
54 changes: 44 additions & 10 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,29 @@ rules_pkg_dependencies()
# Needed as a transitive dependency of @io_bazel
http_archive(
name = "rules_proto",
sha256 = "dc3fb206a2cb3441b485eb1e423165b231235a1ea9b031b4433cf7bc1fa460dd",
strip_prefix = "rules_proto-5.3.0-21.7",
urls = [
"https://github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.7.tar.gz",
],
sha256 = "6fb6767d1bef535310547e03247f7518b03487740c11b6c6adb7952033fe1295",
strip_prefix = "rules_proto-6.0.2",
url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.2/rules_proto-6.0.2.tar.gz",
)

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies")
rules_proto_dependencies()

load("@rules_proto//proto:setup.bzl", "rules_proto_setup")
rules_proto_setup()

load("@rules_proto//proto:toolchains.bzl", "rules_proto_toolchains")
rules_proto_toolchains()

load("@bazel_features//:deps.bzl", "bazel_features_deps")

bazel_features_deps()

load("@toolchains_protoc//protoc:toolchain.bzl", "protoc_toolchains")

protoc_toolchains(
name = "protoc_toolchains",
version = "v27.1",
)

# Needed only for testing stardoc across local-repository bounds.
Expand All @@ -83,13 +101,29 @@ local_repository(
path = ".",
)

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies")
rules_proto_dependencies()

load("@rules_proto//proto:setup.bzl", "rules_proto_setup")
rules_proto_setup()

load("@rules_proto//proto:toolchains.bzl", "rules_proto_toolchains")
rules_proto_toolchains()

load("@bazel_features//:deps.bzl", "bazel_features_deps")

bazel_features_deps()

load("@toolchains_protoc//protoc:toolchain.bzl", "protoc_toolchains")

protoc_toolchains(
name = "protoc_toolchains",
version = "v25.3",
)

local_repository(
name = "local_repository_test",
path = "test/testdata/local_repository_test",
)

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")

rules_proto_dependencies()

rules_proto_toolchains()
register_toolchains("//toolchains:all")
1 change: 1 addition & 0 deletions deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ STARDOC_MAVEN_ARTIFACTS = [
"com.google.guava:guava:31.1-jre",
"com.google.truth:truth:1.1.3",
"junit:junit:4.13.2",
"com.google.protobuf:protobuf-java:4.27.1",
]

def stardoc_external_deps():
Expand Down
15 changes: 13 additions & 2 deletions maven_install.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL",
"__INPUT_ARTIFACTS_HASH": -1307148388,
"__RESOLVED_ARTIFACTS_HASH": 1764595048,
"__INPUT_ARTIFACTS_HASH": 1794655755,
"__RESOLVED_ARTIFACTS_HASH": 2130017368,
"artifacts": {
"com.beust:jcommander": {
"shasums": {
Expand Down Expand Up @@ -57,6 +57,12 @@
},
"version": "1.3"
},
"com.google.protobuf:protobuf-java": {
"shasums": {
"jar": "798c79f6c9fc6859cc76aa5474228aad250821438e1004dad34880d53aa745f9"
},
"version": "4.27.1"
},
"com.google.truth:truth": {
"shasums": {
"jar": "fc0b67782289a2aabfddfdf99eff1dcd5edc890d49143fcd489214b107b8f4f3"
Expand Down Expand Up @@ -166,6 +172,10 @@
"com.google.j2objc:j2objc-annotations": [
"com.google.j2objc.annotations"
],
"com.google.protobuf:protobuf-java": [
"com.google.protobuf",
"com.google.protobuf.compiler"
],
"com.google.truth:truth": [
"com.google.common.truth"
],
Expand Down Expand Up @@ -255,6 +265,7 @@
"com.google.guava:guava",
"com.google.guava:listenablefuture",
"com.google.j2objc:j2objc-annotations",
"com.google.protobuf:protobuf-java",
"com.google.truth:truth",
"junit:junit",
"org.checkerframework:checker-qual",
Expand Down
28 changes: 16 additions & 12 deletions setup.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,17 @@ def stardoc_repositories():
http_archive,
name = "rules_java",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_java/releases/download/6.3.0/rules_java-6.3.0.tar.gz",
"https://github.com/bazelbuild/rules_java/releases/download/6.3.0/rules_java-6.3.0.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/rules_java/releases/download/7.4.0/rules_java-7.4.0.tar.gz",
"https://github.com/bazelbuild/rules_java/releases/download/7.4.0/rules_java-7.4.0.tar.gz",
],
sha256 = "29ba147c583aaf5d211686029842c5278e12aaea86f66bd4a9eb5e525b7f2701",
sha256 = "976ef08b49c929741f201790e59e3807c72ad81f428c8bc953cdbeff5fed15eb",
)

RULES_JVM_EXTERNAL_TAG = "5.2"
RULES_JVM_EXTERNAL_SHA = "f86fd42a809e1871ca0aabe89db0d440451219c3ce46c58da240c7dcdc00125f"
RULES_JVM_EXTERNAL_TAG = "6.1"
RULES_JVM_EXTERNAL_SHA = "08ea921df02ffe9924123b0686dc04fd0ff875710bfadb7ad42badb931b0fd50"
maybe(
http_archive,
name = "rules_jvm_external",
patch_args = ["-p1"],
patches = ["@io_bazel_stardoc//:rules_jvm_external.patch"],
strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
sha256 = RULES_JVM_EXTERNAL_SHA,
url = "https://github.com/bazelbuild/rules_jvm_external/releases/download/%s/rules_jvm_external-%s.tar.gz" % (RULES_JVM_EXTERNAL_TAG, RULES_JVM_EXTERNAL_TAG),
Expand All @@ -72,16 +70,22 @@ def stardoc_repositories():
sha256 = "4531deccb913639c30e5c7512a054d5d875698daeb75d8cf90f284375fe7c360",
)

maybe(
http_archive,
name = "toolchains_protoc",
sha256 = "3898f8e621ca5b3c7b94300c5ae19075d5bb28349d6e6f407490a466ba1e2544",
strip_prefix = "toolchains_protoc-0.3.1",
url = "https://github.com/aspect-build/toolchains_protoc/releases/download/v0.3.1/toolchains_protoc-v0.3.1.tar.gz",
)

# Transitive dep of com_google_protobuf. Unfortunately, protobuf_deps()
# pulls in a dep that's too old.
maybe(
http_archive,
name = "rules_proto",
sha256 = "dc3fb206a2cb3441b485eb1e423165b231235a1ea9b031b4433cf7bc1fa460dd",
strip_prefix = "rules_proto-5.3.0-21.7",
urls = [
"https://github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.7.tar.gz",
],
sha256 = "6fb6767d1bef535310547e03247f7518b03487740c11b6c6adb7952033fe1295",
strip_prefix = "rules_proto-6.0.2",
url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.2/rules_proto-6.0.2.tar.gz",
)

# Transitive dep of com_google_protobuf. Unfortunately, protobuf_deps()
Expand Down
12 changes: 12 additions & 0 deletions toolchains/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
proto_lang_toolchain(
name = "protoc_java_toolchain",
command_line = "--java_out=%s",
progress_message = "Generating Java proto_library %{label}",
runtime = "@stardoc_maven//:com_google_protobuf_protobuf_java",
)

toolchain(
name = "protoc_java_toolchain.registration",
toolchain = ":protoc_java_toolchain",
toolchain_type = "@rules_java//java/proto:toolchain_type",
)

0 comments on commit 05510e0

Please sign in to comment.