Skip to content

Commit 5aecfd9

Browse files
authored
Pass scalac as executable (#1121)
* Pass scalac as executable * Add scalac to tools maybe this will resolve runfiles * proto toolchain exposes ctx.attr.scalac.files_to_run * change scalac cfg host -> exec
1 parent 1d6cc4f commit 5aecfd9

File tree

5 files changed

+17
-21
lines changed

5 files changed

+17
-21
lines changed

scala/private/common_attributes.bzl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,10 @@ implicit_deps = {
100100
default = Label("@bazel_tools//tools/jdk:current_java_runtime"),
101101
),
102102
"_scalac": attr.label(
103-
default = Label(
104-
"@io_bazel_rules_scala//src/java/io/bazel/rulesscala/scalac",
105-
),
103+
executable = True,
104+
cfg = "exec",
105+
default = Label("@io_bazel_rules_scala//src/java/io/bazel/rulesscala/scalac"),
106+
allow_files = True,
106107
),
107108
"_exe": attr.label(
108109
executable = True,

scala/private/phases/phase_compile.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def _compile_or_empty(
204204
ctx.attr.print_compile_time,
205205
ctx.attr.expect_java_output,
206206
ctx.attr.scalac_jvm_flags,
207-
ctx.attr._scalac,
207+
ctx.executable._scalac,
208208
dependency_info,
209209
unused_dependency_checker_ignored_targets,
210210
)

scala/private/rule_impls.bzl

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,12 @@ DiagnosticsFile: {diagnostics_output}
177177
content = scalac_args + optional_scalac_args,
178178
)
179179

180-
scalac_inputs, _, scalac_input_manifests = ctx.resolve_command(
181-
tools = [scalac],
182-
)
183-
184180
outs = [output, statsfile, diagnosticsfile]
185181

186182
ins = (
187183
compiler_classpath_jars.to_list() + all_srcjars.to_list() + list(sources) +
188184
plugins_list + internal_plugin_jars + classpath_resources + resources +
189-
resource_jars + [manifest, argfile] + scalac_inputs
185+
resource_jars + [manifest, argfile]
190186
)
191187

192188
# scalac_jvm_flags passed in on the target override scalac_jvm_flags passed in on the
@@ -199,8 +195,7 @@ DiagnosticsFile: {diagnostics_output}
199195
ctx.actions.run(
200196
inputs = ins,
201197
outputs = outs,
202-
executable = scalac.files_to_run.executable,
203-
input_manifests = scalac_input_manifests,
198+
executable = scalac,
204199
mnemonic = "Scalac",
205200
progress_message = "scala %s" % target_label,
206201
execution_requirements = {"supports-workers": "1"},
@@ -222,8 +217,7 @@ DiagnosticsFile: {diagnostics_output}
222217
ctx.actions.run(
223218
inputs = ins,
224219
outputs = outs,
225-
executable = scalac.files_to_run.executable,
226-
input_manifests = scalac_input_manifests,
220+
executable = scalac,
227221
mnemonic = "Scalac",
228222
progress_message = "scala %s" % target_label,
229223
execution_requirements = {"supports-workers": "1"},

scala_proto/scala_proto_toolchain.bzl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def _scala_proto_toolchain_impl(ctx):
1010
blacklisted_protos = ctx.attr.blacklisted_protos,
1111
code_generator = ctx.attr.code_generator,
1212
extra_generator_dependencies = ctx.attr.extra_generator_dependencies,
13-
scalac = ctx.attr.scalac,
13+
scalac = ctx.attr.scalac.files_to_run,
1414
named_generators = ctx.attr.named_generators,
1515
)
1616
return [toolchain]
@@ -39,9 +39,10 @@ scala_proto_toolchain = rule(
3939
providers = [JavaInfo],
4040
),
4141
"scalac": attr.label(
42-
default = Label(
43-
"@io_bazel_rules_scala//src/java/io/bazel/rulesscala/scalac",
44-
),
42+
executable = True,
43+
cfg = "exec",
44+
default = Label("@io_bazel_rules_scala//src/java/io/bazel/rulesscala/scalac"),
45+
allow_files = True,
4546
),
4647
},
4748
)

twitter_scrooge/twitter_scrooge.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ def _compile_generated_scala(
284284
print_compile_time = False,
285285
expect_java_output = False,
286286
scalac_jvm_flags = [],
287-
scalac = ctx.attr._scalac,
287+
scalac = ctx.executable._scalac,
288288
dependency_info = legacy_unclear_dependency_info_for_protobuf_scrooge(ctx),
289289
unused_dependency_checker_ignored_targets = [],
290290
)
@@ -449,10 +449,10 @@ scrooge_scala_aspect = aspect(
449449
common_attrs,
450450
{
451451
"_scalac": attr.label(
452-
default = Label(
453-
"@io_bazel_rules_scala//src/java/io/bazel/rulesscala/scalac",
454-
),
452+
executable = True,
455453
cfg = "exec",
454+
default = Label("@io_bazel_rules_scala//src/java/io/bazel/rulesscala/scalac"),
455+
allow_files = True,
456456
),
457457
},
458458
),

0 commit comments

Comments
 (0)