1
1
load (
2
2
"@rules_scala_annex//rules:providers.bzl" ,
3
- "LabeledJars" ,
4
- "ScalaConfiguration" ,
5
- "ScalaInfo" ,
6
- "ZincConfiguration" ,
7
- "ZincInfo" ,
3
+ _LabeledJars = "LabeledJars" ,
4
+ _ScalaConfiguration = "ScalaConfiguration" ,
5
+ _ScalaInfo = "ScalaInfo" ,
6
+ _ZincConfiguration = "ZincConfiguration" ,
7
+ _ZincInfo = "ZincInfo" ,
8
8
)
9
- load ("//rules/common:private/utils.bzl" , "write_launcher" )
10
- load (":private/import.bzl" , "create_intellij_info" )
9
+ load ("//rules/common:private/utils.bzl" , _write_launcher = "write_launcher" )
10
+ load (":private/import.bzl" , _create_intellij_info = "create_intellij_info" )
11
11
12
12
runner_common_attributes = {
13
13
"_java_toolchain" : attr .label (
@@ -37,6 +37,7 @@ scala_binary_private_attributes = dict({
37
37
),
38
38
"_java_stub_template" : attr .label (
39
39
default = Label ("@anx_java_stub_template//file" ),
40
+ allow_single_file = True ,
40
41
),
41
42
}, ** runner_common_attributes )
42
43
@@ -45,10 +46,10 @@ scala_test_private_attributes = scala_binary_private_attributes
45
46
def runner_common (ctx ):
46
47
runner = ctx .toolchains ["@rules_scala_annex//rules/scala:runner_toolchain_type" ]
47
48
48
- scala_configuration = ctx .attr .scala [ScalaConfiguration ]
49
+ scala_configuration = ctx .attr .scala [_ScalaConfiguration ]
49
50
scala_configuration_runtime_deps = _collect (JavaInfo , scala_configuration .runtime_classpath )
50
51
51
- zinc_configuration = ctx .attr .scala [ZincConfiguration ]
52
+ zinc_configuration = ctx .attr .scala [_ZincConfiguration ]
52
53
53
54
sdeps = java_common .merge (_collect (JavaInfo , scala_configuration .runtime_classpath + ctx .attr .deps ))
54
55
sruntime_deps = java_common .merge (_collect (JavaInfo , ctx .attr .runtime_deps ))
@@ -94,7 +95,7 @@ def runner_common(ctx):
94
95
macro_classpath = [
95
96
dep [JavaInfo ].transitive_runtime_jars
96
97
for dep in ctx .attr .deps
97
- if ScalaInfo in dep and dep [ScalaInfo ].macro
98
+ if _ScalaInfo in dep and dep [_ScalaInfo ].macro
98
99
]
99
100
compile_classpath = depset (order = "preorder" , transitive = macro_classpath + [sdeps .transitive_compile_time_jars ])
100
101
@@ -128,7 +129,7 @@ def runner_common(ctx):
128
129
129
130
javacopts = [ctx .expand_location (option , ctx .attr .data ) for option in ctx .attr .javacopts + java_common .default_javac_opts (ctx , java_toolchain_attr = "_java_toolchain" )]
130
131
131
- zincs = [dep [ZincInfo ] for dep in ctx .attr .deps if ZincInfo in dep ]
132
+ zincs = [dep [_ZincInfo ] for dep in ctx .attr .deps if _ZincInfo in dep ]
132
133
133
134
args = ctx .actions .args ()
134
135
args .add_all (depset (transitive = [zinc .deps for zinc in zincs ]), map_each = _analysis )
@@ -179,7 +180,7 @@ def runner_common(ctx):
179
180
180
181
deps_toolchain = ctx .toolchains ["@rules_scala_annex//rules/scala:deps_toolchain_type" ]
181
182
deps_checks = {}
182
- labeled_jars = depset (transitive = [dep [LabeledJars ].values for dep in ctx .attr .deps ])
183
+ labeled_jars = depset (transitive = [dep [_LabeledJars ].values for dep in ctx .attr .deps ])
183
184
deps_inputs , _ , deps_input_manifests = ctx .resolve_command (tools = [deps_toolchain .runner ])
184
185
for name in ("direct" , "used" ):
185
186
deps_check = ctx .actions .declare_file ("{}/deps_check_{}" .format (ctx .label .name , name ))
@@ -237,7 +238,7 @@ def runner_common(ctx):
237
238
for jar in java_info .outputs .jars :
238
239
jars .append (jar .class_jar )
239
240
jars .append (jar .ijar )
240
- zinc_info = ZincInfo (
241
+ zinc_info = _ZincInfo (
241
242
apis = apis ,
242
243
label = ctx .label ,
243
244
relations = relations ,
@@ -262,9 +263,9 @@ def runner_common(ctx):
262
263
return struct (
263
264
deps_check = deps_check ,
264
265
java_info = java_info ,
265
- scala_info = ScalaInfo (macro = ctx .attr .macro , scala_configuration = scala_configuration ),
266
+ scala_info = _ScalaInfo (macro = ctx .attr .macro , scala_configuration = scala_configuration ),
266
267
zinc_info = zinc_info ,
267
- intellij_info = create_intellij_info (ctx .label , ctx .attr .deps , java_info ),
268
+ intellij_info = _create_intellij_info (ctx .label , ctx .attr .deps , java_info ),
268
269
files = depset (files ),
269
270
mains_files = depset ([mains_file ]),
270
271
)
@@ -299,9 +300,6 @@ def _collect(index, iterable):
299
300
300
301
def _analysis (analysis ):
301
302
return (["--analysis" , str (analysis .label ), analysis .apis .path , analysis .relations .path ] + [jar .path for jar in analysis .jars ])
302
- """
303
- Ew. Bazel 0.13.0's map_each will allow us to produce multiple args from each item.
304
- """
305
303
306
304
def _labeled_group (labeled_jars ):
307
305
return (["--group" , "_{}" .format (labeled_jars .label )] + [jar .path for jar in labeled_jars .jars .to_list ()])
@@ -355,7 +353,7 @@ def scala_binary_implementation(ctx):
355
353
rjars = depset ([ctx .outputs .jar ], transitive = [transitive_rjars ])
356
354
_build_deployable (ctx , rjars .to_list ())
357
355
358
- files = write_launcher (
356
+ files = _write_launcher (
359
357
ctx ,
360
358
ctx .outputs .bin ,
361
359
java_info .transitive_runtime_deps ,
@@ -406,7 +404,7 @@ def scala_test_implementation(ctx):
406
404
args .add_all ("--shared_classpath" , shared_deps .transitive_runtime_deps , map_each = _short_path )
407
405
elif ctx .attr .isolation == "process" :
408
406
subprocess_executable = ctx .actions .declare_file ("{}/subprocess" .format (ctx .label .name ))
409
- files += write_launcher (
407
+ files += _write_launcher (
410
408
ctx ,
411
409
subprocess_executable ,
412
410
runner_jars ,
@@ -422,7 +420,7 @@ def scala_test_implementation(ctx):
422
420
ctx .actions .write (args_file , args )
423
421
files .append (args_file )
424
422
425
- files += write_launcher (
423
+ files += _write_launcher (
426
424
ctx ,
427
425
ctx .outputs .bin ,
428
426
runner_jars ,
@@ -453,11 +451,5 @@ def scala_test_implementation(ctx):
453
451
java = res .intellij_info ,
454
452
)
455
453
456
- def _analyses (analyses ):
457
- return [_analysis (analysis ) for analysis in analyses ]
458
-
459
454
def _short_path (file ):
460
455
return file .short_path
461
-
462
- def _short_paths (files ):
463
- return [file .short_path for file in files ]
0 commit comments