From 21add763b22dfdf0283480587bce3ea440fcad95 Mon Sep 17 00:00:00 2001 From: Jaden Peterson Date: Wed, 30 Oct 2024 12:39:51 -0400 Subject: [PATCH] Generate OutputGroupInfo in a new phase Previously, it was generated in the "javainfo" phase, which runs before the "depscheck" phase. "javainfo" can't run after "depscheck" because "compile" depends on "javainfo", and "depscheck" can't run before "javainfo" because it depends on "compile". --- docs/newdocs/phases.md | 1 + rules/private/phases.bzl | 3 +++ rules/private/phases/phase_javainfo.bzl | 13 ++----------- rules/private/phases/phase_outputgroupinfo.bzl | 8 ++++++++ rules/scala.bzl | 4 ++++ 5 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 rules/private/phases/phase_outputgroupinfo.bzl diff --git a/docs/newdocs/phases.md b/docs/newdocs/phases.md index 82cbc938..d4cb088b 100644 --- a/docs/newdocs/phases.md +++ b/docs/newdocs/phases.md @@ -15,6 +15,7 @@ def _scala_binary_implementation(ctx): ("ijinfo", _phase_ijinfo), ("binary_deployjar", _phase_binary_deployjar), ("binary_launcher", _phase_binary_launcher), + ("outputgroupinfo", _phase_outputgroupinfo), ("coda", _phase_coda), ]).coda ``` diff --git a/rules/private/phases.bzl b/rules/private/phases.bzl index a5167edd..5d0d02a2 100644 --- a/rules/private/phases.bzl +++ b/rules/private/phases.bzl @@ -9,6 +9,7 @@ load(":phases/phase_ijinfo.bzl", _phase_ijinfo = "phase_ijinfo") load(":phases/phase_javainfo.bzl", _phase_javainfo = "phase_javainfo") load(":phases/phase_library_defaultinfo.bzl", _phase_library_defaultinfo = "phase_library_defaultinfo") load(":phases/phase_noop.bzl", _phase_noop = "phase_noop") +load(":phases/phase_outputgroupinfo.bzl", _phase_outputgroupinfo = "phase_outputgroupinfo") load(":phases/phase_resources.bzl", _phase_resources = "phase_resources") load(":phases/phase_scalafmt_nondefault_outputs.bzl", _phase_scalafmt_nondefault_outputs = "phase_scalafmt_nondefault_outputs") load(":phases/phase_semanticdb.bzl", _phase_semanticdb = "phase_semanticdb") @@ -41,6 +42,8 @@ phase_library_defaultinfo = _phase_library_defaultinfo phase_noop = _phase_noop +phase_outputgroupinfo = _phase_outputgroupinfo + phase_resources = _phase_resources phase_scalafmt_nondefault_outputs = _phase_scalafmt_nondefault_outputs diff --git a/rules/private/phases/phase_javainfo.bzl b/rules/private/phases/phase_javainfo.bzl index 30c8f61a..e93e515a 100644 --- a/rules/private/phases/phase_javainfo.bzl +++ b/rules/private/phases/phase_javainfo.bzl @@ -17,7 +17,6 @@ load( # PHASE: javainfo # # Builds up the JavaInfo provider. And the ScalaInfo, while we're at it. -# And DefaultInfo. # def phase_javainfo(ctx, g): @@ -65,18 +64,10 @@ def phase_javainfo(ctx, g): scala_configuration = g.init.scala_configuration, ) - output_group_info = OutputGroupInfo( - **g.out.output_groups - ) - - g.out.providers.extend([ - output_group_info, - java_info, - scala_info, - ]) + g.out.providers.append(java_info) + g.out.providers.append(scala_info) return struct( java_info = java_info, - output_group_info = output_group_info, scala_info = scala_info, ) diff --git a/rules/private/phases/phase_outputgroupinfo.bzl b/rules/private/phases/phase_outputgroupinfo.bzl new file mode 100644 index 00000000..5a046d8e --- /dev/null +++ b/rules/private/phases/phase_outputgroupinfo.bzl @@ -0,0 +1,8 @@ +# +# PHASE: outputgroupinfo +# +# Generates the `OutputGroupInfo` provider. +# + +def phase_outputgroupinfo(ctx, g): + g.out.providers.append(OutputGroupInfo(**g.out.output_groups)) diff --git a/rules/scala.bzl b/rules/scala.bzl index 60e2f0b8..34c9ff36 100644 --- a/rules/scala.bzl +++ b/rules/scala.bzl @@ -29,6 +29,7 @@ load( _phase_javainfo = "phase_javainfo", _phase_library_defaultinfo = "phase_library_defaultinfo", _phase_noop = "phase_noop", + _phase_outputgroupinfo = "phase_outputgroupinfo", _phase_resources = "phase_resources", _phase_singlejar = "phase_singlejar", _phase_test_launcher = "phase_test_launcher", @@ -218,6 +219,7 @@ def _scala_library_implementation(ctx): ("coverage", _phase_coverage_jacoco), ("ijinfo", _phase_ijinfo), ("library_defaultinfo", _phase_library_defaultinfo), + ("outputgroupinfo", _phase_outputgroupinfo), ("coda", _phase_coda), ]).coda @@ -232,6 +234,7 @@ def _scala_binary_implementation(ctx): ("ijinfo", _phase_ijinfo), ("binary_deployjar", _phase_binary_deployjar), ("binary_launcher", _phase_binary_launcher), + ("outputgroupinfo", _phase_outputgroupinfo), ("coda", _phase_coda), ]).coda @@ -245,6 +248,7 @@ def _scala_test_implementation(ctx): ("coverage", _phase_coverage_jacoco), ("ijinfo", _phase_ijinfo), ("test_launcher", _phase_test_launcher), + ("outputgroupinfo", _phase_outputgroupinfo), ("coda", _phase_coda), ]).coda