@@ -43,12 +43,14 @@ load(":jvm.bzl", _labeled_jars = "labeled_jars")
4343load (":providers.bzl" , _ScalaRulePhase = "ScalaRulePhase" )
4444load (
4545 ":register_toolchain.bzl" ,
46- _scala_toolchain_transition = "scala_toolchain_transition" ,
47- _scala_toolchain_transition_attributes = "scala_toolchain_transition_attributes" ,
46+ _scala_toolchain_attributes = "scala_toolchain_attributes" ,
47+ _scala_toolchain_incoming_transition = "scala_toolchain_incoming_transition" ,
48+ _scala_toolchain_outgoing_transition = "scala_toolchain_outgoing_transition" ,
4849)
4950
5051_compile_private_attributes = {
5152 "_java_toolchain" : attr .label (
53+ cfg = _scala_toolchain_outgoing_transition ,
5254 default = Label ("@bazel_tools//tools/jdk:current_java_toolchain" ),
5355 ),
5456 "_host_javabase" : attr .label (
@@ -77,6 +79,7 @@ _compile_private_attributes = {
7779
7880_compile_attributes = {
7981 "srcs" : attr .label_list (
82+ cfg = _scala_toolchain_outgoing_transition ,
8083 doc = "The source Scala and Java files (and `-sources.jar` `.srcjar` `-src.jar` files of those)." ,
8184 allow_files = [
8285 ".scala" ,
@@ -88,10 +91,12 @@ _compile_attributes = {
8891 flags = ["DIRECT_COMPILE_TIME_INPUT" ],
8992 ),
9093 "data" : attr .label_list (
94+ cfg = _scala_toolchain_outgoing_transition ,
9195 doc = "The additional runtime files needed by this library." ,
9296 allow_files = True ,
9397 ),
9498 "deps" : attr .label_list (
99+ cfg = _scala_toolchain_outgoing_transition ,
95100 aspects = [
96101 _labeled_jars ,
97102 _coverage_replacements_provider .aspect ,
@@ -100,21 +105,25 @@ _compile_attributes = {
100105 providers = [JavaInfo ],
101106 ),
102107 "deps_used_whitelist" : attr .label_list (
108+ cfg = _scala_toolchain_outgoing_transition ,
103109 doc = "The JVM library dependencies to always consider used for `scala_deps_used` checks." ,
104110 providers = [JavaInfo ],
105111 ),
106112 "deps_unused_whitelist" : attr .label_list (
113+ cfg = _scala_toolchain_outgoing_transition ,
107114 doc = "The JVM library dependencies to always consider unused for `scala_deps_direct` checks." ,
108115 providers = [JavaInfo ],
109116 ),
110117 "runtime_deps" : attr .label_list (
118+ cfg = _scala_toolchain_outgoing_transition ,
111119 doc = "The JVM runtime-only library dependencies." ,
112120 providers = [JavaInfo ],
113121 ),
114122 "javacopts" : attr .string_list (
115123 doc = "The Javac options." ,
116124 ),
117125 "plugins" : attr .label_list (
126+ cfg = _scala_toolchain_outgoing_transition ,
118127 doc = "The Scalac plugins." ,
119128 providers = [JavaInfo ],
120129 ),
@@ -123,10 +132,12 @@ _compile_attributes = {
123132 ),
124133 "resources" : attr .label_list (
125134 allow_files = True ,
135+ cfg = _scala_toolchain_outgoing_transition ,
126136 doc = "The files to include as classpath resources." ,
127137 ),
128138 "resource_jars" : attr .label_list (
129139 allow_files = [".jar" ],
140+ cfg = _scala_toolchain_outgoing_transition ,
130141 doc = "The JARs to merge into the output JAR." ,
131142 ),
132143 "scalacopts" : attr .string_list (
@@ -139,6 +150,7 @@ _library_attributes = {
139150 aspects = [
140151 _coverage_replacements_provider .aspect ,
141152 ],
153+ cfg = _scala_toolchain_outgoing_transition ,
142154 doc = "The JVM libraries to add as dependencies to any libraries dependent on this one." ,
143155 providers = [JavaInfo ],
144156 ),
@@ -157,17 +169,20 @@ _runtime_attributes = {
157169 doc = "The JVM runtime flags." ,
158170 ),
159171 "runtime_deps" : attr .label_list (
172+ cfg = _scala_toolchain_outgoing_transition ,
160173 doc = "The JVM runtime-only library dependencies." ,
161174 providers = [JavaInfo ],
162175 ),
163176}
164177
165178_runtime_private_attributes = {
166179 "_target_jdk" : attr .label (
180+ cfg = _scala_toolchain_outgoing_transition ,
167181 default = Label ("@bazel_tools//tools/jdk:current_java_runtime" ),
168182 providers = [java_common .JavaRuntimeInfo ],
169183 ),
170184 "_java_stub_template" : attr .label (
185+ cfg = _scala_toolchain_outgoing_transition ,
171186 default = Label ("@anx_java_stub_template//file" ),
172187 allow_single_file = True ,
173188 ),
@@ -243,11 +258,11 @@ def make_scala_library(*extras):
243258 _compile_attributes ,
244259 _compile_private_attributes ,
245260 _library_attributes ,
246- _scala_toolchain_transition_attributes ,
261+ _scala_toolchain_attributes ,
247262 _extras_attributes (extras ),
248263 * [extra ["attrs" ] for extra in extras ]
249264 ),
250- cfg = _scala_toolchain_transition ,
265+ cfg = _scala_toolchain_incoming_transition ,
251266 doc = "Compiles a Scala JVM library." ,
252267 implementation = _scala_library_implementation ,
253268 outputs = _dicts .add (
@@ -271,7 +286,7 @@ def make_scala_binary(*extras):
271286 _compile_private_attributes ,
272287 _runtime_attributes ,
273288 _runtime_private_attributes ,
274- _scala_toolchain_transition_attributes ,
289+ _scala_toolchain_attributes ,
275290 {
276291 "main_class" : attr .string (
277292 doc = "The main class. If not provided, it will be inferred by its type signature." ,
@@ -280,7 +295,7 @@ def make_scala_binary(*extras):
280295 _extras_attributes (extras ),
281296 * [extra ["attrs" ] for extra in extras ]
282297 ),
283- cfg = _scala_toolchain_transition ,
298+ cfg = _scala_toolchain_incoming_transition ,
284299 doc = """
285300Compiles and links a Scala JVM executable.
286301
@@ -317,7 +332,7 @@ def make_scala_test(*extras):
317332 _compile_private_attributes ,
318333 _runtime_attributes ,
319334 _runtime_private_attributes ,
320- _scala_toolchain_transition_attributes ,
335+ _scala_toolchain_attributes ,
321336 _testing_private_attributes ,
322337 {
323338 "isolation" : attr .string (
@@ -331,6 +346,7 @@ def make_scala_test(*extras):
331346 ),
332347 "scalacopts" : attr .string_list (doc = "Options to pass to scalac." ),
333348 "shared_deps" : attr .label_list (
349+ cfg = _scala_toolchain_outgoing_transition ,
334350 doc = "If isolation is \" classloader\" , the list of deps to keep loaded between tests" ,
335351 providers = [JavaInfo ],
336352 ),
@@ -345,13 +361,19 @@ def make_scala_test(*extras):
345361 ],
346362 doc = "The list of test frameworks to check for. These should conform to the sbt test interface (https://github.com/sbt/test-interface)." ,
347363 ),
348- "runner" : attr .label (default = "@rules_scala_annex//src/main/scala/higherkindness/rules_scala/workers/zinc/test" ),
349- "subprocess_runner" : attr .label (default = "@rules_scala_annex//src/main/scala/higherkindness/rules_scala/common/sbt-testing:subprocess" ),
364+ "runner" : attr .label (
365+ cfg = _scala_toolchain_outgoing_transition ,
366+ default = "@rules_scala_annex//src/main/scala/higherkindness/rules_scala/workers/zinc/test" ,
367+ ),
368+ "subprocess_runner" : attr .label (
369+ cfg = _scala_toolchain_outgoing_transition ,
370+ default = "@rules_scala_annex//src/main/scala/higherkindness/rules_scala/common/sbt-testing:subprocess" ,
371+ ),
350372 },
351373 _extras_attributes (extras ),
352374 * [extra ["attrs" ] for extra in extras ]
353375 ),
354- cfg = _scala_toolchain_transition ,
376+ cfg = _scala_toolchain_incoming_transition ,
355377 doc = """
356378Compiles and links a collection of Scala tests.
357379
@@ -396,13 +418,15 @@ _scala_repl_private_attributes = _dicts.add(
396418scala_repl = rule (
397419 attrs = _dicts .add (
398420 _scala_repl_private_attributes ,
399- _scala_toolchain_transition_attributes ,
421+ _scala_toolchain_attributes ,
400422 {
401423 "data" : attr .label_list (
424+ cfg = _scala_toolchain_outgoing_transition ,
402425 doc = "The additional runtime files needed by this REPL." ,
403426 allow_files = True ,
404427 ),
405428 "deps" : attr .label_list (
429+ cfg = _scala_toolchain_outgoing_transition ,
406430 doc = "Dependencies that should be made available to the REPL." ,
407431 providers = [JavaInfo ],
408432 ),
@@ -412,7 +436,7 @@ scala_repl = rule(
412436 "scalacopts" : attr .string_list (doc = "Options to pass to scalac." ),
413437 },
414438 ),
415- cfg = _scala_toolchain_transition ,
439+ cfg = _scala_toolchain_incoming_transition ,
416440 doc = """
417441Launches a REPL with all given dependencies available.
418442
@@ -469,14 +493,16 @@ Use this only for libraries with macros. Otherwise, use `java_import`.""",
469493
470494scaladoc = rule (
471495 attrs = _dicts .add (
472- _scala_toolchain_transition_attributes ,
496+ _scala_toolchain_attributes ,
473497 _scaladoc_private_attributes ,
474498 {
475499 "compiler_deps" : attr .label_list (
500+ cfg = _scala_toolchain_outgoing_transition ,
476501 doc = "JVM targets that should be included on the compile classpath." ,
477502 providers = [JavaInfo ],
478503 ),
479504 "deps" : attr .label_list (
505+ cfg = _scala_toolchain_outgoing_transition ,
480506 doc = "Dependencies that should be made available to the Scaladoc tool. These may include libraries referenced in Scaladoc or public signatures." ,
481507 providers = [JavaInfo ],
482508 ),
@@ -488,13 +514,14 @@ scaladoc = rule(
488514 "-sources.jar" ,
489515 "-src.jar" ,
490516 ],
517+ cfg = _scala_toolchain_outgoing_transition ,
491518 doc = "Sources from which to generate Scaladoc. These may include `*.java` files, `*.scala` files, and source JARs." ,
492519 ),
493520 "scalacopts" : attr .string_list (doc = "Options to pass to scalac." ),
494521 "title" : attr .string (doc = "The name of the project. If none is provided, the target label will be used." ),
495522 },
496523 ),
497- cfg = _scala_toolchain_transition ,
524+ cfg = _scala_toolchain_incoming_transition ,
498525 doc = "Generates Scaladoc." ,
499526 implementation = _scaladoc_implementation ,
500527 toolchains = [
0 commit comments