Skip to content

Commit 99f58ac

Browse files
committed
Align scala_proto changes with pull requests
Adds comments and rearranges existing logic and declarations, but no material changes. Hence, no "Bzlmod part the Nth" commit message.
1 parent acd3a4b commit 99f58ac

File tree

3 files changed

+51
-49
lines changed

3 files changed

+51
-49
lines changed

scala/private/macros/toolchains.bzl

+4-4
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,10 @@ def scala_toolchains(
188188
scalatest = scalatest,
189189
junit = junit,
190190
specs2 = specs2,
191-
twitter_scrooge = twitter_scrooge,
192-
jmh = jmh,
193-
scala_proto = scala_proto,
194-
scala_proto_enable_all_options = scala_proto_enable_all_options,
195191
testing = testing,
196192
scalafmt = scalafmt,
193+
scala_proto = scala_proto,
194+
scala_proto_enable_all_options = scala_proto_enable_all_options,
195+
jmh = jmh,
196+
twitter_scrooge = twitter_scrooge,
197197
)

scala/private/macros/toolchains_repo.bzl

+42-38
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ def _generate_testing_toolchain_build_file_args(repo_attr):
2121

2222
if len(framework_deps) == 0:
2323
return None
24+
25+
# The _TESTING_TOOLCHAIN_BUILD template expects that all framework keys are
26+
# present in the dictionary, so it can set unset framework classpath
27+
# parameters to `None`.
2428
return {
2529
"deps_symbols": "\",\n \"".join(
2630
[s for s in framework_deps.values()],
@@ -41,12 +45,12 @@ def _scala_toolchains_repo_impl(repository_ctx):
4145

4246
if repo_attr.scala:
4347
toolchains["scala"] = _SCALA_TOOLCHAIN_BUILD
44-
if repo_attr.twitter_scrooge:
45-
toolchains["twitter_scrooge"] = _TWITTER_SCROOGE_TOOLCHAIN_BUILD
46-
if repo_attr.jmh:
47-
toolchains["jmh"] = _JMH_TOOLCHAIN_BUILD
4848
if repo_attr.scala_proto:
4949
toolchains["scala_proto"] = _SCALA_PROTO_TOOLCHAIN_BUILD
50+
if repo_attr.jmh:
51+
toolchains["jmh"] = _JMH_TOOLCHAIN_BUILD
52+
if repo_attr.twitter_scrooge:
53+
toolchains["twitter_scrooge"] = _TWITTER_SCROOGE_TOOLCHAIN_BUILD
5054

5155
testing_build_args = _generate_testing_toolchain_build_file_args(repo_attr)
5256
if testing_build_args != None:
@@ -74,12 +78,12 @@ _scala_toolchains_repo = repository_rule(
7478
"scalatest": attr.bool(),
7579
"junit": attr.bool(),
7680
"specs2": attr.bool(),
77-
"twitter_scrooge": attr.bool(),
78-
"jmh": attr.bool(),
79-
"scala_proto": attr.bool(),
80-
"scala_proto_enable_all_options": attr.bool(),
8181
"testing": attr.bool(),
8282
"scalafmt": attr.bool(),
83+
"scala_proto": attr.bool(),
84+
"scala_proto_enable_all_options": attr.bool(),
85+
"jmh": attr.bool(),
86+
"twitter_scrooge": attr.bool(),
8387
},
8488
)
8589

@@ -130,19 +134,35 @@ load(
130134
]
131135
"""
132136

133-
_TWITTER_SCROOGE_TOOLCHAIN_BUILD = """
137+
_TESTING_TOOLCHAIN_BUILD = """
138+
load("@@{rules_scala_repo}//scala:scala.bzl", "setup_scala_testing_toolchain")
139+
load("@@{rules_scala_repo}//scala:scala_cross_version.bzl", "version_suffix")
134140
load(
135-
"@@{rules_scala_repo}//twitter_scrooge/toolchain:toolchain.bzl",
136-
"setup_scrooge_toolchain",
141+
"@@{rules_scala_repo}//testing:deps.bzl",
142+
"{deps_symbols}",
137143
)
144+
load("@io_bazel_rules_scala_config//:config.bzl", "SCALA_VERSIONS")
138145
139-
setup_scrooge_toolchain(name = "scrooge_toolchain")
146+
[
147+
setup_scala_testing_toolchain(
148+
name = "testing_toolchain" + version_suffix(scala_version),
149+
scala_version = scala_version,
150+
scalatest_classpath = {scalatest},
151+
junit_classpath = {junit},
152+
specs2_classpath = {specs2},
153+
specs2_junit_classpath = {specs2_junit},
154+
)
155+
for scala_version in SCALA_VERSIONS
156+
]
140157
"""
141158

142-
_JMH_TOOLCHAIN_BUILD = """
143-
load("@@{rules_scala_repo}//jmh/toolchain:toolchain.bzl", "setup_jmh_toolchain")
159+
_SCALAFMT_TOOLCHAIN_BUILD = """
160+
load(
161+
"@@{rules_scala_repo}//scala/scalafmt/toolchain:setup_scalafmt_toolchain.bzl",
162+
"setup_scalafmt_toolchains",
163+
)
144164
145-
setup_jmh_toolchain(name = "jmh_toolchain")
165+
setup_scalafmt_toolchains()
146166
"""
147167

148168
_SCALA_PROTO_TOOLCHAIN_BUILD = """
@@ -184,33 +204,17 @@ declare_deps_provider(
184204
)
185205
"""
186206

187-
_TESTING_TOOLCHAIN_BUILD = """
188-
load("@@{rules_scala_repo}//scala:scala.bzl", "setup_scala_testing_toolchain")
189-
load("@@{rules_scala_repo}//scala:scala_cross_version.bzl", "version_suffix")
190-
load(
191-
"@@{rules_scala_repo}//testing:deps.bzl",
192-
"{deps_symbols}",
193-
)
194-
load("@io_bazel_rules_scala_config//:config.bzl", "SCALA_VERSIONS")
207+
_JMH_TOOLCHAIN_BUILD = """
208+
load("@@{rules_scala_repo}//jmh/toolchain:toolchain.bzl", "setup_jmh_toolchain")
195209
196-
[
197-
setup_scala_testing_toolchain(
198-
name = "testing_toolchain" + version_suffix(scala_version),
199-
scala_version = scala_version,
200-
scalatest_classpath = {scalatest},
201-
junit_classpath = {junit},
202-
specs2_classpath = {specs2},
203-
specs2_junit_classpath = {specs2_junit},
204-
)
205-
for scala_version in SCALA_VERSIONS
206-
]
210+
setup_jmh_toolchain(name = "jmh_toolchain")
207211
"""
208212

209-
_SCALAFMT_TOOLCHAIN_BUILD = """
213+
_TWITTER_SCROOGE_TOOLCHAIN_BUILD = """
210214
load(
211-
"@@{rules_scala_repo}//scala/scalafmt/toolchain:setup_scalafmt_toolchain.bzl",
212-
"setup_scalafmt_toolchains",
215+
"@@{rules_scala_repo}//twitter_scrooge/toolchain:toolchain.bzl",
216+
"setup_scrooge_toolchain",
213217
)
214218
215-
setup_scalafmt_toolchains()
219+
setup_scrooge_toolchain(name = "scrooge_toolchain")
216220
"""

scala_proto/default/repositories.bzl

+5-7
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,15 @@ def scala_proto_artifact_ids(scala_version):
6464
def scala_proto_default_repositories(
6565
maven_servers = default_maven_server_urls(),
6666
scala_version = SCALA_VERSION,
67-
overriden_artifacts = {},
68-
register_toolchains = True):
67+
overriden_artifacts = {}):
6968
repositories(
7069
scala_version = scala_version,
71-
for_artifact_ids = scala_proto_artifact_ids(),
70+
for_artifact_ids = scala_proto_artifact_ids(scala_version),
7271
maven_servers = maven_servers,
7372
fetch_sources = True,
7473
overriden_artifacts = overriden_artifacts,
7574
)
7675

77-
if register_toolchains:
78-
native.register_toolchains(
79-
str(Label("//scala_proto:default_deps_toolchain")),
80-
)
76+
native.register_toolchains(
77+
str(Label("//scala_proto:default_deps_toolchain")),
78+
)

0 commit comments

Comments
 (0)