From 99835eb2a83bcf393604dce4c60d17ab4950db48 Mon Sep 17 00:00:00 2001 From: Jaden Peterson Date: Wed, 30 Oct 2024 13:11:27 -0400 Subject: [PATCH] Don't include "phantom inputs" in singlejar actions This shouldn't be necessary, now that we're using validation actions. --- rules/common/private/utils.bzl | 5 +---- rules/private/phases/phase_binary_launcher.bzl | 2 +- rules/private/phases/phase_library_defaultinfo.bzl | 2 +- rules/private/phases/phase_singlejar.bzl | 5 +---- rules/private/phases/phase_test_launcher.bzl | 7 +------ rules/scala.bzl | 4 ++++ rules/scala/private/provider.bzl | 2 -- 7 files changed, 9 insertions(+), 18 deletions(-) diff --git a/rules/common/private/utils.bzl b/rules/common/private/utils.bzl index b2f044d9f..a2df3166b 100644 --- a/rules/common/private/utils.bzl +++ b/rules/common/private/utils.bzl @@ -162,7 +162,6 @@ def action_singlejar( ctx, inputs, output, - phantom_inputs = depset(), main_class = None, progress_message = None, resources = {}, @@ -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") @@ -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], diff --git a/rules/private/phases/phase_binary_launcher.bzl b/rules/private/phases/phase_binary_launcher.bzl index 5d969ceaf..256664a49 100644 --- a/rules/private/phases/phase_binary_launcher.bzl +++ b/rules/private/phases/phase_binary_launcher.bzl @@ -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( diff --git a/rules/private/phases/phase_library_defaultinfo.bzl b/rules/private/phases/phase_library_defaultinfo.bzl index 3a3ca8bfb..029dfdfc8 100644 --- a/rules/private/phases/phase_library_defaultinfo.bzl +++ b/rules/private/phases/phase_library_defaultinfo.bzl @@ -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), )) diff --git a/rules/private/phases/phase_singlejar.bzl b/rules/private/phases/phase_singlejar.bzl index b12d6b505..4bcbc1cf8 100644 --- a/rules/private/phases/phase_singlejar.bzl +++ b/rules/private/phases/phase_singlejar.bzl @@ -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) diff --git a/rules/private/phases/phase_test_launcher.bzl b/rules/private/phases/phase_test_launcher.bzl index 11854c695..fcfd4cf35 100644 --- a/rules/private/phases/phase_test_launcher.bzl +++ b/rules/private/phases/phase_test_launcher.bzl @@ -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 diff --git a/rules/scala.bzl b/rules/scala.bzl index 34c9ff36c..e9b7ec713 100644 --- a/rules/scala.bzl +++ b/rules/scala.bzl @@ -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", @@ -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), @@ -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), @@ -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), diff --git a/rules/scala/private/provider.bzl b/rules/scala/private/provider.bzl index f377e3083..ea82132a7 100644 --- a/rules/scala/private/provider.bzl +++ b/rules/scala/private/provider.bzl @@ -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", ) @@ -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), ], ),