Search in sources :

Example 26 with PBXTarget

use of com.facebook.buck.apple.xcode.xcodeproj.PBXTarget in project buck by facebook.

the class ProjectGeneratorTest method testCxxLibraryExportedPreprocessorFlagsPropagate.

@Test
public void testCxxLibraryExportedPreprocessorFlagsPropagate() throws IOException {
    BuildTarget buildTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
    TargetNode<?, ?> node = new CxxLibraryBuilder(buildTarget).setExportedPreprocessorFlags(ImmutableList.of("-DHELLO")).build();
    BuildTarget dependentBuildTarget = BuildTarget.builder(rootPath, "//foo", "bin").build();
    TargetNode<?, ?> dependentNode = AppleBinaryBuilder.createBuilder(dependentBuildTarget).setConfigs(ImmutableSortedMap.of("Debug", ImmutableMap.of())).setPreprocessorFlags(ImmutableList.of("-D__APPLE__")).setDeps(ImmutableSortedSet.of(buildTarget)).build();
    ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(node, dependentNode), ImmutableSet.of());
    projectGenerator.createXcodeProjects();
    PBXTarget target = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), "//foo:bin");
    ImmutableMap<String, String> settings = getBuildSettings(buildTarget, target, "Debug");
    assertEquals("$(inherited) -Wno-deprecated -Wno-conversion -DHELLO -D__APPLE__", settings.get("OTHER_CFLAGS"));
}
Also used : PBXTarget(com.facebook.buck.apple.xcode.xcodeproj.PBXTarget) BuildTarget(com.facebook.buck.model.BuildTarget) CxxLibraryBuilder(com.facebook.buck.cxx.CxxLibraryBuilder) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) NSString(com.dd.plist.NSString) Test(org.junit.Test)

Example 27 with PBXTarget

use of com.facebook.buck.apple.xcode.xcodeproj.PBXTarget in project buck by facebook.

the class ProjectGeneratorTest method testAppleLibraryConfiguresOutputPaths.

@Test
public void testAppleLibraryConfiguresOutputPaths() throws IOException {
    BuildTarget buildTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
    TargetNode<?, ?> node = AppleLibraryBuilder.createBuilder(buildTarget).setConfigs(ImmutableSortedMap.of("Debug", ImmutableMap.of())).setHeaderPathPrefix(Optional.of("MyHeaderPathPrefix")).setPrefixHeader(Optional.of(new FakeSourcePath("Foo/Foo-Prefix.pch"))).build();
    ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(node), ImmutableSet.of());
    projectGenerator.createXcodeProjects();
    PBXTarget target = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), "//foo:lib");
    assertThat(target.isa(), equalTo("PBXNativeTarget"));
    assertThat(target.getProductType(), equalTo(ProductType.STATIC_LIBRARY));
    ImmutableMap<String, String> settings = getBuildSettings(buildTarget, target, "Debug");
    assertEquals("../Foo/Foo-Prefix.pch", settings.get("GCC_PREFIX_HEADER"));
    assertEquals("$SYMROOT/$CONFIGURATION$EFFECTIVE_PLATFORM_NAME", settings.get("BUILT_PRODUCTS_DIR"));
    assertEquals("$BUILT_PRODUCTS_DIR", settings.get("CONFIGURATION_BUILD_DIR"));
}
Also used : FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) PBXTarget(com.facebook.buck.apple.xcode.xcodeproj.PBXTarget) BuildTarget(com.facebook.buck.model.BuildTarget) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) NSString(com.dd.plist.NSString) Test(org.junit.Test)

Example 28 with PBXTarget

use of com.facebook.buck.apple.xcode.xcodeproj.PBXTarget in project buck by facebook.

the class ProjectGeneratorTest method testAppleLibraryLinkerFlagsDontPropagate.

