Search in sources :

Example 6 with XCScheme

use of com.facebook.buck.apple.xcode.XCScheme in project buck by facebook.

the class WorkspaceAndProjectGeneratorTest method customRunnableSettings.

@Test
public void customRunnableSettings() throws IOException, InterruptedException {
    BuildTarget fooLibTarget = BuildTarget.builder(rootCell.getRoot(), "//foo", "FooLib").build();
    TargetNode<AppleLibraryDescription.Arg, ?> fooLib = AppleLibraryBuilder.createBuilder(fooLibTarget).build();
    TargetNode<XcodeWorkspaceConfigDescription.Arg, ?> workspaceNode = XcodeWorkspaceConfigBuilder.createBuilder(BuildTarget.builder(rootCell.getRoot(), "//foo", "workspace").build()).setWorkspaceName(Optional.of("workspace")).setSrcTarget(Optional.of(fooLibTarget)).setExplicitRunnablePath(Optional.of("/some.app")).setLaunchStyle(Optional.of(XCScheme.LaunchAction.LaunchStyle.WAIT)).build();
    TargetGraph targetGraph = TargetGraphFactory.newInstance(fooLib, workspaceNode);
    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(), true, /* 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());
    XCScheme mainScheme = generator.getSchemeGenerators().get("workspace").getOutputScheme().get();
    XCScheme.LaunchAction launchAction = mainScheme.getLaunchAction().get();
    assertThat(launchAction.getRunnablePath().get(), Matchers.equalTo("/some.app"));
    assertThat(launchAction.getLaunchStyle(), Matchers.equalTo(XCScheme.LaunchAction.LaunchStyle.WAIT));
}
Also used : Path(java.nio.file.Path) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) DefaultBuildTargetSourcePath(com.facebook.buck.rules.DefaultBuildTargetSourcePath) HashMap(java.util.HashMap) TargetGraph(com.facebook.buck.rules.TargetGraph) AlwaysFoundExecutableFinder(com.facebook.buck.io.AlwaysFoundExecutableFinder) BuildTarget(com.facebook.buck.model.BuildTarget) XCScheme(com.facebook.buck.apple.xcode.XCScheme) Test(org.junit.Test)

Example 7 with XCScheme

use of com.facebook.buck.apple.xcode.XCScheme in project buck by facebook.

the class WorkspaceAndProjectGeneratorTest method enablingParallelizeBuild.

@Test
public void enablingParallelizeBuild() throws IOException, InterruptedException {
    BuildTarget fooLibTarget = BuildTarget.builder(rootCell.getRoot(), "//foo", "FooLib").build();
    TargetNode<AppleLibraryDescription.Arg, ?> fooLib = AppleLibraryBuilder.createBuilder(fooLibTarget).build();
    TargetNode<XcodeWorkspaceConfigDescription.Arg, ?> workspaceNode = XcodeWorkspaceConfigBuilder.createBuilder(BuildTarget.builder(rootCell.getRoot(), "//foo", "workspace").build()).setWorkspaceName(Optional.of("workspace")).setSrcTarget(Optional.of(fooLibTarget)).build();
    TargetGraph targetGraph = TargetGraphFactory.newInstance(fooLib, workspaceNode);
    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(), true, /* 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());
    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(1));
    assertThat(mainSchemeBuildAction.getBuildActionEntries().get(0), withNameAndBuildingFor("FooLib", equalTo(XCScheme.BuildActionEntry.BuildFor.DEFAULT)));
    assertThat(mainSchemeBuildAction.getParallelizeBuild(), is(true));
}
Also used : Path(java.nio.file.Path) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) DefaultBuildTargetSourcePath(com.facebook.buck.rules.DefaultBuildTargetSourcePath) HashMap(java.util.HashMap) TargetGraph(com.facebook.buck.rules.TargetGraph) AlwaysFoundExecutableFinder(com.facebook.buck.io.AlwaysFoundExecutableFinder) BuildTarget(com.facebook.buck.model.BuildTarget) XCScheme(com.facebook.buck.apple.xcode.XCScheme) Test(org.junit.Test)

Aggregations

XCScheme (com.facebook.buck.apple.xcode.XCScheme)7 Path (java.nio.file.Path)7 AlwaysFoundExecutableFinder (com.facebook.buck.io.AlwaysFoundExecutableFinder)6 DefaultBuildTargetSourcePath (com.facebook.buck.rules.DefaultBuildTargetSourcePath)6 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)6 HashMap (java.util.HashMap)6 Test (org.junit.Test)6 BuildTarget (com.facebook.buck.model.BuildTarget)3 TargetGraph (com.facebook.buck.rules.TargetGraph)3 PBXTarget (com.facebook.buck.apple.xcode.xcodeproj.PBXTarget)2 ExecutableFinder (com.facebook.buck.io.ExecutableFinder)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1