use of com.facebook.buck.io.AlwaysFoundExecutableFinder in project buck by facebook.
the class WorkspaceAndProjectGeneratorTest method workspaceAndProjectsShouldDiscoverDependenciesAndTests.
@Test
public void workspaceAndProjectsShouldDiscoverDependenciesAndTests() throws IOException, InterruptedException {
WorkspaceAndProjectGenerator generator = new WorkspaceAndProjectGenerator(rootCell, targetGraph, workspaceNode.getConstructorArg(), workspaceNode.getBuildTarget(), ImmutableSet.of(ProjectGenerator.Option.INCLUDE_TESTS, ProjectGenerator.Option.INCLUDE_DEPENDENCIES_TESTS), false, /* combinedProject */
false, /* buildWithBuck */
ImmutableList.of(), Optional.empty(), false, /* parallelizeBuild */
new AlwaysFoundExecutableFinder(), ImmutableMap.of(), PLATFORMS, DEFAULT_PLATFORM, "BUCK", getBuildRuleResolverForNodeFunction(targetGraph), getFakeBuckEventBus(), halideBuckConfig, cxxBuckConfig, appleConfig, swiftBuckConfig);
Map<Path, ProjectGenerator> projectGenerators = new HashMap<>();
generator.generateWorkspaceAndDependentProjects(projectGenerators, MoreExecutors.newDirectExecutorService());
ProjectGenerator fooProjectGenerator = projectGenerators.get(Paths.get("foo"));
ProjectGenerator barProjectGenerator = projectGenerators.get(Paths.get("bar"));
ProjectGenerator bazProjectGenerator = projectGenerators.get(Paths.get("baz"));
ProjectGenerator quxProjectGenerator = projectGenerators.get(Paths.get("qux"));
assertNull("The Qux project should not be generated at all", quxProjectGenerator);
assertNotNull("The Foo project should have been generated", fooProjectGenerator);
assertNotNull("The Bar project should have been generated", barProjectGenerator);
assertNotNull("The Baz project should have been generated", bazProjectGenerator);
ProjectGeneratorTestUtils.assertTargetExistsAndReturnTarget(fooProjectGenerator.getGeneratedProject(), "//foo:bin");
ProjectGeneratorTestUtils.assertTargetExistsAndReturnTarget(fooProjectGenerator.getGeneratedProject(), "//foo:lib");
ProjectGeneratorTestUtils.assertTargetExistsAndReturnTarget(fooProjectGenerator.getGeneratedProject(), "//foo:bin-xctest");
ProjectGeneratorTestUtils.assertTargetExistsAndReturnTarget(fooProjectGenerator.getGeneratedProject(), "//foo:lib-xctest");
ProjectGeneratorTestUtils.assertTargetExistsAndReturnTarget(barProjectGenerator.getGeneratedProject(), "//bar:lib");
ProjectGeneratorTestUtils.assertTargetExistsAndReturnTarget(bazProjectGenerator.getGeneratedProject(), "//baz:lib");
}
use of com.facebook.buck.io.AlwaysFoundExecutableFinder in project buck by facebook.
the class WorkspaceAndProjectGeneratorTest method targetsForWorkspaceWithExtraSchemes.
@Test
public void targetsForWorkspaceWithExtraSchemes() throws IOException, InterruptedException {
setUpWorkspaceWithSchemeAndProjects();
WorkspaceAndProjectGenerator generator = new WorkspaceAndProjectGenerator(rootCell, targetGraph, workspaceWithExtraSchemeNode.getConstructorArg(), workspaceWithExtraSchemeNode.getBuildTarget(), ImmutableSet.of(ProjectGenerator.Option.INCLUDE_TESTS, ProjectGenerator.Option.INCLUDE_DEPENDENCIES_TESTS), false, /* combinedProject */
false, /* buildWithBuck */
ImmutableList.of(), Optional.empty(), false, /* parallelizeBuild */
new AlwaysFoundExecutableFinder(), ImmutableMap.of(), PLATFORMS, DEFAULT_PLATFORM, "BUCK", getBuildRuleResolverForNodeFunction(targetGraph), getFakeBuckEventBus(), halideBuckConfig, cxxBuckConfig, appleConfig, swiftBuckConfig);
Map<Path, ProjectGenerator> projectGenerators = new HashMap<>();
generator.generateWorkspaceAndDependentProjects(projectGenerators, MoreExecutors.newDirectExecutorService());
ProjectGenerator fooProjectGenerator = projectGenerators.get(Paths.get("foo"));
ProjectGenerator barProjectGenerator = projectGenerators.get(Paths.get("bar"));
ProjectGenerator bazProjectGenerator = projectGenerators.get(Paths.get("baz"));
ProjectGenerator quxProjectGenerator = projectGenerators.get(Paths.get("qux"));
assertNotNull("The Qux project should have been generated", quxProjectGenerator);
assertNotNull("The Foo project should have been generated", fooProjectGenerator);
assertNotNull("The Bar project should have been generated", barProjectGenerator);
assertNotNull("The Baz project should have been generated", bazProjectGenerator);
ProjectGeneratorTestUtils.assertTargetExistsAndReturnTarget(fooProjectGenerator.getGeneratedProject(), "//foo:FooBin");
ProjectGeneratorTestUtils.assertTargetExistsAndReturnTarget(fooProjectGenerator.getGeneratedProject(), "//foo:FooLib");
ProjectGeneratorTestUtils.assertTargetExistsAndReturnTarget(fooProjectGenerator.getGeneratedProject(), "//foo:FooBinTest");
ProjectGeneratorTestUtils.assertTargetExistsAndReturnTarget(fooProjectGenerator.getGeneratedProject(), "//foo:FooLibTest");
ProjectGeneratorTestUtils.assertTargetExistsAndReturnTarget(barProjectGenerator.getGeneratedProject(), "//bar:BarLib");
ProjectGeneratorTestUtils.assertTargetExistsAndReturnTarget(bazProjectGenerator.getGeneratedProject(), "//baz:BazLib");
ProjectGeneratorTestUtils.assertTargetExistsAndReturnTarget(quxProjectGenerator.getGeneratedProject(), "//qux:QuxBin");
XCScheme mainScheme = generator.getSchemeGenerators().get("workspace").getOutputScheme().get();
XCScheme.BuildAction mainSchemeBuildAction = mainScheme.getBuildAction().get();
// I wish we could use Hamcrest contains() here, but we hit
// https://code.google.com/p/hamcrest/issues/detail?id=190 if we do that.
assertThat(mainSchemeBuildAction.getBuildActionEntries(), hasSize(2));
assertThat(mainSchemeBuildAction.getBuildActionEntries().get(0), withNameAndBuildingFor("BarLib", equalTo(XCScheme.BuildActionEntry.BuildFor.DEFAULT)));
assertThat(mainSchemeBuildAction.getBuildActionEntries().get(1), withNameAndBuildingFor("QuxBin", equalTo(XCScheme.BuildActionEntry.BuildFor.DEFAULT)));
XCScheme fooScheme = generator.getSchemeGenerators().get("FooScheme").getOutputScheme().get();
XCScheme.BuildAction fooSchemeBuildAction = fooScheme.getBuildAction().get();
assertThat(fooSchemeBuildAction.getBuildActionEntries(), hasSize(6));
assertThat(fooSchemeBuildAction.getBuildActionEntries().get(0), withNameAndBuildingFor("BarLib", equalTo(XCScheme.BuildActionEntry.BuildFor.DEFAULT)));
assertThat(fooSchemeBuildAction.getBuildActionEntries().get(1), withNameAndBuildingFor("FooLib", equalTo(XCScheme.BuildActionEntry.BuildFor.DEFAULT)));
assertThat(fooSchemeBuildAction.getBuildActionEntries().get(2), withNameAndBuildingFor("FooBin", equalTo(XCScheme.BuildActionEntry.BuildFor.DEFAULT)));
assertThat(fooSchemeBuildAction.getBuildActionEntries().get(3), withNameAndBuildingFor("BazLib", equalTo(XCScheme.BuildActionEntry.BuildFor.TEST_ONLY)));
assertThat(fooSchemeBuildAction.getBuildActionEntries().get(4), withNameAndBuildingFor("FooLibTest", equalTo(XCScheme.BuildActionEntry.BuildFor.TEST_ONLY)));
assertThat(fooSchemeBuildAction.getBuildActionEntries().get(5), withNameAndBuildingFor("FooBinTest", equalTo(XCScheme.BuildActionEntry.BuildFor.TEST_ONLY)));
}
use of com.facebook.buck.io.AlwaysFoundExecutableFinder in project buck by facebook.
the class WorkspaceAndProjectGeneratorTest method buildWithBuck.
@Test
public void buildWithBuck() throws IOException, InterruptedException {
Optional<Path> buck = new ExecutableFinder().getOptionalExecutable(Paths.get("buck"), ImmutableMap.of());
assumeThat(buck.isPresent(), is(true));
WorkspaceAndProjectGenerator generator = new WorkspaceAndProjectGenerator(rootCell, targetGraph, workspaceNode.getConstructorArg(), workspaceNode.getBuildTarget(), ImmutableSet.of(ProjectGenerator.Option.INCLUDE_TESTS, ProjectGenerator.Option.INCLUDE_DEPENDENCIES_TESTS), false, /* combinedProject */
true, /* buildWithBuck */
ImmutableList.of(), Optional.empty(), false, /* parallelizeBuild */
new AlwaysFoundExecutableFinder(), ImmutableMap.of(), PLATFORMS, DEFAULT_PLATFORM, "BUCK", getBuildRuleResolverForNodeFunction(targetGraph), getFakeBuckEventBus(), halideBuckConfig, cxxBuckConfig, appleConfig, swiftBuckConfig);
Map<Path, ProjectGenerator> projectGenerators = new HashMap<>();
generator.generateWorkspaceAndDependentProjects(projectGenerators, MoreExecutors.newDirectExecutorService());
ProjectGenerator fooProjectGenerator = projectGenerators.get(Paths.get("foo"));
assertThat(fooProjectGenerator, is(notNullValue()));
PBXTarget buildWithBuckTarget = null;
for (PBXTarget target : fooProjectGenerator.getGeneratedProject().getTargets()) {
if (target.getProductName() != null && target.getProductName().endsWith("-Buck")) {
buildWithBuckTarget = target;
break;
}
}
assertThat(buildWithBuckTarget, is(notNullValue()));
assertThat(buildWithBuckTarget, is(instanceOf(PBXAggregateTarget.class)));
String gid = buildWithBuckTarget.getGlobalID();
Optional<XCScheme> scheme = Iterables.getOnlyElement(generator.getSchemeGenerators().values()).getOutputScheme();
assertThat(scheme.isPresent(), is(true));
XCScheme.BuildableReference buildWithBuckBuildableReference = null;
for (XCScheme.BuildActionEntry buildActionEntry : scheme.get().getBuildAction().get().getBuildActionEntries()) {
XCScheme.BuildableReference buildableReference = buildActionEntry.getBuildableReference();
if (buildableReference.getBlueprintIdentifier().equals(gid)) {
buildWithBuckBuildableReference = buildableReference;
}
}
assertThat(buildWithBuckBuildableReference, is(notNullValue()));
assertThat(buildWithBuckBuildableReference.getBuildableName(), equalTo("//foo:bin-Buck"));
}
use of com.facebook.buck.io.AlwaysFoundExecutableFinder in project buck by facebook.
the class WorkspaceAndProjectGeneratorTest method workspaceAndProjectsWithoutTests.
@Test
public void workspaceAndProjectsWithoutTests() throws IOException, InterruptedException {
WorkspaceAndProjectGenerator generator = new WorkspaceAndProjectGenerator(rootCell, targetGraph, workspaceNode.getConstructorArg(), workspaceNode.getBuildTarget(), ImmutableSet.of(), false, /* combinedProject */
false, /* buildWithBuck */
ImmutableList.of(), Optional.empty(), false, /* parallelizeBuild */
new AlwaysFoundExecutableFinder(), ImmutableMap.of(), PLATFORMS, DEFAULT_PLATFORM, "BUCK", getBuildRuleResolverForNodeFunction(targetGraph), getFakeBuckEventBus(), halideBuckConfig, cxxBuckConfig, appleConfig, swiftBuckConfig);
Map<Path, ProjectGenerator> projectGenerators = new HashMap<>();
generator.generateWorkspaceAndDependentProjects(projectGenerators, MoreExecutors.newDirectExecutorService());
ProjectGenerator fooProjectGenerator = projectGenerators.get(Paths.get("foo"));
ProjectGenerator barProjectGenerator = projectGenerators.get(Paths.get("bar"));
ProjectGenerator bazProjectGenerator = projectGenerators.get(Paths.get("baz"));
ProjectGenerator quxProjectGenerator = projectGenerators.get(Paths.get("qux"));
assertNull("The Qux project should not be generated at all", quxProjectGenerator);
assertNull("The Baz project should not be generated at all", bazProjectGenerator);
assertNotNull("The Foo project should have been generated", fooProjectGenerator);
assertNotNull("The Bar project should have been generated", barProjectGenerator);
ProjectGeneratorTestUtils.assertTargetExistsAndReturnTarget(fooProjectGenerator.getGeneratedProject(), "//foo:bin");
ProjectGeneratorTestUtils.assertTargetExistsAndReturnTarget(fooProjectGenerator.getGeneratedProject(), "//foo:lib");
ProjectGeneratorTestUtils.assertTargetExistsAndReturnTarget(barProjectGenerator.getGeneratedProject(), "//bar:lib");
}
use of com.facebook.buck.io.AlwaysFoundExecutableFinder in project buck by facebook.
the class WorkspaceAndProjectGeneratorTest method requiredBuildTargets.
@Test
public void requiredBuildTargets() throws IOException, InterruptedException {
BuildTarget genruleTarget = BuildTarget.builder(rootCell.getRoot(), "//foo", "gen").build();
TargetNode<GenruleDescription.Arg, ?> genrule = GenruleBuilder.newGenruleBuilder(genruleTarget).setOut("source.m").build();
BuildTarget libraryTarget = BuildTarget.builder(rootCell.getRoot(), "//foo", "lib").build();
TargetNode<AppleLibraryDescription.Arg, ?> library = AppleLibraryBuilder.createBuilder(libraryTarget).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new DefaultBuildTargetSourcePath(genruleTarget)))).build();
TargetNode<XcodeWorkspaceConfigDescription.Arg, ?> workspaceNode = XcodeWorkspaceConfigBuilder.createBuilder(BuildTarget.builder(rootCell.getRoot(), "//foo", "workspace").build()).setSrcTarget(Optional.of(libraryTarget)).build();
TargetGraph targetGraph = TargetGraphFactory.newInstance(genrule, library, workspaceNode);
WorkspaceAndProjectGenerator generator = new WorkspaceAndProjectGenerator(rootCell, targetGraph, workspaceNode.getConstructorArg(), workspaceNode.getBuildTarget(), ImmutableSet.of(), false, /* combinedProject */
false, /* buildWithBuck */
ImmutableList.of(), Optional.empty(), false, /* parallelizeBuild */
new AlwaysFoundExecutableFinder(), ImmutableMap.of(), PLATFORMS, DEFAULT_PLATFORM, "BUCK", getBuildRuleResolverForNodeFunction(targetGraph), getFakeBuckEventBus(), halideBuckConfig, cxxBuckConfig, appleConfig, swiftBuckConfig);
Map<Path, ProjectGenerator> projectGenerators = new HashMap<>();
generator.generateWorkspaceAndDependentProjects(projectGenerators, MoreExecutors.newDirectExecutorService());
assertEquals(generator.getRequiredBuildTargets(), ImmutableSet.of(genruleTarget));
}
Aggregations