use of com.facebook.buck.apple.xcode.xcodeproj.SourceTreePath in project buck by facebook.
the class ProjectGeneratorTest method testAppleLibraryDependentsInheritSearchPaths.
@Test
public void testAppleLibraryDependentsInheritSearchPaths() throws IOException {
ImmutableSortedMap<String, ImmutableMap<String, String>> configs = ImmutableSortedMap.of("Debug", ImmutableMap.of("HEADER_SEARCH_PATHS", "headers", "USER_HEADER_SEARCH_PATHS", "user_headers", "LIBRARY_SEARCH_PATHS", "libraries", "FRAMEWORK_SEARCH_PATHS", "frameworks"));
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("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("user_headers", settings.get("USER_HEADER_SEARCH_PATHS"));
assertEquals("libraries $BUILT_PRODUCTS_DIR", settings.get("LIBRARY_SEARCH_PATHS"));
assertEquals("frameworks $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 FrameworkPathTypeCoercer method coerce.
@Override
public FrameworkPath coerce(CellPathResolver cellRoots, ProjectFilesystem filesystem, Path pathRelativeToProjectRoot, Object object) throws CoerceFailedException {
if (object instanceof String) {
Path path = Paths.get((String) object);
String firstElement = Preconditions.checkNotNull(Iterables.getFirst(path, Paths.get(""))).toString();
if (firstElement.startsWith("$")) {
// NOPMD - length() > 0 && charAt(0) == '$' is ridiculous
Optional<PBXReference.SourceTree> sourceTree = PBXReference.SourceTree.fromBuildSetting(firstElement);
if (sourceTree.isPresent()) {
int nameCount = path.getNameCount();
if (nameCount < 2) {
throw new HumanReadableException("Invalid source tree path: '%s'. Should have at least one path component after" + "'%s'.", path, firstElement);
}
return FrameworkPath.ofSourceTreePath(new SourceTreePath(sourceTree.get(), path.subpath(1, path.getNameCount()), Optional.empty()));
} else {
throw new HumanReadableException("Unknown SourceTree: '%s'. Should be one of: %s", firstElement, Joiner.on(", ").join(Iterables.transform(ImmutableList.copyOf(PBXReference.SourceTree.values()), input -> "$" + input.toString())));
}
} else {
return FrameworkPath.ofSourcePath(sourcePathTypeCoercer.coerce(cellRoots, filesystem, pathRelativeToProjectRoot, object));
}
}
throw CoerceFailedException.simple(object, getOutputClass(), "input should be either a source tree path or a source path");
}
use of com.facebook.buck.apple.xcode.xcodeproj.SourceTreePath in project buck by facebook.
the class CxxLinkableEnhancerTest method frameworksToLinkerFlagsTransformer.
@Test
public void frameworksToLinkerFlagsTransformer() {
ProjectFilesystem projectFilesystem = new FakeProjectFilesystem();
SourcePathResolver resolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
Arg linkerFlags = CxxLinkableEnhancer.frameworksToLinkerArg(ImmutableSortedSet.of(FrameworkPath.ofSourceTreePath(new SourceTreePath(PBXReference.SourceTree.DEVELOPER_DIR, Paths.get("Library/Frameworks/XCTest.framework"), Optional.empty())), FrameworkPath.ofSourcePath(new PathSourcePath(projectFilesystem, Paths.get("Vendor/Bar/Bar.framework")))));
assertEquals(ImmutableList.of("-framework", "XCTest", "-framework", "Bar"), Arg.stringifyList(linkerFlags, resolver));
}
use of com.facebook.buck.apple.xcode.xcodeproj.SourceTreePath in project buck by facebook.
the class CxxLibraryDescriptionTest method sharedLibraryShouldLinkOwnRequiredLibraries.
@Test
public void sharedLibraryShouldLinkOwnRequiredLibraries() throws Exception {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
CxxPlatform platform = CxxLibraryBuilder.createDefaultPlatform();
CxxLibraryBuilder libraryBuilder = new CxxLibraryBuilder(BuildTargetFactory.newInstance("//:foo").withFlavors(platform.getFlavor(), CxxDescriptionEnhancer.SHARED_FLAVOR), cxxBuckConfig);
libraryBuilder.setLibraries(ImmutableSortedSet.of(FrameworkPath.ofSourceTreePath(new SourceTreePath(PBXReference.SourceTree.SDKROOT, Paths.get("/usr/lib/libz.dylib"), Optional.empty())), FrameworkPath.ofSourcePath(new FakeSourcePath("/another/path/liba.dylib")))).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("foo.c"))));
TargetGraph targetGraph = TargetGraphFactory.newInstance(libraryBuilder.build());
BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
CxxLink library = (CxxLink) libraryBuilder.build(resolver, filesystem, targetGraph);
assertThat(Arg.stringify(library.getArgs(), pathResolver), hasItems("-L", "/another/path", "$SDKROOT/usr/lib", "-la", "-lz"));
}
use of com.facebook.buck.apple.xcode.xcodeproj.SourceTreePath in project buck by facebook.
the class NewNativeTargetProjectMutatorTest method testFrameworkBuildPhase.
@Test
public void testFrameworkBuildPhase() throws NoSuchBuildTargetException {
NewNativeTargetProjectMutator mutator = mutatorWithCommonDefaults();
mutator.setFrameworks(ImmutableSet.of(FrameworkPath.ofSourceTreePath(new SourceTreePath(PBXReference.SourceTree.SDKROOT, Paths.get("Foo.framework"), Optional.empty()))));
mutator.setArchives(ImmutableSet.of(new PBXFileReference("libdep.a", "libdep.a", PBXReference.SourceTree.BUILT_PRODUCTS_DIR, Optional.empty())));
NewNativeTargetProjectMutator.Result result = mutator.buildTargetAndAddToProject(generatedProject, true);
assertHasSingletonFrameworksPhaseWithFrameworkEntries(result.target, ImmutableList.of("$SDKROOT/Foo.framework", "$BUILT_PRODUCTS_DIR/libdep.a"));
}
Aggregations