Search in sources :

Example 6 with TargetGraphAndTargets

use of com.facebook.buck.rules.TargetGraphAndTargets in project buck by facebook.

the class ProjectCommandXcodeTest method testCreateTargetGraphWithoutTests.

@Test
public void testCreateTargetGraphWithoutTests() {
    TargetGraphAndTargets targetGraphAndTargets = ProjectCommandTests.createTargetGraph(targetGraph, ProjectCommand.Ide.XCODE, ImmutableSet.of(), /* withTests = */
    false, /* withDependenciesTests = */
    false);
    assertEquals(ImmutableSortedSet.<TargetNode<?, ?>>of(workspaceNode, fooBinNode, fooBinBinaryNode, fooLibNode, barLibNode, smallWorkspaceNode, bazLibNode, workspaceExtraTestNode), ImmutableSortedSet.copyOf(targetGraphAndTargets.getTargetGraph().getNodes()));
}
Also used : TargetGraphAndTargets(com.facebook.buck.rules.TargetGraphAndTargets) Test(org.junit.Test)

Example 7 with TargetGraphAndTargets

use of com.facebook.buck.rules.TargetGraphAndTargets in project buck by facebook.

the class ProjectCommandXcodeTest method testCreateTargetGraphForSliceWithTests.

@Test
public void testCreateTargetGraphForSliceWithTests() {
    TargetGraphAndTargets targetGraphAndTargets = ProjectCommandTests.createTargetGraph(targetGraph, ProjectCommand.Ide.XCODE, ImmutableSet.of(workspaceNode.getBuildTarget()), /* withTests = */
    true, /* withDependenciesTests */
    true);
    assertEquals(ImmutableSortedSet.<TargetNode<?, ?>>of(workspaceNode, fooBinNode, fooBinBinaryNode, fooLibNode, fooBinTestNode, fooTestNode, barLibNode, bazLibNode, workspaceExtraTestNode), ImmutableSortedSet.copyOf(targetGraphAndTargets.getTargetGraph().getNodes()));
}
Also used : TargetGraphAndTargets(com.facebook.buck.rules.TargetGraphAndTargets) Test(org.junit.Test)

Example 8 with TargetGraphAndTargets

use of com.facebook.buck.rules.TargetGraphAndTargets in project buck by facebook.

the class ProjectCommandXcodeTest method testCreateTargetGraphForSmallSliceWithTests.

@Test
public void testCreateTargetGraphForSmallSliceWithTests() {
    TargetGraphAndTargets targetGraphAndTargets = ProjectCommandTests.createTargetGraph(targetGraph, ProjectCommand.Ide.XCODE, ImmutableSet.of(smallWorkspaceNode.getBuildTarget()), /* withTests = */
    true, /* withDependenciesTests */
    true);
    assertEquals(ImmutableSortedSet.of(smallWorkspaceNode, bazLibNode, bazTestNode), ImmutableSortedSet.copyOf(targetGraphAndTargets.getTargetGraph().getNodes()));
}
Also used : TargetGraphAndTargets(com.facebook.buck.rules.TargetGraphAndTargets) Test(org.junit.Test)

Example 9 with TargetGraphAndTargets

use of com.facebook.buck.rules.TargetGraphAndTargets in project buck by facebook.

the class ProjectCommandXcodeTest method testCreateTargetGraphForSliceWithoutTests.

@Test
public void testCreateTargetGraphForSliceWithoutTests() {
    TargetGraphAndTargets targetGraphAndTargets = ProjectCommandTests.createTargetGraph(targetGraph, ProjectCommand.Ide.XCODE, ImmutableSet.of(workspaceNode.getBuildTarget()), /* withTests = */
    false, /* withDependenciesTests */
    false);
    assertEquals(ImmutableSortedSet.<TargetNode<?, ?>>of(workspaceNode, fooBinNode, fooBinBinaryNode, fooLibNode, barLibNode, workspaceExtraTestNode), ImmutableSortedSet.copyOf(targetGraphAndTargets.getTargetGraph().getNodes()));
}
Also used : TargetGraphAndTargets(com.facebook.buck.rules.TargetGraphAndTargets) Test(org.junit.Test)

Example 10 with TargetGraphAndTargets

use of com.facebook.buck.rules.TargetGraphAndTargets in project buck by facebook.

the class ProjectCommand method runWithoutHelp.

