use of com.facebook.buck.rules.SourcePath in project buck by facebook.
the class AppleDescriptionsTest method parseAppleHeadersForUseFromTheSameTargetFromMap.
@Test
public void parseAppleHeadersForUseFromTheSameTargetFromMap() {
ImmutableSortedMap<String, SourcePath> headerMap = ImmutableSortedMap.of("virtual/path.h", new FakeSourcePath("path/to/some_file.h"), "another/path.h", new FakeSourcePath("path/to/another_file.h"), "another/file.h", new FakeSourcePath("different/path/to/a_file.h"), "file.h", new FakeSourcePath("file.h"));
SourcePathResolver resolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
assertEquals(ImmutableMap.of(), AppleDescriptions.parseAppleHeadersForUseFromTheSameTarget(resolver::getRelativePath, SourceList.ofNamedSources(headerMap)));
}
use of com.facebook.buck.rules.SourcePath in project buck by facebook.
the class ProjectGeneratorTest method testAppBundleDoesntLinkFrameworkWrappedWithResource.
@Test
public void testAppBundleDoesntLinkFrameworkWrappedWithResource() throws Exception {
BuildTarget frameworkTarget = BuildTarget.builder(rootPath, "//foo", "framework").addFlavors(FakeAppleRuleDescriptions.DEFAULT_MACOSX_X86_64_PLATFORM.getFlavor(), CxxDescriptionEnhancer.SHARED_FLAVOR).build();
BuildTarget frameworkBinaryTarget = BuildTarget.builder(rootPath, "//foo", "framework_bin").addFlavors(FakeAppleRuleDescriptions.DEFAULT_MACOSX_X86_64_PLATFORM.getFlavor(), CxxDescriptionEnhancer.SHARED_FLAVOR).build();
TargetNode<?, ?> frameworkBinaryNode = AppleLibraryBuilder.createBuilder(frameworkBinaryTarget).build();
TargetNode<?, ?> frameworkNode = AppleBundleBuilder.createBuilder(frameworkTarget).setExtension(Either.ofLeft(AppleBundleExtension.FRAMEWORK)).setInfoPlist(new FakeSourcePath("Info.plist")).setBinary(frameworkBinaryTarget).build();
BuildTarget resourceTarget = BuildTarget.builder(rootPath, "//foo", "res").build();
SourcePath sourcePath = new DefaultBuildTargetSourcePath(frameworkTarget);
TargetNode<?, ?> resourceNode = AppleResourceBuilder.createBuilder(resourceTarget).setFiles(ImmutableSet.of()).setDirs(ImmutableSet.of(sourcePath)).build();
BuildTarget binaryTarget = BuildTarget.builder(rootPath, "//foo", "bin").build();
TargetNode<?, ?> binaryNode = AppleBinaryBuilder.createBuilder(binaryTarget).setDeps(ImmutableSortedSet.of(resourceTarget)).build();
BuildTarget bundleTarget = BuildTarget.builder(rootPath, "//foo", "bundle").addFlavors(FakeAppleRuleDescriptions.DEFAULT_MACOSX_X86_64_PLATFORM.getFlavor()).build();
TargetNode<?, ?> bundleNode = AppleBundleBuilder.createBuilder(bundleTarget).setExtension(Either.ofLeft(AppleBundleExtension.APP)).setInfoPlist(new FakeSourcePath("Info.plist")).setBinary(binaryTarget).build();
ImmutableSet<TargetNode<?, ?>> nodes = ImmutableSet.of(frameworkBinaryNode, frameworkNode, resourceNode, binaryNode, bundleNode);
final TargetGraph targetGraph = TargetGraphFactory.newInstance(ImmutableSet.copyOf(nodes));
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(nodes, ImmutableSet.of(), getBuildRuleResolverWithRulesForNodeFunction(targetGraph));
projectGenerator.createXcodeProjects();
PBXTarget target = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), bundleTarget.getFullyQualifiedName());
assertEquals(target.getProductType(), ProductType.APPLICATION);
for (PBXBuildPhase buildPhase : target.getBuildPhases()) {
assertFalse(buildPhase instanceof PBXCopyFilesBuildPhase);
}
assertThat(target.getBuildPhases().size(), Matchers.equalTo(1));
}
use of com.facebook.buck.rules.SourcePath in project buck by facebook.
the class NewNativeTargetProjectMutatorTest method testLibraryHeaderGroups.
@Test
public void testLibraryHeaderGroups() throws NoSuchBuildTargetException {
NewNativeTargetProjectMutator mutator = mutatorWithCommonDefaults();
SourcePath foo = new FakeSourcePath("HeaderGroup1/foo.h");
SourcePath bar = new FakeSourcePath("HeaderGroup1/bar.h");
SourcePath baz = new FakeSourcePath("HeaderGroup2/baz.h");
mutator.setPublicHeaders(ImmutableSet.of(bar, baz));
mutator.setPrivateHeaders(ImmutableSet.of(foo));
NewNativeTargetProjectMutator.Result result = mutator.buildTargetAndAddToProject(generatedProject, true);
PBXGroup sourcesGroup = result.targetGroup.get().getOrCreateChildGroupByName("Sources");
assertThat(sourcesGroup.getChildren(), hasSize(2));
PBXGroup group1 = (PBXGroup) Iterables.get(sourcesGroup.getChildren(), 0);
assertEquals("HeaderGroup1", group1.getName());
assertThat(group1.getChildren(), hasSize(2));
PBXFileReference fileRefBar = (PBXFileReference) Iterables.get(group1.getChildren(), 0);
assertEquals("bar.h", fileRefBar.getName());
PBXFileReference fileRefFoo = (PBXFileReference) Iterables.get(group1.getChildren(), 1);
assertEquals("foo.h", fileRefFoo.getName());
PBXGroup group2 = (PBXGroup) Iterables.get(sourcesGroup.getChildren(), 1);
assertEquals("HeaderGroup2", group2.getName());
assertThat(group2.getChildren(), hasSize(1));
PBXFileReference fileRefBaz = (PBXFileReference) Iterables.get(group2.getChildren(), 0);
assertEquals("baz.h", fileRefBaz.getName());
}
use of com.facebook.buck.rules.SourcePath in project buck by facebook.
the class RuleUtilsTest method creatingGroupsFromSourcePathsRemovesLongestCommonPrefix.
@Test
public void creatingGroupsFromSourcePathsRemovesLongestCommonPrefix() {
ImmutableList<SourcePath> input = ImmutableList.of(new FakeSourcePath("Lib/Foo/File1.h"), new FakeSourcePath("Lib/Foo/File2.h"), new FakeSourcePath("Lib/Bar/File1.h"));
ImmutableList<GroupedSource> expected = ImmutableList.of(GroupedSource.ofSourceGroup("Bar", Paths.get("Lib/Bar"), ImmutableList.of(GroupedSource.ofPrivateHeader(new FakeSourcePath("Lib/Bar/File1.h")))), GroupedSource.ofSourceGroup("Foo", Paths.get("Lib/Foo"), ImmutableList.of(GroupedSource.ofPrivateHeader(new FakeSourcePath("Lib/Foo/File1.h")), GroupedSource.ofPrivateHeader(new FakeSourcePath("Lib/Foo/File2.h")))));
SourcePathResolver resolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
ImmutableList<GroupedSource> actual = RuleUtils.createGroupsFromSourcePaths(resolver::getRelativePath, ImmutableList.of(), ImmutableSortedSet.of(), ImmutableList.of(), input);
assertEquals(expected, actual);
}
use of com.facebook.buck.rules.SourcePath in project buck by facebook.
the class RuleUtilsTest method creatingGroupsFromSourcePaths.
@Test
public void creatingGroupsFromSourcePaths() {
ImmutableList<SourcePath> input = ImmutableList.of(new FakeSourcePath("File.h"), new FakeSourcePath("Lib/Foo/File2.h"), new FakeSourcePath("App/Foo/File.h"), new FakeSourcePath("Lib/Bar/File1.h"), new FakeSourcePath("App/File.h"), new FakeSourcePath("Lib/Foo/File1.h"), new FakeSourcePath("App/Foo/Bar/File.h"));
ImmutableList<GroupedSource> expected = ImmutableList.of(GroupedSource.ofSourceGroup("App", Paths.get("App"), ImmutableList.of(GroupedSource.ofSourceGroup("Foo", Paths.get("App/Foo"), ImmutableList.of(GroupedSource.ofSourceGroup("Bar", Paths.get("App/Foo/Bar"), ImmutableList.of(GroupedSource.ofPrivateHeader(new FakeSourcePath("App/Foo/Bar/File.h")))), GroupedSource.ofPrivateHeader(new FakeSourcePath("App/Foo/File.h")))), GroupedSource.ofPrivateHeader(new FakeSourcePath("App/File.h")))), GroupedSource.ofSourceGroup("Lib", Paths.get("Lib"), ImmutableList.of(GroupedSource.ofSourceGroup("Bar", Paths.get("Lib/Bar"), ImmutableList.of(GroupedSource.ofPrivateHeader(new FakeSourcePath("Lib/Bar/File1.h")))), GroupedSource.ofSourceGroup("Foo", Paths.get("Lib/Foo"), ImmutableList.of(GroupedSource.ofPrivateHeader(new FakeSourcePath("Lib/Foo/File1.h")), GroupedSource.ofPrivateHeader(new FakeSourcePath("Lib/Foo/File2.h")))))), GroupedSource.ofPrivateHeader(new FakeSourcePath("File.h")));
SourcePathResolver resolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
ImmutableList<GroupedSource> actual = RuleUtils.createGroupsFromSourcePaths(resolver::getRelativePath, ImmutableList.of(), ImmutableSortedSet.of(), ImmutableList.of(), input);
assertEquals(expected, actual);
}
Aggregations