44 "@rules_scala_annex//rules:providers.bzl" ,
55 _ScalaConfiguration = "ScalaConfiguration" ,
66 _ZincCompilationInfo = "ZincCompilationInfo" ,
7- _ZincConfiguration = "ZincConfiguration" ,
8- _ZincDepInfo = "ZincDepInfo" ,
9- _ZincInfo = "ZincInfo" ,
107)
118
129#
1714
1815def phase_zinc_compile (ctx , g ):
1916 toolchain = ctx .toolchains ["//rules/scala:toolchain_type" ]
20- analysis_store = ctx .actions .declare_file ("{}/analysis_store.gz" .format (ctx .label .name ))
21- analysis_store_text = ctx .actions .declare_file ("{}/analysis_store.text.gz" .format (ctx .label .name ))
2217 mains_file = ctx .actions .declare_file ("{}.jar.mains.txt" .format (ctx .label .name ))
2318 used = ctx .actions .declare_file ("{}/deps_used.txt" .format (ctx .label .name ))
2419 tmp = ctx .actions .declare_directory ("{}/tmp" .format (ctx .label .name ))
@@ -34,21 +29,16 @@ def phase_zinc_compile(ctx, g):
3429 )
3530 ]
3631
37- zincs = [dep [_ZincInfo ] for dep in ctx .attr .deps if _ZincInfo in dep ]
3832 common_scalacopts = toolchain .scala_configuration .global_scalacopts + ctx .attr .scalacopts
3933
4034 args = ctx .actions .args ()
41- if toolchain .zinc_configuration .incremental :
42- args .add_all (depset (transitive = [zinc .deps for zinc in zincs ]), map_each = _compile_analysis )
43-
4435 args .add ("--compiler_bridge" , toolchain .zinc_configuration .compiler_bridge )
4536 args .add_all ("--compiler_classpath" , g .classpaths .compiler )
4637 args .add_all ("--classpath" , g .classpaths .compile )
4738 args .add_all (common_scalacopts , format_each = "--compiler_option=%s" )
4839 args .add_all (javacopts , format_each = "--java_compiler_option=%s" )
4940 args .add (ctx .label , format = "--label=%s" )
5041 args .add ("--main_manifest" , mains_file )
51- args .add ("--output_analysis_store" , analysis_store )
5242 args .add ("--output_jar" , g .classpaths .jar )
5343 args .add ("--output_used" , used )
5444 args .add_all ("--plugins" , g .classpaths .plugin )
@@ -58,29 +48,16 @@ def phase_zinc_compile(ctx, g):
5848
5949 g .semanticdb .arguments_modifier (args )
6050
61- args .add_all ("--" , g .classpaths .srcs )
62- args .set_param_file_format ("multiline" )
63- args .use_param_file ("@%s" , use_always = True )
64-
65- worker = toolchain .zinc_configuration .compile_worker
66-
6751 inputs = depset (
6852 [toolchain .zinc_configuration .compiler_bridge ] + ctx .files .data + ctx .files .srcs ,
6953 transitive = [
7054 g .classpaths .plugin ,
7155 g .classpaths .compile ,
7256 g .classpaths .compiler ,
73- ] + ([ zinc . deps_files for zinc in zincs ] if toolchain . zinc_configuration . incremental else []) ,
57+ ],
7458 )
7559
76- outputs = [
77- g .classpaths .jar ,
78- mains_file ,
79- analysis_store ,
80- analysis_store_text ,
81- used ,
82- tmp ,
83- ] + g .semanticdb .outputs
60+ outputs = [g .classpaths .jar , mains_file , used , tmp ] + g .semanticdb .outputs
8461
8562 if hasattr (ctx .attr , "frameworks" ):
8663 tests_file = ctx .actions .declare_file ("{}/tests.json" .format (ctx .label .name ))
@@ -92,6 +69,12 @@ def phase_zinc_compile(ctx, g):
9269 else :
9370 tests_file = None
9471
72+ args .add_all ("--" , g .classpaths .srcs )
73+ args .set_param_file_format ("multiline" )
74+ args .use_param_file ("@%s" , use_always = True )
75+
76+ worker = toolchain .zinc_configuration .compile_worker
77+
9578 execution_requirements_tags = {
9679 "supports-multiplex-workers" : "1" ,
9780 "supports-workers" : "1" ,
@@ -100,16 +83,6 @@ def phase_zinc_compile(ctx, g):
10083 "supports-path-mapping" : "1" ,
10184 }
10285
103- # Disable several things if incremental compilation features are going to be used
104- # because incremental compilation require stashing files outside the sandbox that
105- # Bazel isn't aware of and is less deterministic than ideal.
106- if toolchain .zinc_configuration .incremental :
107- execution_requirements_tags ["no-sandbox" ] = "1"
108- execution_requirements_tags ["no-cache" ] = "1"
109- execution_requirements_tags ["no-remote" ] = "1"
110- execution_requirements_tags ["supports-multiplex-sandboxing" ] = "0"
111- execution_requirements_tags ["supports-path-mapping" ] = "0"
112-
11386 # todo: different execution path for nosrc jar?
11487 ctx .actions .run (
11588 arguments = [args ],
@@ -126,32 +99,9 @@ def phase_zinc_compile(ctx, g):
12699 for jar in g .javainfo .java_info .outputs .jars :
127100 jars .append (jar .class_jar )
128101 jars .append (jar .ijar )
129- zinc_info = _ZincInfo (
130- analysis_store = analysis_store ,
131- deps_files = depset ([analysis_store ], transitive = [zinc .deps_files for zinc in zincs ]),
132- label = ctx .label ,
133- deps = depset (
134- [_ZincDepInfo (
135- analysis_store = analysis_store ,
136- jars = tuple (jars ),
137- label = ctx .label ,
138- )],
139- transitive = [zinc .deps for zinc in zincs ],
140- ),
141- )
142102
143- g .out .providers .append (zinc_info )
144103 return _ZincCompilationInfo (
145104 mains_file = mains_file ,
146105 tests_file = tests_file ,
147106 used = used ,
148- # todo: see about cleaning up & generalizing fields below
149- zinc_info = zinc_info ,
150107 )
151-
152- def _compile_analysis (analysis ):
153- return [
154- "--analysis" ,
155- "_{}" .format (analysis .label ),
156- analysis .analysis_store .path ,
157- ] + [jar .path for jar in analysis .jars ]
0 commit comments