@Override
public int runWithoutHelp(CommandRunnerParams params) throws IOException, InterruptedException {
    int rc = runPreprocessScriptIfNeeded(params);
    if (rc != 0) {
        return rc;
    }
    Ide projectIde = getIdeFromBuckConfig(params.getBuckConfig()).orElse(null);
    boolean needsFullRecursiveParse = deprecatedIntelliJProjectGenerationEnabled && projectIde != Ide.XCODE;
    try (CommandThreadManager pool = new CommandThreadManager("Project", getConcurrencyLimit(params.getBuckConfig()))) {
        ImmutableSet<BuildTarget> passedInTargetsSet;
        TargetGraph projectGraph;
        List<String> targets = getArguments();
        if (projectIde != Ide.XCODE && !deprecatedIntelliJProjectGenerationEnabled && targets.isEmpty()) {
            targets = ImmutableList.of("//...");
        }
        try {
            ParserConfig parserConfig = params.getBuckConfig().getView(ParserConfig.class);
            passedInTargetsSet = ImmutableSet.copyOf(Iterables.concat(params.getParser().resolveTargetSpecs(params.getBuckEventBus(), params.getCell(), getEnableParserProfiling(), pool.getExecutor(), parseArgumentsAsTargetNodeSpecs(params.getBuckConfig(), targets), SpeculativeParsing.of(true), parserConfig.getDefaultFlavorsMode())));
            needsFullRecursiveParse = needsFullRecursiveParse || passedInTargetsSet.isEmpty();
            projectGraph = getProjectGraphForIde(params, pool.getExecutor(), passedInTargetsSet, needsFullRecursiveParse);
        } catch (BuildTargetException | BuildFileParseException | HumanReadableException e) {
            params.getBuckEventBus().post(ConsoleEvent.severe(MoreExceptions.getHumanReadableOrLocalizedMessage(e)));
            return 1;
        }
        projectIde = getIdeBasedOnPassedInTargetsAndProjectGraph(params.getBuckConfig(), passedInTargetsSet, Optional.of(projectGraph));
        if (projectIde == ProjectCommand.Ide.XCODE) {
            checkForAndKillXcodeIfRunning(params, getIdePrompt(params.getBuckConfig()));
        }
        ProjectPredicates projectPredicates = ProjectPredicates.forIde(projectIde);
        ImmutableSet<BuildTarget> graphRoots;
        if (passedInTargetsSet.isEmpty()) {
            graphRoots = getRootsFromPredicate(projectGraph, projectPredicates.getProjectRootsPredicate());
        } else if (projectIde == Ide.INTELLIJ && needsFullRecursiveParse) {
            ImmutableSet<BuildTarget> supplementalGraphRoots = getRootBuildTargetsForIntelliJ(Ide.INTELLIJ, projectGraph, projectPredicates);
            graphRoots = Sets.union(passedInTargetsSet, supplementalGraphRoots).immutableCopy();
        } else {
            graphRoots = passedInTargetsSet;
        }
        TargetGraphAndTargets targetGraphAndTargets;
        try {
            targetGraphAndTargets = createTargetGraph(params, projectGraph, graphRoots, projectPredicates.getAssociatedProjectPredicate(), isWithTests(params.getBuckConfig()), isWithDependenciesTests(params.getBuckConfig()), needsFullRecursiveParse, pool.getExecutor());
        } catch (BuildFileParseException | TargetGraph.NoSuchNodeException | BuildTargetException | HumanReadableException e) {
            params.getBuckEventBus().post(ConsoleEvent.severe(MoreExceptions.getHumanReadableOrLocalizedMessage(e)));
            return 1;
        }
        if (getDryRun()) {
            for (TargetNode<?, ?> targetNode : targetGraphAndTargets.getTargetGraph().getNodes()) {
                params.getConsole().getStdOut().println(targetNode.toString());
            }
            return 0;
        }
        params.getBuckEventBus().post(ProjectGenerationEvent.started());
        int result;
        try {
            switch(projectIde) {
                case INTELLIJ:
                    result = runIntellijProjectGenerator(params, projectGraph, targetGraphAndTargets, passedInTargetsSet);
                    break;
                case XCODE:
                    result = runXcodeProjectGenerator(params, pool.getExecutor(), targetGraphAndTargets, passedInTargetsSet);
                    break;
                default:
                    // unreachable
                    throw new IllegalStateException("'ide' should always be of type 'INTELLIJ' or 'XCODE'");
            }
        } finally {
            params.getBuckEventBus().post(ProjectGenerationEvent.finished());
        }
        return result;
    }
}
Also used : BuildTargetException(com.facebook.buck.model.BuildTargetException) TargetGraphAndTargets(com.facebook.buck.rules.TargetGraphAndTargets) TargetGraph(com.facebook.buck.rules.TargetGraph) BuildFileParseException(com.facebook.buck.json.BuildFileParseException) ImmutableSet(com.google.common.collect.ImmutableSet) BuildTarget(com.facebook.buck.model.BuildTarget) UnflavoredBuildTarget(com.facebook.buck.model.UnflavoredBuildTarget) HumanReadableException(com.facebook.buck.util.HumanReadableException) ParserConfig(com.facebook.buck.parser.ParserConfig)

Aggregations

TargetGraphAndTargets (com.facebook.buck.rules.TargetGraphAndTargets)14 Test (org.junit.Test)12 ProjectGenerator (com.facebook.buck.apple.project_generator.ProjectGenerator)1 BuildFileParseException (com.facebook.buck.json.BuildFileParseException)1 BuildTarget (com.facebook.buck.model.BuildTarget)1 BuildTargetException (com.facebook.buck.model.BuildTargetException)1 UnflavoredBuildTarget (com.facebook.buck.model.UnflavoredBuildTarget)1 ParserConfig (com.facebook.buck.parser.ParserConfig)1 TargetGraph (com.facebook.buck.rules.TargetGraph)1 HumanReadableException (com.facebook.buck.util.HumanReadableException)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Path (java.nio.file.Path)1 HashMap (java.util.HashMap)1