use of com.google.devtools.build.lib.query2.engine.QueryEnvironment.Argument 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);
}
}
use of com.google.devtools.build.lib.query2.engine.QueryEnvironment.Argument in project bazel by bazelbuild.
the class QueryExpressionMapper method map.
public QueryExpression map(FunctionExpression functionExpression) {
boolean changed = false;
ImmutableList.Builder<Argument> mappedArgumentBuilder = ImmutableList.builder();
for (Argument argument : functionExpression.getArgs()) {
switch(argument.getType()) {
case EXPRESSION:
{
QueryExpression expr = argument.getExpression();
QueryExpression mappedExpression = expr.getMapped(this);
mappedArgumentBuilder.add(Argument.of(mappedExpression));
if (expr != mappedExpression) {
changed = true;
}
break;
}
default:
mappedArgumentBuilder.add(argument);
break;
}
}
return changed ? new FunctionExpression(functionExpression.getFunction(), mappedArgumentBuilder.build()) : functionExpression;
}
use of com.google.devtools.build.lib.query2.engine.QueryEnvironment.Argument in project bazel by bazelbuild.
the class JavaToolchainDataParser method parseBuildRuleProto.
private static JavaToolchainData parseBuildRuleProto(Build.Rule rule) {
String source = "";
String target = "";
ImmutableList<String> bootclasspath = ImmutableList.of();
ImmutableList<String> extclasspath = ImmutableList.of();
String encoding = "";
ImmutableList<String> xlint = ImmutableList.of();
ImmutableList<String> misc = ImmutableList.of();
ImmutableList<String> jvmOpts = ImmutableList.of();
SupportsWorkers javacSupportsWorkers = SupportsWorkers.NO;
for (Build.Attribute attribute : rule.getAttributeList()) {
switch(attribute.getName()) {
case "source_version":
source = attribute.getStringValue();
break;
case "target_version":
target = attribute.getStringValue();
break;
case "bootclasspath":
bootclasspath = ImmutableList.copyOf(attribute.getStringListValueList());
break;
case "extclasspath":
extclasspath = ImmutableList.copyOf(attribute.getStringListValueList());
break;
case "encoding":
encoding = attribute.getStringValue();
break;
case "xlint":
xlint = ImmutableList.copyOf(attribute.getStringListValueList());
break;
case "misc":
{
List<String> options = new ArrayList<>();
for (String option : attribute.getStringListValueList()) {
try {
ShellUtils.tokenize(options, option);
} catch (ShellUtils.TokenizationException e) {
// Tokenization failed; this likely means that the user
// did not want tokenization to happen on the argument.
// (see JavaHelper.tokenizeJavaOptions)
options.add(option);
}
}
misc = ImmutableList.copyOf(options);
break;
}
case "jvm_opts":
jvmOpts = ImmutableList.copyOf(attribute.getStringListValueList());
break;
case "javac_supports_workers":
if (attribute.getBooleanValue()) {
javacSupportsWorkers = SupportsWorkers.YES;
}
break;
}
}
return new JavaToolchainData(source, target, bootclasspath, extclasspath, encoding, xlint, misc, jvmOpts, javacSupportsWorkers);
}
Aggregations