Skip to content

Commit

Permalink
Don't include "phantom inputs" in singlejar actions
Browse files Browse the repository at this point in the history
This shouldn't be necessary, now that we're using validation actions.
  • Loading branch information
Jaden Peterson committed Oct 30, 2024
1 parent 6235cbf commit 99835eb
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 18 deletions.
5 changes: 1 addition & 4 deletions rules/common/private/utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ def action_singlejar(
ctx,
inputs,
output,
phantom_inputs = depset(),
main_class = None,
progress_message = None,
resources = {},
Expand All @@ -174,8 +173,6 @@ def action_singlejar(

if type(inputs) == "list":
inputs = depset(inputs)
if type(phantom_inputs) == "list":
phantom_inputs = depset(phantom_inputs)

args = ctx.actions.args()
args.add("--exclude_build_data")
Expand All @@ -190,7 +187,7 @@ def action_singlejar(
args.set_param_file_format("multiline")
args.use_param_file("@%s", use_always = True)

all_inputs = depset(resources.values(), transitive = [inputs, phantom_inputs])
all_inputs = depset(resources.values(), transitive = [inputs])

ctx.actions.run(
arguments = [args],
Expand Down
2 changes: 1 addition & 1 deletion rules/private/phases/phase_binary_launcher.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def phase_binary_launcher(ctx, g):

g.out.providers.append(DefaultInfo(
executable = ctx.outputs.bin,
files = depset([ctx.outputs.bin, ctx.outputs.jar]),
files = depset([ctx.outputs.bin, ctx.outputs.jar] + g.semanticdb.outputs),
runfiles = ctx.runfiles(
files = inputs + files,
transitive_files = depset(
Expand Down
2 changes: 1 addition & 1 deletion rules/private/phases/phase_library_defaultinfo.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

def phase_library_defaultinfo(ctx, g):
g.out.providers.append(DefaultInfo(
files = depset([ctx.outputs.jar]),
files = depset([ctx.outputs.jar] + g.semanticdb.outputs),
))
5 changes: 1 addition & 4 deletions rules/private/phases/phase_singlejar.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@ def phase_singlejar(ctx, g):
# cause the build to fail, cleanly, if any declared outputs are
# missing from previous phases.
inputs = [f for f in ctx.files.resource_jars if f.extension.lower() in ["jar"]]
phantom_inputs = []
for v in [getattr(g, k) for k in dir(g) if k not in ["to_json", "to_proto"]]:
if hasattr(v, "jar"):
jar = getattr(v, "jar")
inputs.append(jar)
if hasattr(v, "outputs"):
phantom_inputs.extend(getattr(v, "outputs"))

_action_singlejar(ctx, inputs, ctx.outputs.jar, phantom_inputs)
_action_singlejar(ctx, inputs, ctx.outputs.jar)
7 changes: 1 addition & 6 deletions rules/private/phases/phase_test_launcher.bzl
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
load("//rules/common:private/utils.bzl", _collect = "collect", _write_launcher = "write_launcher")
load(
"@rules_scala_annex//rules/private:coverage_replacements_provider.bzl",
_coverage_replacements_provider = "coverage_replacements_provider",
)
load(
"//rules/common:private/utils.bzl",
_action_singlejar = "action_singlejar",
_collect = "collect",
_write_launcher = "write_launcher",
)

#
# PHASE: test_launcher
Expand Down
4 changes: 4 additions & 0 deletions rules/scala.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ load(
_phase_noop = "phase_noop",
_phase_outputgroupinfo = "phase_outputgroupinfo",
_phase_resources = "phase_resources",
_phase_semanticdb = "phase_semanticdb",
_phase_singlejar = "phase_singlejar",
_phase_test_launcher = "phase_test_launcher",
_run_phases = "run_phases",
Expand Down Expand Up @@ -214,6 +215,7 @@ def _scala_library_implementation(ctx):
("resources", _phase_resources),
("classpaths", _phase_classpaths),
("javainfo", _phase_javainfo),
("semanticdb", _phase_semanticdb),
("compile", _phase_noop),
("singlejar", _phase_singlejar),
("coverage", _phase_coverage_jacoco),
Expand All @@ -228,6 +230,7 @@ def _scala_binary_implementation(ctx):
("resources", _phase_resources),
("classpaths", _phase_classpaths),
("javainfo", _phase_javainfo),
("semanticdb", _phase_semanticdb),
("compile", _phase_noop),
("singlejar", _phase_singlejar),
("coverage", _phase_coverage_jacoco),
Expand All @@ -243,6 +246,7 @@ def _scala_test_implementation(ctx):
("resources", _phase_resources),
("classpaths", _phase_classpaths),
("javainfo", _phase_javainfo),
("semanticdb", _phase_semanticdb),
("compile", _phase_noop),
("singlejar", _phase_singlejar),
("coverage", _phase_coverage_jacoco),
Expand Down
2 changes: 0 additions & 2 deletions rules/scala/private/provider.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ load(
load(
"//rules/private:phases.bzl",
_phase_bootstrap_compile = "phase_bootstrap_compile",
_phase_semanticdb = "phase_semanticdb",
_phase_zinc_compile = "phase_zinc_compile",
_phase_zinc_depscheck = "phase_zinc_depscheck",
)
Expand Down Expand Up @@ -60,7 +59,6 @@ def configure_zinc_scala_implementation(ctx):
_ScalaRulePhase(
phases = [
("=", "compile", "compile", _phase_zinc_compile),
("-", "compile", "semanticdb", _phase_semanticdb),
("+", "compile", "depscheck", _phase_zinc_depscheck),
],
),
Expand Down

0 comments on commit 99835eb

Please sign in to comment.