Search in sources :

Example 1 with TransitiveTraversalValue

use of com.google.devtools.build.lib.skyframe.TransitiveTraversalValue in project bazel by bazelbuild.

the class SkyQueryEnvironment method buildTransitiveClosure.

@Override
public void buildTransitiveClosure(QueryExpression caller, Set<Target> targets, int maxDepth) throws QueryException, InterruptedException {
    // Everything has already been loaded, so here we just check for errors so that we can
    // pre-emptively throw/report if needed.
    Iterable<SkyKey> transitiveTraversalKeys = makeTransitiveTraversalKeys(targets);
    ImmutableList.Builder<String> errorMessagesBuilder = ImmutableList.builder();
    // First, look for errors in the successfully evaluated TransitiveTraversalValues. They may
    // have encountered errors that they were able to recover from.
    Set<Entry<SkyKey, SkyValue>> successfulEntries = graph.getSuccessfulValues(transitiveTraversalKeys).entrySet();
    Builder<SkyKey> successfulKeysBuilder = ImmutableSet.builder();
    for (Entry<SkyKey, SkyValue> successfulEntry : successfulEntries) {
        successfulKeysBuilder.add(successfulEntry.getKey());
        TransitiveTraversalValue value = (TransitiveTraversalValue) successfulEntry.getValue();
        String firstErrorMessage = value.getFirstErrorMessage();
        if (firstErrorMessage != null) {
            errorMessagesBuilder.add(firstErrorMessage);
        }
    }
    ImmutableSet<SkyKey> successfulKeys = successfulKeysBuilder.build();
    // Next, look for errors from the unsuccessfully evaluated TransitiveTraversal skyfunctions.
    Iterable<SkyKey> unsuccessfulKeys = Iterables.filter(transitiveTraversalKeys, Predicates.not(Predicates.in(successfulKeys)));
    Set<Entry<SkyKey, Exception>> errorEntries = graph.getMissingAndExceptions(unsuccessfulKeys).entrySet();
    for (Map.Entry<SkyKey, Exception> entry : errorEntries) {
        if (entry.getValue() == null) {
            // Targets may be in the graph because they are not in the universe or depend on cycles.
            eventHandler.handle(Event.warn(entry.getKey().argument() + " does not exist in graph"));
        } else {
            errorMessagesBuilder.add(entry.getValue().getMessage());
        }
    }
    // Lastly, report all found errors.
    ImmutableList<String> errorMessages = errorMessagesBuilder.build();
    for (String errorMessage : errorMessages) {
        reportBuildFileError(caller, errorMessage);
    }
}
Also used : SkyKey(com.google.devtools.build.skyframe.SkyKey) ImmutableList(com.google.common.collect.ImmutableList) LabelSyntaxException(com.google.devtools.build.lib.cmdline.LabelSyntaxException) IOException(java.io.IOException) TargetParsingException(com.google.devtools.build.lib.cmdline.TargetParsingException) BuildFileContainsErrorsException(com.google.devtools.build.lib.packages.BuildFileContainsErrorsException) NoSuchThingException(com.google.devtools.build.lib.packages.NoSuchThingException) QueryException(com.google.devtools.build.lib.query2.engine.QueryException) NoSuchPackageException(com.google.devtools.build.lib.packages.NoSuchPackageException) NoSuchTargetException(com.google.devtools.build.lib.packages.NoSuchTargetException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) SkyValue(com.google.devtools.build.skyframe.SkyValue) Entry(java.util.Map.Entry) TransitiveTraversalValue(com.google.devtools.build.lib.skyframe.TransitiveTraversalValue) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 LabelSyntaxException (com.google.devtools.build.lib.cmdline.LabelSyntaxException)1 TargetParsingException (com.google.devtools.build.lib.cmdline.TargetParsingException)1 BuildFileContainsErrorsException (com.google.devtools.build.lib.packages.BuildFileContainsErrorsException)1 NoSuchPackageException (com.google.devtools.build.lib.packages.NoSuchPackageException)1 NoSuchTargetException (com.google.devtools.build.lib.packages.NoSuchTargetException)1 NoSuchThingException (com.google.devtools.build.lib.packages.NoSuchThingException)1 QueryException (com.google.devtools.build.lib.query2.engine.QueryException)1 TransitiveTraversalValue (com.google.devtools.build.lib.skyframe.TransitiveTraversalValue)1 SkyKey (com.google.devtools.build.skyframe.SkyKey)1 SkyValue (com.google.devtools.build.skyframe.SkyValue)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1