use of com.google.devtools.build.lib.pkgcache.CompileOneDependencyTransformer in project bazel by bazelbuild.
the class LegacyLoadingPhaseRunner method getTargetsToBuild.
/**
* Interpret the command-line arguments.
*
* @param targetPatterns the list of command-line target patterns specified by the user
* @param compileOneDependency if true, enables alternative interpretation of targetPatterns; see
* {@link LoadingOptions#compileOneDependency}
* @throws TargetParsingException if parsing failed and !keepGoing
*/
private ResolvedTargets<Target> getTargetsToBuild(ExtendedEventHandler eventHandler, List<String> targetPatterns, boolean compileOneDependency, List<String> buildTagFilterList, boolean keepGoing) throws TargetParsingException, InterruptedException {
ResolvedTargets<Target> evaluated = targetPatternEvaluator.parseTargetPatternList(eventHandler, targetPatterns, FilteringPolicies.FILTER_MANUAL, keepGoing);
ResolvedTargets<Target> result = ResolvedTargets.<Target>builder().merge(evaluated).filter(TargetUtils.tagFilter(buildTagFilterList)).build();
if (compileOneDependency) {
return new CompileOneDependencyTransformer(packageManager).transformCompileOneDependency(eventHandler, result);
}
return result;
}
use of com.google.devtools.build.lib.pkgcache.CompileOneDependencyTransformer in project bazel by bazelbuild.
the class TargetPatternPhaseFunction method getTargetsToBuild.
/**
* Interpret the command-line arguments.
*
* @param options the command-line arguments in structured form
*/
private static ResolvedTargets<Target> getTargetsToBuild(Environment env, TargetPatternList options) throws InterruptedException {
List<SkyKey> patternSkyKeys = new ArrayList<>();
for (TargetPatternSkyKeyOrException keyOrException : TargetPatternValue.keys(options.getTargetPatterns(), FilteringPolicies.FILTER_MANUAL, options.getOffset())) {
try {
patternSkyKeys.add(keyOrException.getSkyKey());
} catch (TargetParsingException e) {
// Skip.
}
}
Map<SkyKey, ValueOrException<TargetParsingException>> resolvedPatterns = env.getValuesOrThrow(patternSkyKeys, TargetParsingException.class);
if (env.valuesMissing()) {
return null;
}
ResolvedTargets.Builder<Target> builder = ResolvedTargets.builder();
for (SkyKey key : patternSkyKeys) {
TargetPatternKey pattern = (TargetPatternKey) key.argument();
TargetPatternValue value;
try {
value = (TargetPatternValue) resolvedPatterns.get(key).get();
} catch (TargetParsingException e) {
// TODO(ulfjack): Report to EventBus.
String rawPattern = pattern.getPattern();
String errorMessage = e.getMessage();
env.getListener().handle(Event.error("Skipping '" + rawPattern + "': " + errorMessage));
builder.setError();
continue;
}
// TODO(ulfjack): This is terribly inefficient.
ResolvedTargets<Target> asTargets = TestSuiteExpansionFunction.labelsToTargets(env, value.getTargets().getTargets(), value.getTargets().hasError());
if (pattern.isNegative()) {
builder.filter(Predicates.not(Predicates.in(asTargets.getTargets())));
} else {
builder.merge(asTargets);
}
}
ResolvedTargets<Target> result = builder.filter(TargetUtils.tagFilter(options.getBuildTargetFilter())).build();
if (options.getCompileOneDependency()) {
TargetProvider targetProvider = new EnvironmentBackedRecursivePackageProvider(env);
try {
return new CompileOneDependencyTransformer(targetProvider).transformCompileOneDependency(env.getListener(), result);
} catch (MissingDepException e) {
return null;
} catch (TargetParsingException e) {
env.getListener().handle(Event.error(e.getMessage()));
return ResolvedTargets.failed();
}
}
return result;
}
Aggregations