Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toolchainize //scala_proto:{,deps_}toolchain_type #1687

Merged
merged 1 commit into from
Feb 5, 2025

Conversation

mbland
Copy link
Contributor

@mbland mbland commented Jan 27, 2025

Description

Adds scala_proto toolchains to scala_toolchains(). Part of #1482.

The most significant part of the change is moving all the toolchain rules from scala_proto/BUILD to setup_scala_toolchains() in scala_proto/toolchains.bzl.

Adds the scala_proto_deps_providers() macro to replace //scala_proto:scalapb_{compile,grpc,worker}_deps_provider targets in the dep_providers parameter of scala_proto_deps_toolchain(). Examples of this are in test/proto/custom_generator/BUILD.

Excludes @scala_proto_rules_scalapb_protoc_gen from DEFAULT_SCALAPB_WORKER_DEPS in scala_proto/default/default_deps.bzl for Scala 2.11. For other Scala versions, this repo name will have the Scala version appended.

A lot of the other changes are more opportunistic removals of @io_bazel_rules_scala label prefixes and application of Label() where appropriate.

Motivation

This is the next step in the toolchainization of the frameworks used to implement various rules, as required to implement Bzlmod support.

Excluding @scala_proto_rules_scalapb_protoc_gen from DEFAULT_SCALAPB_WORKER_DEPS avoids build failures under Bzlmod, since:

  • This repo is required by ScalaPB 0.11.17, but Scala 2.11 is capped at ScalaPB 0.9.8.

  • Importing the nonexistent scala_proto_rules_scalapb_protoc_gen under Scala 2.11 results in an error under Bzlmod, as does importing it multiple times when configuring multiple Scala versions.

  • MODULE.bazel can iterate over a list of Scala versions, filtering out Scala 2.11, and call use_repo() on each version specific repo.

As in other pull requests, removing @io_bazel_rules_scala label prefixes will allow Bzlmod users to use rules_scala without setting repo_name = "@io_bazel_rules_scala" in bazel_dep().

Adds scala_proto toolchains to `scala_toolchains()`. Part of bazelbuild#1482.

The most significant part of the change is moving all the toolchain
rules from `scala_proto/BUILD` to `setup_scala_toolchains()` in
`scala_proto/toolchains.bzl`.

Adds the `scala_proto_deps_providers()` macro to replace
`//scala_proto:scalapb_{compile,grpc,worker}_deps_provider` targets in
the `dep_providers` parameter of `scala_proto_deps_toolchain()`.
Examples of this are in `test/proto/custom_generator/BUILD`.

Excludes `@scala_proto_rules_scalapb_protoc_gen` from
`DEFAULT_SCALAPB_WORKER_DEPS` in `scala_proto/default/default_deps.bzl`
for Scala 2.11. For other Scala versions, this repo name will have the
Scala version appended. This is to avoid build failures under Bzlmod,
since:

- This repo is required by ScalaPB 0.11.17, but Scala 2.11 is capped at
  ScalaPB 0.9.8.

- Importing the nonexistent `scala_proto_rules_scalapb_protoc_gen` under
  Scala 2.11 results in an error under Bzlmod, as does importing it
  multiple times when configuring multiple Scala versions.

- `MODULE.bazel` can iterate over a list of Scala versions, filtering
  out Scala 2.11, and call `use_repo()` on each version specific repo.

A lot of the other changes are more opportunistic removals of
`@io_bazel_rules_scala` label prefixes and application of `Label()`
where appropriate. Doing this will allow Bzlmod users to use
`rules_scala` without setting `repo_name = "@io_bazel_rules_scala"` in
`bazel_dep()`.
@mbland mbland force-pushed the bzlmod-toolchain-scala-proto branch from 7df3082 to 62c17f1 Compare February 3, 2025 15:04
@mbland
Copy link
Contributor Author

mbland commented Feb 3, 2025

Rebased after #1688 and #1689.

Copy link
Collaborator

@simuons simuons left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @mbland!

@liucijus liucijus merged commit d409cb6 into bazelbuild:master Feb 5, 2025
2 checks passed
@mbland mbland deleted the bzlmod-toolchain-scala-proto branch February 5, 2025 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants