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()));
}
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()));
}
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()));
}
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()));
}
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;
}
}
Aggregations