Skip to content

Commit

Permalink
Update Scala toolchainizaion per @simuons in #1633
Browse files Browse the repository at this point in the history
- Removes an extraneous `compiler_sources_repo` call.

- `scala_toolchains` will now _always_ create the main Scala toolchain
  repository (there's no longer an option to turn it off).

- Registers `@io_bazel_rules_scala_toolchains//...:all` in
  `scala_register_toolchains.
  • Loading branch information
mbland committed Nov 12, 2024
1 parent 04a246c commit 6a2f39b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 34 deletions.
5 changes: 0 additions & 5 deletions scala/private/macros/scala_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,6 @@ def _setup_scala_compiler_sources(srcjars = {}):
scala_versions = SCALA_VERSIONS,
)

compiler_sources_repo(
name = "scala_compiler_sources",
scala_versions = SCALA_VERSIONS,
)

def _artifact_ids(scala_version):
result = [
"io_bazel_rules_scala_scala_compiler",
Expand Down
33 changes: 12 additions & 21 deletions scala/private/macros/toolchains.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ def scala_toolchains(
load_scala_toolchain_dependencies = True,
fetch_sources = False,
validate_scala_version = True,
scala_compiler_srcjars = {},
scala = True):
scala_compiler_srcjars = {}):
"""Instantiates @io_bazel_rules_scala_toolchains and all its dependencies.
Provides a unified interface to configuring rules_scala both directly in a
Expand Down Expand Up @@ -52,24 +51,16 @@ def scala_toolchains(
compiler srcjar metadata dictionaries containing:
- exactly one "label", "url", or "urls" key
- optional "integrity" or "sha256" keys
scala: whether to instantiate the core Scala toolchain
"""
num_toolchains = 0
scala_repositories(
maven_servers = maven_servers,
# Note the internal macro parameter misspells "overriden".
overriden_artifacts = overridden_artifacts,
load_dep_rules = load_rules_scala_dependencies,
load_jar_deps = load_scala_toolchain_dependencies,
fetch_sources = fetch_sources,
validate_scala_version = validate_scala_version,
scala_compiler_srcjars = scala_compiler_srcjars,
)

if scala:
num_toolchains += 1
scala_repositories(
maven_servers = maven_servers,
# Note the internal macro parameter misspells "overriden".
overriden_artifacts = overridden_artifacts,
load_dep_rules = load_rules_scala_dependencies,
load_jar_deps = load_scala_toolchain_dependencies,
fetch_sources = fetch_sources,
validate_scala_version = validate_scala_version,
scala_compiler_srcjars = scala_compiler_srcjars,
)

if num_toolchains != 0:
scala_toolchains_repo(
scala = scala,
)
scala_toolchains_repo()
9 changes: 1 addition & 8 deletions scala/toolchains.bzl
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
load("@io_bazel_rules_scala_config//:config.bzl", "SCALA_VERSIONS")
load("@io_bazel_rules_scala//scala:scala_cross_version.bzl", "version_suffix")

def scala_register_toolchains():
for scala_version in SCALA_VERSIONS:
native.register_toolchains(
"@io_bazel_rules_scala_toolchains//scala:toolchain" +
version_suffix(scala_version),
)
native.register_toolchains("@io_bazel_rules_scala_toolchains//...:all")

def scala_register_unused_deps_toolchains():
native.register_toolchains(
Expand Down

0 comments on commit 6a2f39b

Please sign in to comment.