@Test
public void testAppleLibraryLinkerFlagsDontPropagate() throws IOException {
    BuildTarget buildTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
    TargetNode<?, ?> node = AppleLibraryBuilder.createBuilder(buildTarget).setConfigs(ImmutableSortedMap.of("Debug", ImmutableMap.of())).setLinkerFlags(ImmutableList.of(StringWithMacrosUtils.format("-lhello"))).build();
    BuildTarget dependentBuildTarget = BuildTarget.builder(rootPath, "//foo", "bin").build();
    TargetNode<?, ?> dependentNode = AppleBinaryBuilder.createBuilder(dependentBuildTarget).setConfigs(ImmutableSortedMap.of("Debug", ImmutableMap.of())).setDeps(ImmutableSortedSet.of(buildTarget)).build();
    ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(node, dependentNode), ImmutableSet.of());
    projectGenerator.createXcodeProjects();
    PBXTarget target = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), "//foo:bin");
    ImmutableMap<String, String> settings = getBuildSettings(buildTarget, target, "Debug");
    assertEquals("$(inherited) ", settings.get("OTHER_LDFLAGS"));
}
Also used : PBXTarget(com.facebook.buck.apple.xcode.xcodeproj.PBXTarget) BuildTarget(com.facebook.buck.model.BuildTarget) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) NSString(com.dd.plist.NSString) Test(org.junit.Test)

Example 29 with PBXTarget

use of com.facebook.buck.apple.xcode.xcodeproj.PBXTarget in project buck by facebook.

the class ProjectGeneratorTest method testCxxLibraryRule.

@Test
public void testCxxLibraryRule() throws IOException {
    BuildTarget buildTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
    TargetNode<?, ?> cxxNode = new CxxLibraryBuilder(buildTarget).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("foo.cpp"), ImmutableList.of("-foo")), SourceWithFlags.of(new FakeSourcePath("bar.cpp")))).setHeaders(ImmutableSortedSet.of(new FakeSourcePath("foo.h"))).build();
    ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(cxxNode));
    projectGenerator.createXcodeProjects();
    PBXTarget target = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), "//foo:lib");
    assertThat(target.isa(), equalTo("PBXNativeTarget"));
    assertThat(target.getProductType(), equalTo(ProductType.STATIC_LIBRARY));
    assertHasConfigurations(target, "Debug", "Release", "Profile");
    assertEquals("Should have exact number of build phases", 1, target.getBuildPhases().size());
    assertHasSingletonSourcesPhaseWithSourcesAndFlags(target, ImmutableMap.of("foo.cpp", Optional.of("-foo"), "bar.cpp", Optional.empty()));
}
Also used : FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) PBXTarget(com.facebook.buck.apple.xcode.xcodeproj.PBXTarget) BuildTarget(com.facebook.buck.model.BuildTarget) CxxLibraryBuilder(com.facebook.buck.cxx.CxxLibraryBuilder) Test(org.junit.Test)

Example 30 with PBXTarget

use of com.facebook.buck.apple.xcode.xcodeproj.PBXTarget in project buck by facebook.

the class ProjectGeneratorTest method testAppleLibraryWithoutHeaderMaps.

@Test
public void testAppleLibraryWithoutHeaderMaps() 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")))).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.Option.DISABLE_HEADER_MAPS));
    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 " + "../buck-out/gen/_p/ptQfVNNRRE-pub " + "../buck-out/gen/_p/CwkbTNOBmb-pub " + "../buck-out", settings.get("HEADER_SEARCH_PATHS"));
}
Also used : FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) PBXTarget(com.facebook.buck.apple.xcode.xcodeproj.PBXTarget) BuildTarget(com.facebook.buck.model.BuildTarget) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) NSString(com.dd.plist.NSString) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Aggregations

PBXTarget (com.facebook.buck.apple.xcode.xcodeproj.PBXTarget)85 Test (org.junit.Test)79 BuildTarget (com.facebook.buck.model.BuildTarget)68 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)47 NSString (com.dd.plist.NSString)40 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)39 Path (java.nio.file.Path)21 PBXFileReference (com.facebook.buck.apple.xcode.xcodeproj.PBXFileReference)19 PBXProject (com.facebook.buck.apple.xcode.xcodeproj.PBXProject)19 ImmutableMap (com.google.common.collect.ImmutableMap)18 SourceTreePath (com.facebook.buck.apple.xcode.xcodeproj.SourceTreePath)13 PBXNativeTarget (com.facebook.buck.apple.xcode.xcodeproj.PBXNativeTarget)11 DocumentBuilder (javax.xml.parsers.DocumentBuilder)11 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)11 XPath (javax.xml.xpath.XPath)11 XPathExpression (javax.xml.xpath.XPathExpression)11 XPathFactory (javax.xml.xpath.XPathFactory)11 Document (org.w3c.dom.Document)11 NodeList (org.w3c.dom.NodeList)11 DefaultBuildTargetSourcePath (com.facebook.buck.rules.DefaultBuildTargetSourcePath)10