use of com.facebook.buck.rules.FakeSourcePath in project buck by facebook.
the class ProjectGeneratorTest method stopsCopyingRecursiveDependenciesAtBundles.
@Test
public void stopsCopyingRecursiveDependenciesAtBundles() throws IOException {
BuildTarget dependentStaticLibraryTarget = BuildTarget.builder(rootPath, "//dep", "static").build();
TargetNode<?, ?> dependentStaticLibraryNode = AppleLibraryBuilder.createBuilder(dependentStaticLibraryTarget).build();
BuildTarget dependentStaticFrameworkTarget = BuildTarget.builder(rootPath, "//dep", "static-framework").build();
TargetNode<?, ?> dependentStaticFrameworkNode = AppleBundleBuilder.createBuilder(dependentStaticFrameworkTarget).setExtension(Either.ofLeft(AppleBundleExtension.FRAMEWORK)).setInfoPlist(new FakeSourcePath("Info.plist")).setBinary(dependentStaticLibraryTarget).build();
BuildTarget dependentSharedLibraryTarget = BuildTarget.builder(rootPath, "//dep", "shared").addFlavors(CxxDescriptionEnhancer.SHARED_FLAVOR).build();
TargetNode<?, ?> dependentSharedLibraryNode = AppleLibraryBuilder.createBuilder(dependentSharedLibraryTarget).setDeps(ImmutableSortedSet.of(dependentStaticFrameworkTarget)).build();
BuildTarget dependentFrameworkTarget = BuildTarget.builder(rootPath, "//dep", "framework").build();
TargetNode<?, ?> dependentFrameworkNode = AppleBundleBuilder.createBuilder(dependentFrameworkTarget).setExtension(Either.ofLeft(AppleBundleExtension.FRAMEWORK)).setInfoPlist(new FakeSourcePath("Info.plist")).setBinary(dependentSharedLibraryTarget).build();
BuildTarget libraryTarget = BuildTarget.builder(rootPath, "//foo", "library").addFlavors(CxxDescriptionEnhancer.SHARED_FLAVOR).build();
TargetNode<?, ?> libraryNode = AppleLibraryBuilder.createBuilder(libraryTarget).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("e.m")))).setDeps(ImmutableSortedSet.of(dependentFrameworkTarget)).build();
BuildTarget bundleTarget = BuildTarget.builder(rootPath, "//foo", "final").build();
TargetNode<?, ?> bundleNode = AppleBundleBuilder.createBuilder(bundleTarget).setExtension(Either.ofLeft(AppleBundleExtension.BUNDLE)).setInfoPlist(new FakeSourcePath("Info.plist")).setBinary(libraryTarget).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(// ant needs this to be explicit
ImmutableSet.of(dependentStaticLibraryNode, dependentStaticFrameworkNode, dependentSharedLibraryNode, dependentFrameworkNode, libraryNode, bundleNode));
projectGenerator.createXcodeProjects();
PBXTarget target = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), "//foo:final");
assertEquals(target.getProductType(), ProductType.BUNDLE);
assertEquals("Should have exact number of build phases ", 2, target.getBuildPhases().size());
ProjectGeneratorTestUtils.assertHasSingletonCopyFilesPhaseWithFileEntries(target, ImmutableList.of("$BUILT_PRODUCTS_DIR/framework.framework"));
}
use of com.facebook.buck.rules.FakeSourcePath in project buck by facebook.
the class ProjectGeneratorTest method bundlesDontLinkTheirOwnBinary.
@Test
public void bundlesDontLinkTheirOwnBinary() throws IOException {
BuildTarget libraryTarget = BuildTarget.builder(rootPath, "//foo", "library").addFlavors(CxxDescriptionEnhancer.SHARED_FLAVOR).build();
TargetNode<?, ?> libraryNode = AppleLibraryBuilder.createBuilder(libraryTarget).build();
BuildTarget bundleTarget = BuildTarget.builder(rootPath, "//foo", "final").build();
TargetNode<?, ?> bundleNode = AppleBundleBuilder.createBuilder(bundleTarget).setExtension(Either.ofLeft(AppleBundleExtension.BUNDLE)).setInfoPlist(new FakeSourcePath("Info.plist")).setBinary(libraryTarget).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(libraryNode, bundleNode));
projectGenerator.createXcodeProjects();
PBXTarget target = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), "//foo:final");
assertEquals(target.getProductType(), ProductType.BUNDLE);
assertEquals("Should have exact number of build phases ", 0, target.getBuildPhases().size());
}
use of com.facebook.buck.rules.FakeSourcePath in project buck by facebook.
the class ProjectGeneratorTest method applicationTestDoesNotCopyHostAppBundleIntoTestBundle.
@Test
public void applicationTestDoesNotCopyHostAppBundleIntoTestBundle() throws IOException {
BuildTarget hostAppBinaryTarget = BuildTarget.builder(rootPath, "//foo", "HostAppBinary").build();
TargetNode<?, ?> hostAppBinaryNode = AppleBinaryBuilder.createBuilder(hostAppBinaryTarget).build();
BuildTarget hostAppTarget = BuildTarget.builder(rootPath, "//foo", "HostApp").build();
TargetNode<?, ?> hostAppNode = AppleBundleBuilder.createBuilder(hostAppTarget).setExtension(Either.ofLeft(AppleBundleExtension.APP)).setInfoPlist(new FakeSourcePath("Info.plist")).setBinary(hostAppBinaryTarget).build();
BuildTarget testTarget = BuildTarget.builder(rootPath, "//foo", "AppTest").build();
TargetNode<?, ?> testNode = AppleTestBuilder.createBuilder(testTarget).setConfigs(ImmutableSortedMap.of("Debug", ImmutableMap.of())).setInfoPlist(new FakeSourcePath("Info.plist")).setTestHostApp(Optional.of(hostAppTarget)).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(hostAppBinaryNode, hostAppNode, testNode), ImmutableSet.of());
projectGenerator.createXcodeProjects();
PBXTarget testPBXTarget = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), "//foo:AppTest");
// for this test phases should be empty - there should be no copy phases in particular
assertThat(testPBXTarget.getBuildPhases().size(), Matchers.equalTo(0));
}
use of com.facebook.buck.rules.FakeSourcePath in project buck by facebook.
the class ProjectGeneratorTest method testAppleBundleRuleWithPostBuildScriptDependency.
@Test
public void testAppleBundleRuleWithPostBuildScriptDependency() throws IOException {
BuildTarget scriptTarget = BuildTarget.builder(rootPath, "//foo", "post_build_script").addFlavors(DEFAULT_FLAVOR).build();
TargetNode<?, ?> scriptNode = XcodePostbuildScriptBuilder.createBuilder(scriptTarget).setCmd("script.sh").build();
BuildTarget resourceTarget = BuildTarget.builder(rootPath, "//foo", "resource").build();
TargetNode<?, ?> resourceNode = AppleResourceBuilder.createBuilder(resourceTarget).setFiles(ImmutableSet.of(new FakeSourcePath("bar.png"))).setDirs(ImmutableSet.of()).build();
BuildTarget sharedLibraryTarget = BuildTarget.builder(rootPath, "//dep", "shared").addFlavors(CxxDescriptionEnhancer.SHARED_FLAVOR).build();
TargetNode<?, ?> sharedLibraryNode = AppleLibraryBuilder.createBuilder(sharedLibraryTarget).setDeps(ImmutableSortedSet.of(resourceTarget)).build();
BuildTarget bundleTarget = BuildTarget.builder(rootPath, "//foo", "bundle").build();
TargetNode<?, ?> bundleNode = AppleBundleBuilder.createBuilder(bundleTarget).setExtension(Either.ofLeft(AppleBundleExtension.BUNDLE)).setInfoPlist(new FakeSourcePath("Info.plist")).setBinary(sharedLibraryTarget).setDeps(ImmutableSortedSet.of(scriptTarget)).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(scriptNode, resourceNode, sharedLibraryNode, bundleNode));
projectGenerator.createXcodeProjects();
PBXProject project = projectGenerator.getGeneratedProject();
PBXTarget target = assertTargetExistsAndReturnTarget(project, "//foo:bundle");
assertThat(target.getName(), equalTo("//foo:bundle"));
assertThat(target.isa(), equalTo("PBXNativeTarget"));
PBXShellScriptBuildPhase shellScriptBuildPhase = ProjectGeneratorTestUtils.getSingletonPhaseByType(target, PBXShellScriptBuildPhase.class);
assertThat(shellScriptBuildPhase.getShellScript(), equalTo("script.sh"));
// Assert that the post-build script phase comes after resources are copied.
assertThat(target.getBuildPhases().get(0), instanceOf(PBXResourcesBuildPhase.class));
assertThat(target.getBuildPhases().get(1), instanceOf(PBXShellScriptBuildPhase.class));
}
use of com.facebook.buck.rules.FakeSourcePath in project buck by facebook.
the class ProjectCommandXcodeTest method buildGraph.
@Before
public void buildGraph() {
// Create the following dep tree:
//
// FooBin -has-test-> FooBinTest
// |
// V
// FooLib -has-test-> FooLibTest
// | |
// V V
// BarLib BazLib -has-test-> BazLibTest
// ^
// |
// QuxBin
//
// FooBin and BazLib and FooLibTest use "tests" to specify their tests.
BuildTarget bazTestTarget = BuildTargetFactory.newInstance("//baz:xctest");
BuildTarget fooBinTestTarget = BuildTargetFactory.newInstance("//foo:bin-xctest");
BuildTarget barLibTarget = BuildTargetFactory.newInstance("//bar:lib");
barLibNode = AppleLibraryBuilder.createBuilder(barLibTarget).build();
BuildTarget bazLibTarget = BuildTargetFactory.newInstance("//baz:lib");
bazLibNode = AppleLibraryBuilder.createBuilder(bazLibTarget).setTests(ImmutableSortedSet.of(bazTestTarget)).build();
BuildTarget fooTestTarget = BuildTargetFactory.newInstance("//foo:lib-xctest");
fooTestNode = AppleTestBuilder.createBuilder(fooTestTarget).setDeps(ImmutableSortedSet.of(bazLibTarget)).setInfoPlist(new FakeSourcePath("Info.plist")).build();
BuildTarget fooLibTarget = BuildTargetFactory.newInstance("//foo:lib");
fooLibNode = AppleLibraryBuilder.createBuilder(fooLibTarget).setDeps(ImmutableSortedSet.of(barLibTarget)).setTests(ImmutableSortedSet.of(fooTestTarget)).build();
BuildTarget fooBinBinaryTarget = BuildTargetFactory.newInstance("//foo:binbinary");
fooBinBinaryNode = AppleBinaryBuilder.createBuilder(fooBinBinaryTarget).setDeps(ImmutableSortedSet.of(fooLibTarget)).build();
BuildTarget fooBinTarget = BuildTargetFactory.newInstance("//foo:bin");
fooBinNode = AppleBundleBuilder.createBuilder(fooBinTarget).setExtension(Either.ofLeft(AppleBundleExtension.APP)).setBinary(fooBinBinaryTarget).setTests(ImmutableSortedSet.of(fooBinTestTarget)).setInfoPlist(new FakeSourcePath("Info.plist")).build();
bazTestNode = AppleTestBuilder.createBuilder(bazTestTarget).setDeps(ImmutableSortedSet.of(bazLibTarget)).setInfoPlist(new FakeSourcePath("Info.plist")).build();
fooBinTestNode = AppleTestBuilder.createBuilder(fooBinTestTarget).setDeps(ImmutableSortedSet.of(fooBinTarget)).setInfoPlist(new FakeSourcePath("Info.plist")).build();
BuildTarget quxBinTarget = BuildTargetFactory.newInstance("//qux:bin");
quxBinNode = AppleBinaryBuilder.createBuilder(quxBinTarget).setDeps(ImmutableSortedSet.of(barLibTarget)).build();
BuildTarget workspaceExtraTestTarget = BuildTargetFactory.newInstance("//foo:extra-xctest");
workspaceExtraTestNode = AppleTestBuilder.createBuilder(workspaceExtraTestTarget).setInfoPlist(new FakeSourcePath("Info.plist")).build();
BuildTarget workspaceTarget = BuildTargetFactory.newInstance("//foo:workspace");
workspaceNode = XcodeWorkspaceConfigBuilder.createBuilder(workspaceTarget).setWorkspaceName(Optional.of("workspace")).setSrcTarget(Optional.of(fooBinTarget)).setExtraTests(ImmutableSortedSet.of(workspaceExtraTestTarget)).build();
BuildTarget smallWorkspaceTarget = BuildTargetFactory.newInstance("//baz:small-workspace");
smallWorkspaceNode = XcodeWorkspaceConfigBuilder.createBuilder(smallWorkspaceTarget).setWorkspaceName(Optional.of("small-workspace")).setSrcTarget(Optional.of(bazLibTarget)).build();
targetGraph = TargetGraphFactory.newInstance(barLibNode, fooLibNode, fooBinBinaryNode, fooBinNode, bazLibNode, bazTestNode, fooTestNode, fooBinTestNode, quxBinNode, workspaceExtraTestNode, workspaceNode, smallWorkspaceNode);
}
Aggregations