use of com.facebook.buck.apple.xcode.xcodeproj.SourceTreePath in project buck by facebook.
the class ProjectGeneratorTest method testAppleLibraryDependentsSearchHeadersAndLibraries.
@Test
public void testAppleLibraryDependentsSearchHeadersAndLibraries() throws IOException {
ImmutableSortedMap<String, ImmutableMap<String, String>> configs = ImmutableSortedMap.of("Debug", ImmutableMap.<String, String>of());
BuildTarget libraryTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
TargetNode<?, ?> libraryNode = AppleLibraryBuilder.createBuilder(libraryTarget).setConfigs(configs).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("foo.m")))).setFrameworks(ImmutableSortedSet.of(FrameworkPath.ofSourceTreePath(new SourceTreePath(PBXReference.SourceTree.SDKROOT, Paths.get("Library.framework"), Optional.empty())))).build();
BuildTarget testTarget = BuildTarget.builder(rootPath, "//foo", "xctest").build();
TargetNode<?, ?> testNode = AppleTestBuilder.createBuilder(testTarget).setConfigs(configs).setInfoPlist(new FakeSourcePath("Info.plist")).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("fooTest.m")))).setFrameworks(ImmutableSortedSet.of(FrameworkPath.ofSourceTreePath(new SourceTreePath(PBXReference.SourceTree.SDKROOT, Paths.get("Test.framework"), Optional.empty())))).setDeps(ImmutableSortedSet.of(libraryTarget)).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(libraryNode, testNode), ImmutableSet.of());
projectGenerator.createXcodeProjects();
PBXTarget target = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), "//foo:xctest");
ImmutableMap<String, String> settings = getBuildSettings(testTarget, target, "Debug");
assertEquals("$(inherited) " + "../buck-out/gen/_p/ptQfVNNRRE-priv/.hmap " + "../buck-out/gen/_p/ptQfVNNRRE-pub/.hmap " + "../buck-out/gen/_p/CwkbTNOBmb-pub/.hmap " + "../buck-out", settings.get("HEADER_SEARCH_PATHS"));
assertEquals(null, settings.get("USER_HEADER_SEARCH_PATHS"));
assertEquals("$(inherited) $BUILT_PRODUCTS_DIR", settings.get("LIBRARY_SEARCH_PATHS"));
assertEquals("$(inherited) $BUILT_PRODUCTS_DIR $SDKROOT", settings.get("FRAMEWORK_SEARCH_PATHS"));
}
use of com.facebook.buck.apple.xcode.xcodeproj.SourceTreePath in project buck by facebook.
the class ProjectGeneratorTest method shouldEmitFilesForBuildSettingPrefixedFrameworks.
@Test
public void shouldEmitFilesForBuildSettingPrefixedFrameworks() throws IOException {
BuildTarget buildTarget = BuildTarget.builder(rootPath, "//foo", "rule").addFlavors(CxxDescriptionEnhancer.SHARED_FLAVOR).build();
TargetNode<?, ?> node = AppleLibraryBuilder.createBuilder(buildTarget).setConfigs(ImmutableSortedMap.of("Debug", ImmutableMap.of())).setLibraries(ImmutableSortedSet.of(FrameworkPath.ofSourceTreePath(new SourceTreePath(PBXReference.SourceTree.BUILT_PRODUCTS_DIR, Paths.get("libfoo.a"), Optional.empty())), FrameworkPath.ofSourceTreePath(new SourceTreePath(PBXReference.SourceTree.SDKROOT, Paths.get("libfoo.a"), Optional.empty())), FrameworkPath.ofSourceTreePath(new SourceTreePath(PBXReference.SourceTree.SOURCE_ROOT, Paths.get("libfoo.a"), Optional.empty())))).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(node));
projectGenerator.createXcodeProjects();
PBXProject generatedProject = projectGenerator.getGeneratedProject();
PBXTarget target = assertTargetExistsAndReturnTarget(generatedProject, "//foo:rule#shared");
ProjectGeneratorTestUtils.assertHasSingletonFrameworksPhaseWithFrameworkEntries(target, ImmutableList.of("$BUILT_PRODUCTS_DIR/libfoo.a", "$SDKROOT/libfoo.a", "$SOURCE_ROOT/libfoo.a"));
}
use of com.facebook.buck.apple.xcode.xcodeproj.SourceTreePath in project buck by facebook.
the class ProjectGeneratorTest method testAppleLibraryTransitiveDependentsSearchHeadersAndLibraries.
@Test
public void testAppleLibraryTransitiveDependentsSearchHeadersAndLibraries() throws IOException {
ImmutableSortedMap<String, ImmutableMap<String, String>> configs = ImmutableSortedMap.of("Debug", ImmutableMap.<String, String>of());
BuildTarget libraryDepTarget = BuildTarget.builder(rootPath, "//bar", "lib").build();
TargetNode<?, ?> libraryDepNode = AppleLibraryBuilder.createBuilder(libraryDepTarget).setConfigs(configs).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("foo.m")))).setFrameworks(ImmutableSortedSet.of(FrameworkPath.ofSourceTreePath(new SourceTreePath(PBXReference.SourceTree.SDKROOT, Paths.get("Library.framework"), Optional.empty())))).build();
BuildTarget libraryTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
TargetNode<?, ?> libraryNode = AppleLibraryBuilder.createBuilder(libraryTarget).setConfigs(configs).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("foo.m")))).setFrameworks(ImmutableSortedSet.of(FrameworkPath.ofSourceTreePath(new SourceTreePath(PBXReference.SourceTree.SDKROOT, Paths.get("Library.framework"), Optional.empty())))).setDeps(ImmutableSortedSet.of(libraryDepTarget)).build();
BuildTarget testTarget = BuildTarget.builder(rootPath, "//foo", "xctest").build();
TargetNode<?, ?> testNode = AppleTestBuilder.createBuilder(testTarget).setConfigs(configs).setInfoPlist(new FakeSourcePath("Info.plist")).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("fooTest.m")))).setFrameworks(ImmutableSortedSet.of(FrameworkPath.ofSourceTreePath(new SourceTreePath(PBXReference.SourceTree.SDKROOT, Paths.get("Test.framework"), Optional.empty())))).setDeps(ImmutableSortedSet.of(libraryTarget)).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(libraryDepNode, libraryNode, testNode), ImmutableSet.of());
projectGenerator.createXcodeProjects();
PBXTarget target = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), "//foo:xctest");
ImmutableMap<String, String> settings = getBuildSettings(testTarget, target, "Debug");
assertEquals("$(inherited) " + "../buck-out/gen/_p/ptQfVNNRRE-priv/.hmap " + "../buck-out/gen/_p/ptQfVNNRRE-pub/.hmap " + "../buck-out/gen/_p/zAW4E7kxsV-pub/.hmap " + "../buck-out/gen/_p/CwkbTNOBmb-pub/.hmap " + "../buck-out", settings.get("HEADER_SEARCH_PATHS"));
assertEquals(null, settings.get("USER_HEADER_SEARCH_PATHS"));
assertEquals("$(inherited) " + "$BUILT_PRODUCTS_DIR", settings.get("LIBRARY_SEARCH_PATHS"));
assertEquals("$(inherited) " + "$BUILT_PRODUCTS_DIR $SDKROOT", settings.get("FRAMEWORK_SEARCH_PATHS"));
}
use of com.facebook.buck.apple.xcode.xcodeproj.SourceTreePath in project buck by facebook.
the class ProjectGeneratorTest method testAppleLibraryWithoutSourcesWithHeaders.
@Test
public void testAppleLibraryWithoutSourcesWithHeaders() throws IOException {
ImmutableSortedMap<String, ImmutableMap<String, String>> configs = ImmutableSortedMap.of("Debug", ImmutableMap.of("HEADER_SEARCH_PATHS", "headers", "LIBRARY_SEARCH_PATHS", "libraries"));
BuildTarget libraryTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
TargetNode<?, ?> libraryNode = AppleLibraryBuilder.createBuilder(libraryTarget).setConfigs(configs).setExportedHeaders(ImmutableSortedSet.of(new FakeSourcePath("HeaderGroup1/bar.h"))).setFrameworks(ImmutableSortedSet.of(FrameworkPath.ofSourceTreePath(new SourceTreePath(PBXReference.SourceTree.SDKROOT, Paths.get("Library.framework"), Optional.empty())))).build();
BuildTarget testTarget = BuildTarget.builder(rootPath, "//foo", "xctest").build();
TargetNode<?, ?> testNode = AppleTestBuilder.createBuilder(testTarget).setConfigs(configs).setInfoPlist(new FakeSourcePath("Info.plist")).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("fooTest.m")))).setDeps(ImmutableSortedSet.of(libraryTarget)).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(libraryNode, testNode), ImmutableSet.of());
projectGenerator.createXcodeProjects();
PBXTarget target = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), "//foo:xctest");
ImmutableMap<String, String> settings = getBuildSettings(testTarget, target, "Debug");
assertEquals("headers " + "../buck-out/gen/_p/ptQfVNNRRE-priv/.hmap " + "../buck-out/gen/_p/ptQfVNNRRE-pub/.hmap " + "../buck-out/gen/_p/CwkbTNOBmb-pub/.hmap " + "../buck-out", settings.get("HEADER_SEARCH_PATHS"));
assertEquals("libraries $BUILT_PRODUCTS_DIR", settings.get("LIBRARY_SEARCH_PATHS"));
assertEquals("Should have exact number of build phases", 2, target.getBuildPhases().size());
assertHasSingletonSourcesPhaseWithSourcesAndFlags(target, ImmutableMap.of("fooTest.m", Optional.empty()));
ProjectGeneratorTestUtils.assertHasSingletonFrameworksPhaseWithFrameworkEntries(target, ImmutableList.of("$SDKROOT/Library.framework"));
}
use of com.facebook.buck.apple.xcode.xcodeproj.SourceTreePath in project buck by facebook.
the class NewNativeTargetProjectMutator method addSourcePathToSourcesBuildPhase.
private void addSourcePathToSourcesBuildPhase(SourceWithFlags sourceWithFlags, PBXGroup sourcesGroup, PBXSourcesBuildPhase sourcesBuildPhase) {
SourceTreePath sourceTreePath = new SourceTreePath(PBXReference.SourceTree.SOURCE_ROOT, pathRelativizer.outputDirToRootRelative(sourcePathResolver.apply(sourceWithFlags.getSourcePath())), Optional.empty());
PBXFileReference fileReference = sourcesGroup.getOrCreateFileReferenceBySourceTreePath(sourceTreePath);
PBXBuildFile buildFile = new PBXBuildFile(fileReference);
sourcesBuildPhase.getFiles().add(buildFile);
ImmutableList<String> customLangPreprocessorFlags = ImmutableList.of();
Optional<CxxSource.Type> sourceType = CxxSource.Type.fromExtension(Files.getFileExtension(sourceTreePath.toString()));
if (sourceType.isPresent() && langPreprocessorFlags.containsKey(sourceType.get())) {
customLangPreprocessorFlags = langPreprocessorFlags.get(sourceType.get());
}
ImmutableList<String> customFlags = ImmutableList.copyOf(Iterables.concat(customLangPreprocessorFlags, sourceWithFlags.getFlags()));
if (!customFlags.isEmpty()) {
NSDictionary settings = new NSDictionary();
settings.put("COMPILER_FLAGS", Joiner.on(' ').join(customFlags));
buildFile.setSettings(Optional.of(settings));
}
LOG.verbose("Added source path %s to group %s, flags %s, PBXFileReference %s", sourceWithFlags, sourcesGroup.getName(), customFlags, fileReference);
}
Aggregations