diff options
author | mjhalupka <mjhalupka@google.com> | 2018-01-31 13:48:36 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-01-31 13:50:35 -0800 |
commit | 18e333f7c0b0cc8411feda24f07874eb6dd50467 (patch) | |
tree | 4ad6f9b8f5e7bba55d348fc435aa45bc8866688d /src/main/java/com/google/devtools/build/lib/skyframe/CompletionFunction.java | |
parent | 8098304ac8d0f339be14622d4781f9a0d0c47d53 (diff) |
Remove references to ConfiguredTarget.getTarget() in CompletionFunction.
PiperOrigin-RevId: 184040834
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe/CompletionFunction.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/skyframe/CompletionFunction.java | 59 |
1 files changed, 42 insertions, 17 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/CompletionFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/CompletionFunction.java index db8d44ccc2..f25c559ffb 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/CompletionFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/CompletionFunction.java @@ -29,6 +29,8 @@ import com.google.devtools.build.lib.collect.nestedset.NestedSet; import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; import com.google.devtools.build.lib.events.Event; import com.google.devtools.build.lib.events.ExtendedEventHandler; +import com.google.devtools.build.lib.packages.NoSuchTargetException; +import com.google.devtools.build.lib.packages.Target; import com.google.devtools.build.lib.skyframe.AspectCompletionValue.AspectCompletionKey; import com.google.devtools.build.lib.skyframe.AspectValue.AspectKey; import com.google.devtools.build.lib.skyframe.TargetCompletionValue.TargetCompletionKey; @@ -72,12 +74,11 @@ public final class CompletionFunction<TValue extends SkyValue, TResult extends S ArtifactsToBuild getAllArtifactsToBuild(TValue value, TopLevelArtifactContext context); /** Creates an event reporting an absent input artifact. */ - Event getRootCauseError(TValue value, Cause rootCause); + Event getRootCauseError(TValue value, Cause rootCause, Environment env); - /** - * Creates an error message reporting {@code missingCount} missing input files. - */ - MissingInputFileException getMissingFilesException(TValue value, int missingCount); + /** Creates an error message reporting {@code missingCount} missing input files. */ + MissingInputFileException getMissingFilesException( + TValue value, int missingCount, Environment env); /** * Creates a successful completion value. @@ -120,22 +121,45 @@ public final class CompletionFunction<TValue extends SkyValue, TResult extends S } @Override - public Event getRootCauseError(ConfiguredTargetValue ctValue, Cause rootCause) { + public Event getRootCauseError( + ConfiguredTargetValue ctValue, Cause rootCause, Environment env) { + Target target = null; + try { + target = + ((PackageValue) + env.getValue( + PackageValue.key( + ctValue.getConfiguredTarget().getLabel().getPackageIdentifier()))) + .getPackage() + .getTarget(ctValue.getConfiguredTarget().getLabel().getName()); + } catch (NoSuchTargetException | InterruptedException e) { + throw new IllegalStateException("Failed to retrieve target to get a root cause error."); + } return Event.error( - ctValue.getConfiguredTarget().getTarget().getLocation(), + target.getLocation(), String.format( "%s: missing input file '%s'", ctValue.getConfiguredTarget().getLabel(), rootCause)); } @Override public MissingInputFileException getMissingFilesException( - ConfiguredTargetValue value, int missingCount) { + ConfiguredTargetValue value, int missingCount, Environment env) { + Target target = null; + try { + target = + ((PackageValue) + env.getValue( + PackageValue.key( + value.getConfiguredTarget().getLabel().getPackageIdentifier()))) + .getPackage() + .getTarget(value.getConfiguredTarget().getLabel().getName()); + } catch (NoSuchTargetException | InterruptedException e) { + throw new IllegalStateException( + "Failed to retrieve target to create MissingFilesException."); + } return new MissingInputFileException( - value.getConfiguredTarget().getTarget().getLocation() - + " " - + missingCount - + " input file(s) do not exist", - value.getConfiguredTarget().getTarget().getLocation()); + target.getLocation() + " " + missingCount + " input file(s) do not exist", + target.getLocation()); } @Override @@ -194,7 +218,7 @@ public final class CompletionFunction<TValue extends SkyValue, TResult extends S } @Override - public Event getRootCauseError(AspectValue value, Cause rootCause) { + public Event getRootCauseError(AspectValue value, Cause rootCause, Environment env) { return Event.error( value.getLocation(), String.format( @@ -205,7 +229,8 @@ public final class CompletionFunction<TValue extends SkyValue, TResult extends S } @Override - public MissingInputFileException getMissingFilesException(AspectValue value, int missingCount) { + public MissingInputFileException getMissingFilesException( + AspectValue value, int missingCount, Environment env) { return new MissingInputFileException( value.getLabel() + ", aspect " @@ -286,7 +311,7 @@ public final class CompletionFunction<TValue extends SkyValue, TResult extends S if (inputOwner != null) { Cause cause = new LabelCause(inputOwner); rootCausesBuilder.add(cause); - env.getListener().handle(completor.getRootCauseError(value, cause)); + env.getListener().handle(completor.getRootCauseError(value, cause, env)); } } catch (ActionExecutionException e) { rootCausesBuilder.addTransitive(e.getRootCauses()); @@ -299,7 +324,7 @@ public final class CompletionFunction<TValue extends SkyValue, TResult extends S } if (missingCount > 0) { - missingInputException = completor.getMissingFilesException(value, missingCount); + missingInputException = completor.getMissingFilesException(value, missingCount, env); } NestedSet<Cause> rootCauses = rootCausesBuilder.build(); |