Search in sources :

Example 6 with TargetGraphAndBuildTargets

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);
}
Also used : TargetGraphAndBuildTargets(com.facebook.buck.rules.TargetGraphAndBuildTargets)

Example 7 with TargetGraphAndBuildTargets

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());
}
Also used : TargetGraphAndBuildTargets(com.facebook.buck.rules.TargetGraphAndBuildTargets) Test(org.junit.Test)

Example 8 with TargetGraphAndBuildTargets

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);
}
Also used : TargetGraphAndBuildTargets(com.facebook.buck.rules.TargetGraphAndBuildTargets) Test(org.junit.Test)

Example 9 with TargetGraphAndBuildTargets

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());
}
Also used : TargetGraphAndBuildTargets(com.facebook.buck.rules.TargetGraphAndBuildTargets) Test(org.junit.Test)

Example 10 with TargetGraphAndBuildTargets

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));
}
Also used : TargetNode(com.facebook.buck.rules.TargetNode) ImmutableSet(com.google.common.collect.ImmutableSet) BuildTarget(com.facebook.buck.model.BuildTarget) TargetGraphAndBuildTargets(com.facebook.buck.rules.TargetGraphAndBuildTargets)

Aggregations

TargetGraphAndBuildTargets (com.facebook.buck.rules.TargetGraphAndBuildTargets)17 Test (org.junit.Test)7 BuildTarget (com.facebook.buck.model.BuildTarget)5 BuildFileParseException (com.facebook.buck.json.BuildFileParseException)4 ParserConfig (com.facebook.buck.parser.ParserConfig)4 TargetNode (com.facebook.buck.rules.TargetNode)4 BuildTargetException (com.facebook.buck.model.BuildTargetException)3 ActionGraphAndResolver (com.facebook.buck.rules.ActionGraphAndResolver)3 TargetGraph (com.facebook.buck.rules.TargetGraph)3 VersionException (com.facebook.buck.versions.VersionException)3 Build (com.facebook.buck.command.Build)2 BuildEvent (com.facebook.buck.rules.BuildEvent)2 CachingBuildEngine (com.facebook.buck.rules.CachingBuildEngine)2 CachingBuildEngineBuckConfig (com.facebook.buck.rules.CachingBuildEngineBuckConfig)2 LocalCachingBuildEngineDelegate (com.facebook.buck.rules.LocalCachingBuildEngineDelegate)2 RuleKey (com.facebook.buck.rules.RuleKey)2 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)2 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)2 RuleKeyCacheRecycler (com.facebook.buck.rules.keys.RuleKeyCacheRecycler)2 RuleKeyFactoryManager (com.facebook.buck.rules.keys.RuleKeyFactoryManager)2