use of com.facebook.buck.apple.xcode.xcodeproj.PBXTarget in project buck by facebook.
the class ProjectGeneratorTest method testConfiglessAppleTargetGetsDefaultBuildConfigurations.
@Test
public void testConfiglessAppleTargetGetsDefaultBuildConfigurations() throws IOException {
BuildTarget buildTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
TargetNode<?, ?> node = AppleLibraryBuilder.createBuilder(buildTarget).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("foo.mm")))).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(node));
projectGenerator.createXcodeProjects();
PBXTarget target = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), "//foo:lib");
assertHasConfigurations(target, "Debug", "Release", "Profile");
ImmutableMap<String, String> debugSettings = ProjectGeneratorTestUtils.getBuildSettings(projectFilesystem, buildTarget, target, "Debug");
assertThat(debugSettings.size(), Matchers.greaterThan(0));
ImmutableMap<String, String> profileSettings = ProjectGeneratorTestUtils.getBuildSettings(projectFilesystem, buildTarget, target, "Profile");
assertThat(debugSettings, Matchers.equalTo(profileSettings));
ImmutableMap<String, String> releaseSettings = ProjectGeneratorTestUtils.getBuildSettings(projectFilesystem, buildTarget, target, "Release");
assertThat(debugSettings, Matchers.equalTo(releaseSettings));
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXTarget in project buck by facebook.
the class ProjectGeneratorTest method ruleToTargetMapContainsPBXTarget.
@Test
public void ruleToTargetMapContainsPBXTarget() throws IOException {
BuildTarget buildTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
TargetNode<?, ?> node = AppleLibraryBuilder.createBuilder(buildTarget).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("foo.m"), ImmutableList.of("-foo")), SourceWithFlags.of(new FakeSourcePath("bar.m")))).setHeaders(ImmutableSortedSet.of(new FakeSourcePath("foo.h"))).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(node));
projectGenerator.createXcodeProjects();
assertEquals(buildTarget, Iterables.getOnlyElement(projectGenerator.getBuildTargetToGeneratedTargetMap().keySet()));
PBXTarget target = Iterables.getOnlyElement(projectGenerator.getBuildTargetToGeneratedTargetMap().values());
assertHasSingletonSourcesPhaseWithSourcesAndFlags(target, ImmutableMap.of("foo.m", Optional.of("-foo"), "bar.m", Optional.empty()));
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXTarget in project buck by facebook.
the class ProjectGeneratorTest method resourcesInDependenciesPropagatesToBundles.
@Test
public void resourcesInDependenciesPropagatesToBundles() throws IOException {
BuildTarget resourceTarget = BuildTarget.builder(rootPath, "//foo", "res").build();
TargetNode<?, ?> resourceNode = AppleResourceBuilder.createBuilder(resourceTarget).setFiles(ImmutableSet.of(new FakeSourcePath("bar.png"))).setDirs(ImmutableSet.of(new FakeSourcePath("foodir"))).build();
BuildTarget libraryTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
TargetNode<?, ?> libraryNode = AppleLibraryBuilder.createBuilder(libraryTarget).setDeps(ImmutableSortedSet.of(resourceTarget)).build();
BuildTarget bundleLibraryTarget = BuildTarget.builder(rootPath, "//foo", "bundlelib").build();
TargetNode<?, ?> bundleLibraryNode = AppleLibraryBuilder.createBuilder(bundleLibraryTarget).setDeps(ImmutableSortedSet.of(libraryTarget)).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(bundleLibraryTarget).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(resourceNode, libraryNode, bundleLibraryNode, bundleNode));
projectGenerator.createXcodeProjects();
PBXProject generatedProject = projectGenerator.getGeneratedProject();
PBXTarget target = assertTargetExistsAndReturnTarget(generatedProject, "//foo:bundle");
assertHasSingletonResourcesPhaseWithEntries(target, "bar.png", "foodir");
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXTarget in project buck by facebook.
the class ProjectGeneratorTest method uiTestUsesHostAppAsTarget.
@Test
public void uiTestUsesHostAppAsTarget() throws IOException {
BuildTarget hostAppBinaryTarget = BuildTarget.builder(rootPath, "//foo", "HostAppBinary").build();
TargetNode<?, ?> hostAppBinaryNode = AppleBinaryBuilder.createBuilder(hostAppBinaryTarget).build();
BuildTarget hostAppTarget = BuildTarget.builder(rootPath, "//foo", "HostApp").build();
TargetNode<?, ?> hostAppNode = AppleBundleBuilder.createBuilder(hostAppTarget).setExtension(Either.ofLeft(AppleBundleExtension.APP)).setInfoPlist(new FakeSourcePath("Info.plist")).setBinary(hostAppBinaryTarget).build();
BuildTarget testTarget = BuildTarget.builder(rootPath, "//foo", "AppTest").build();
TargetNode<?, ?> testNode = AppleTestBuilder.createBuilder(testTarget).setConfigs(ImmutableSortedMap.of("Debug", ImmutableMap.of())).setInfoPlist(new FakeSourcePath("Info.plist")).setTestHostApp(Optional.of(hostAppTarget)).isUiTest(Optional.of(true)).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(hostAppBinaryNode, hostAppNode, testNode), ImmutableSet.of());
projectGenerator.createXcodeProjects();
PBXTarget testPBXTarget = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), "//foo:AppTest");
assertEquals(testPBXTarget.getProductType(), ProductType.UI_TEST);
ImmutableMap<String, String> settings = getBuildSettings(testTarget, testPBXTarget, "Debug");
// Check starts with as the remainder depends on the bundle style at build time.
assertEquals(settings.get("TEST_TARGET_NAME"), "//foo:HostApp");
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXTarget in project buck by facebook.
the class ProjectGeneratorTest method testAppleBundleRuleWithCustomXcodeProductNameFromConfigs.
@Test
public void testAppleBundleRuleWithCustomXcodeProductNameFromConfigs() throws IOException {
BuildTarget sharedLibraryTarget = BuildTarget.builder(rootPath, "//dep", "shared").addFlavors(CxxDescriptionEnhancer.SHARED_FLAVOR).build();
TargetNode<?, ?> sharedLibraryNode = AppleLibraryBuilder.createBuilder(sharedLibraryTarget).setConfigs(ImmutableSortedMap.of("Debug", ImmutableMap.of("PRODUCT_NAME", "FancyFramework"))).build();
BuildTarget buildTarget = BuildTarget.builder(rootPath, "//foo", "custombundle").build();
TargetNode<?, ?> node = AppleBundleBuilder.createBuilder(buildTarget).setExtension(Either.ofLeft(AppleBundleExtension.FRAMEWORK)).setInfoPlist(new FakeSourcePath("Info.plist")).setBinary(sharedLibraryTarget).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(sharedLibraryNode, node), ImmutableSet.of());
projectGenerator.createXcodeProjects();
PBXProject project = projectGenerator.getGeneratedProject();
PBXTarget target = assertTargetExistsAndReturnTarget(project, "//foo:custombundle");
ImmutableMap<String, String> buildSettings = getBuildSettings(buildTarget, target, "Debug");
assertThat(buildSettings.get("PRODUCT_NAME"), Matchers.equalTo("FancyFramework"));
}
Aggregations