use of com.facebook.buck.rules.FakeSourcePath in project buck by facebook.
the class ProjectGeneratorTest method testCxxLibraryWithoutHeadersSymLinks.
@Test
public void testCxxLibraryWithoutHeadersSymLinks() throws IOException {
BuildTarget buildTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
TargetNode<?, ?> node = new CxxLibraryBuilder(buildTarget).setExportedHeaders(ImmutableSortedSet.of(new FakeSourcePath("foo/dir1/bar.h"))).setHeaders(ImmutableSortedSet.of(new FakeSourcePath("foo/dir1/foo.h"), new FakeSourcePath("foo/dir2/baz.h"))).setSrcs(ImmutableSortedSet.of()).setXcodePublicHeadersSymlinks(false).setXcodePrivateHeadersSymlinks(false).build();
ImmutableSet.Builder<ProjectGenerator.Option> optionsBuilder = ImmutableSet.builder();
ImmutableSet<ProjectGenerator.Option> projectGeneratorOptions = optionsBuilder.build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(node), projectGeneratorOptions);
projectGenerator.createXcodeProjects();
List<Path> headerSymlinkTrees = projectGenerator.getGeneratedHeaderSymlinkTrees();
assertThat(headerSymlinkTrees, hasSize(2));
assertThat(headerSymlinkTrees.get(0).toString(), is(equalTo("buck-out/gen/_p/CwkbTNOBmb-pub")));
assertThatHeaderMapWithoutSymLinksContains(Paths.get("buck-out/gen/_p/CwkbTNOBmb-pub"), ImmutableMap.of("foo/dir1/bar.h", "foo/dir1/bar.h"));
assertThat(headerSymlinkTrees.get(1).toString(), is(equalTo("buck-out/gen/_p/CwkbTNOBmb-priv")));
assertThatHeaderMapWithoutSymLinksContains(Paths.get("buck-out/gen/_p/CwkbTNOBmb-priv"), ImmutableMap.<String, String>builder().put("foo/dir1/foo.h", "foo/dir1/foo.h").put("foo/dir2/baz.h", "foo/dir2/baz.h").build());
}
use of com.facebook.buck.rules.FakeSourcePath in project buck by facebook.
the class ProjectGeneratorTest method testCxxLibraryWithListsOfHeaders.
@Test
public void testCxxLibraryWithListsOfHeaders() throws IOException {
BuildTarget buildTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
TargetNode<?, ?> node = new CxxLibraryBuilder(buildTarget).setExportedHeaders(ImmutableSortedSet.of(new FakeSourcePath("foo/dir1/bar.h"))).setHeaders(ImmutableSortedSet.of(new FakeSourcePath("foo/dir1/foo.h"), new FakeSourcePath("foo/dir2/baz.h"))).setSrcs(ImmutableSortedSet.of()).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(node));
projectGenerator.createXcodeProjects();
List<Path> headerSymlinkTrees = projectGenerator.getGeneratedHeaderSymlinkTrees();
assertThat(headerSymlinkTrees, hasSize(2));
assertThat(headerSymlinkTrees.get(0).toString(), is(equalTo("buck-out/gen/_p/CwkbTNOBmb-pub")));
assertThatHeaderSymlinkTreeContains(Paths.get("buck-out/gen/_p/CwkbTNOBmb-pub"), ImmutableMap.of("foo/dir1/bar.h", "foo/dir1/bar.h"));
assertThat(headerSymlinkTrees.get(1).toString(), is(equalTo("buck-out/gen/_p/CwkbTNOBmb-priv")));
assertThatHeaderSymlinkTreeContains(Paths.get("buck-out/gen/_p/CwkbTNOBmb-priv"), ImmutableMap.<String, String>builder().put("foo/dir1/foo.h", "foo/dir1/foo.h").put("foo/dir2/baz.h", "foo/dir2/baz.h").build());
}
use of com.facebook.buck.rules.FakeSourcePath in project buck by facebook.
the class ProjectGeneratorTest method testHeaderSymlinkTreesWithTestsAndBinaryBundles.
@Test
public void testHeaderSymlinkTreesWithTestsAndBinaryBundles() throws IOException {
BuildTarget binaryTarget = BuildTarget.builder(rootPath, "//foo", "bin").build();
BuildTarget bundleTarget = BuildTarget.builder(rootPath, "//foo", "bundle").build();
BuildTarget testTarget = BuildTarget.builder(rootPath, "//foo", "test").build();
TargetNode<?, ?> binaryNode = AppleBinaryBuilder.createBuilder(binaryTarget).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("foo.h"), ImmutableList.of("public")), SourceWithFlags.of(new FakeSourcePath("bar.h")))).build();
TargetNode<?, ?> bundleNode = AppleBundleBuilder.createBuilder(bundleTarget).setBinary(binaryTarget).setExtension(Either.ofLeft(AppleBundleExtension.APP)).setInfoPlist(new FakeSourcePath("Info.plist")).setTests(ImmutableSortedSet.of(testTarget)).build();
TargetNode<?, ?> testNode = AppleTestBuilder.createBuilder(testTarget).setConfigs(ImmutableSortedMap.of("Default", ImmutableMap.of())).setInfoPlist(new FakeSourcePath("Info.plist")).setDeps(ImmutableSortedSet.of(bundleTarget)).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(binaryNode, bundleNode, testNode));
projectGenerator.createXcodeProjects();
PBXProject project = projectGenerator.getGeneratedProject();
PBXTarget testPBXTarget = assertTargetExistsAndReturnTarget(project, "//foo:test");
ImmutableMap<String, String> buildSettings = getBuildSettings(testTarget, testPBXTarget, "Default");
assertEquals("test binary should use header symlink trees for both public and non-public headers " + "of the tested binary in HEADER_SEARCH_PATHS", "$(inherited) " + "../buck-out/gen/_p/LpygK8zq5F-priv/.hmap " + "../buck-out/gen/_p/LpygK8zq5F-pub/.hmap " + "../buck-out/gen/_p/4UdYl649ee-pub/.hmap " + "../buck-out/gen/_p/4UdYl649ee-priv/.hmap " + "../buck-out", buildSettings.get("HEADER_SEARCH_PATHS"));
assertEquals("USER_HEADER_SEARCH_PATHS should not be set", null, buildSettings.get("USER_HEADER_SEARCH_PATHS"));
}
use of com.facebook.buck.rules.FakeSourcePath in project buck by facebook.
the class ProjectGeneratorTest method testAppleResourceWithVariantGroupSetsFileTypeBasedOnPath.
@Test
public void testAppleResourceWithVariantGroupSetsFileTypeBasedOnPath() throws IOException {
BuildTarget resourceTarget = BuildTarget.builder(rootPath, "//foo", "resource").addFlavors(DEFAULT_FLAVOR).build();
TargetNode<?, ?> resourceNode = AppleResourceBuilder.createBuilder(resourceTarget).setFiles(ImmutableSet.of()).setDirs(ImmutableSet.of()).setVariants(ImmutableSet.of(new FakeSourcePath("Base.lproj/Bar.storyboard"))).build();
BuildTarget fooLibraryTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
TargetNode<?, ?> fooLibraryNode = AppleLibraryBuilder.createBuilder(fooLibraryTarget).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(fooLibraryTarget).setDeps(ImmutableSortedSet.of(resourceTarget)).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(fooLibraryNode, bundleNode, resourceNode), ImmutableSet.of());
projectGenerator.createXcodeProjects();
PBXProject project = projectGenerator.getGeneratedProject();
PBXGroup targetGroup = project.getMainGroup().getOrCreateChildGroupByName(bundleTarget.getFullyQualifiedName());
PBXGroup resourcesGroup = targetGroup.getOrCreateChildGroupByName("Resources");
PBXVariantGroup storyboardGroup = (PBXVariantGroup) Iterables.get(resourcesGroup.getChildren(), 0);
List<PBXReference> storyboardGroupChildren = storyboardGroup.getChildren();
assertEquals(1, storyboardGroupChildren.size());
assertTrue(storyboardGroupChildren.get(0) instanceof PBXFileReference);
PBXFileReference baseStoryboardReference = (PBXFileReference) storyboardGroupChildren.get(0);
assertEquals("Base", baseStoryboardReference.getName());
// Make sure the file type is set from the path.
assertEquals(Optional.of("file.storyboard"), baseStoryboardReference.getLastKnownFileType());
assertEquals(Optional.empty(), baseStoryboardReference.getExplicitFileType());
}
use of com.facebook.buck.rules.FakeSourcePath in project buck by facebook.
the class ProjectGeneratorTest method testCoreDataModelRuleAddsReference.
@Test
public void testCoreDataModelRuleAddsReference() throws IOException {
BuildTarget modelTarget = BuildTarget.builder(rootPath, "//foo", "model").build();
TargetNode<?, ?> modelNode = CoreDataModelBuilder.createBuilder(modelTarget).setPath(new FakeSourcePath("foo.xcdatamodel").getRelativePath()).build();
testRuleAddsReference(modelTarget, modelNode, "foo.xcdatamodel");
}
Aggregations