use of com.facebook.buck.rules.TargetGraphAndBuildTargets in project buck by facebook.
the class VersionedTargetGraphCache method getVersionedTargetGraph.
private VersionedTargetGraphCacheResult getVersionedTargetGraph(TargetGraphAndBuildTargets targetGraphAndBuildTargets, ImmutableMap<String, VersionUniverse> versionUniverses, ForkJoinPool pool) throws VersionException, InterruptedException {
// If new inputs match old ones, we can used the cached graph, if present.
VersionedTargetGraphInputs newInputs = VersionedTargetGraphInputs.of(targetGraphAndBuildTargets, versionUniverses);
if (cachedVersionedTargetGraph != null && newInputs.equals(cachedVersionedTargetGraph.getInputs())) {
return VersionedTargetGraphCacheResult.of(ResultType.HIT, cachedVersionedTargetGraph.getTargetGraphAndBuildTargets());
}
// Build and cache new versioned target graph.
ResultType resultType = cachedVersionedTargetGraph == null ? ResultType.EMPTY : ResultType.MISMATCH;
TargetGraphAndBuildTargets newVersionedTargetGraph = createdVersionedTargetGraph(targetGraphAndBuildTargets, versionUniverses, pool);
cachedVersionedTargetGraph = CachedVersionedTargetGraph.of(newInputs, newVersionedTargetGraph);
return VersionedTargetGraphCacheResult.of(resultType, newVersionedTargetGraph);
}
use of com.facebook.buck.rules.TargetGraphAndBuildTargets in project buck by facebook.
the class VersionedTargetGraphCacheTest method testVersionUniverseChangeCausesMiss.
@Test
public void testVersionUniverseChangeCausesMiss() throws Exception {
VersionedTargetGraphCache cache = new VersionedTargetGraphCache();
TargetGraphAndBuildTargets graph = createSimpleGraph();
ImmutableMap<String, VersionUniverse> firstVersionUniverses = ImmutableMap.of();
VersionedTargetGraphCacheResult firstResult = cache.getVersionedTargetGraph(BUS, graph, firstVersionUniverses, POOL);
assertEmpty(firstResult);
ImmutableMap<String, VersionUniverse> secondVersionUniverses = ImmutableMap.of("foo", VersionUniverse.of(ImmutableMap.of()));
VersionedTargetGraphCacheResult secondResult = cache.getVersionedTargetGraph(BUS, graph, secondVersionUniverses, POOL);
assertMismatch(secondResult, firstResult.getTargetGraphAndBuildTargets());
}
use of com.facebook.buck.rules.TargetGraphAndBuildTargets in project buck by facebook.
the class VersionedTargetGraphCacheTest method testEmpty.
@Test
public void testEmpty() throws Exception {
VersionedTargetGraphCache cache = new VersionedTargetGraphCache();
TargetGraphAndBuildTargets graph = createSimpleGraph();
VersionedTargetGraphCacheResult result = cache.getVersionedTargetGraph(BUS, graph, ImmutableMap.of(), POOL);
assertEmpty(result);
}
use of com.facebook.buck.rules.TargetGraphAndBuildTargets in project buck by facebook.
the class VersionedTargetGraphCacheTest method testGraphChangeCausesMiss.
@Test
public void testGraphChangeCausesMiss() throws Exception {
VersionedTargetGraphCache cache = new VersionedTargetGraphCache();
TargetGraphAndBuildTargets firstGraph = createSimpleGraph();
VersionedTargetGraphCacheResult firstResult = cache.getVersionedTargetGraph(BUS, firstGraph, ImmutableMap.of(), POOL);
assertEmpty(firstResult);
TargetGraphAndBuildTargets secondGraph = createSimpleGraph();
VersionedTargetGraphCacheResult secondResult = cache.getVersionedTargetGraph(BUS, secondGraph, ImmutableMap.of(), POOL);
assertMismatch(secondResult, firstResult.getTargetGraphAndBuildTargets());
}
use of com.facebook.buck.rules.TargetGraphAndBuildTargets in project buck by facebook.
the class TargetsCommand method runWithExecutor.
private int runWithExecutor(CommandRunnerParams params, ListeningExecutorService executor) throws IOException, InterruptedException, BuildFileParseException, BuildTargetException, CycleException, VersionException {
Optional<ImmutableSet<Class<? extends Description<?>>>> descriptionClasses = getDescriptionClassFromParams(params);
if (!descriptionClasses.isPresent()) {
return 1;
}
if (isShowCellPath() || isShowOutput() || isShowFullOutput() || isShowRuleKey() || isShowTargetHash()) {
ImmutableMap<BuildTarget, ShowOptions> showRulesResult;
TargetGraphAndBuildTargets targetGraphAndBuildTargetsForShowRules = buildTargetGraphAndTargetsForShowRules(params, executor, descriptionClasses);
boolean useVersioning = isShowRuleKey() || isShowOutput() || isShowFullOutput() ? params.getBuckConfig().getBuildVersions() : params.getBuckConfig().getTargetsVersions();
targetGraphAndBuildTargetsForShowRules = useVersioning ? toVersionedTargetGraph(params, targetGraphAndBuildTargetsForShowRules) : targetGraphAndBuildTargetsForShowRules;
showRulesResult = computeShowRules(params, executor, TargetGraphAndTargetNodes.fromTargetGraphAndBuildTargets(targetGraphAndBuildTargetsForShowRules));
if (shouldUseJsonFormat()) {
Iterable<TargetNode<?, ?>> matchingNodes = targetGraphAndBuildTargetsForShowRules.getTargetGraph().getAll(targetGraphAndBuildTargetsForShowRules.getBuildTargets());
printJsonForTargets(params, executor, matchingNodes, showRulesResult, getOutputAttributes());
} else {
printShowRules(showRulesResult, params);
}
return 0;
}
return printResults(params, executor, getMatchingNodes(params, buildTargetGraphAndTargets(params, executor), descriptionClasses));
}
Aggregations