use of com.facebook.buck.apple.xcode.xcodeproj.PBXTarget in project buck by facebook.
the class ProjectGeneratorTest method testGeneratedProjectStructureAndSettingsWithBridgingHeader.
@Test
public void testGeneratedProjectStructureAndSettingsWithBridgingHeader() throws IOException {
BuildTarget buildTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
TargetNode<?, ?> node = AppleLibraryBuilder.createBuilder(buildTarget).setConfigs(ImmutableSortedMap.of("Debug", ImmutableMap.of())).setSrcs(ImmutableSortedSet.of()).setBridgingHeader(Optional.of(new FakeSourcePath("BridgingHeader/header1.h"))).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(node));
projectGenerator.createXcodeProjects();
// check if bridging header file existing in the project structure
PBXProject project = projectGenerator.getGeneratedProject();
PBXGroup targetGroup = project.getMainGroup().getOrCreateChildGroupByName(buildTarget.getFullyQualifiedName());
PBXGroup sourcesGroup = targetGroup.getOrCreateChildGroupByName("Sources");
assertThat(sourcesGroup.getChildren(), hasSize(1));
PBXFileReference fileRefBridgingHeader = (PBXFileReference) Iterables.get(sourcesGroup.getChildren(), 0);
assertEquals("header1.h", fileRefBridgingHeader.getName());
// check for bridging header build setting
PBXTarget target = assertTargetExistsAndReturnTarget(project, "//foo:lib");
ImmutableMap<String, String> buildSettings = getBuildSettings(buildTarget, target, "Debug");
assertEquals("$(SRCROOT)/../BridgingHeader/header1.h", buildSettings.get("SWIFT_OBJC_BRIDGING_HEADER"));
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXTarget in project buck by facebook.
the class ProjectGeneratorTest method testAppleLibraryLinkerFlags.
@Test
public void testAppleLibraryLinkerFlags() 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("-Xlinker"), StringWithMacrosUtils.format("-lhello"))).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(node), ImmutableSet.of());
projectGenerator.createXcodeProjects();
PBXTarget target = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), "//foo:lib");
ImmutableMap<String, String> settings = getBuildSettings(buildTarget, target, "Debug");
assertEquals("$(inherited) -Xlinker -lhello", settings.get("OTHER_LDFLAGS"));
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXTarget in project buck by facebook.
the class ProjectGeneratorTest method testGeneratedProjectSettingForSwiftVersion.
@Test
public void testGeneratedProjectSettingForSwiftVersion() throws IOException {
BuildTarget buildTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
TargetNode<?, ?> node = AppleLibraryBuilder.createBuilder(buildTarget).setConfigs(ImmutableSortedMap.of("Debug", ImmutableMap.of())).setSrcs(ImmutableSortedSet.of()).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(node));
projectGenerator.createXcodeProjects();
PBXProject project = projectGenerator.getGeneratedProject();
PBXTarget target = assertTargetExistsAndReturnTarget(project, "//foo:lib");
ImmutableMap<String, String> buildSettings = getBuildSettings(buildTarget, target, "Debug");
assertThat(buildSettings.get("SWIFT_VERSION"), equalTo("1.23"));
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXTarget in project buck by facebook.
the class ProjectGeneratorTest method testAppleWatchTarget.
@Test
public void testAppleWatchTarget() throws IOException {
BuildTarget watchAppBinaryTarget = BuildTarget.builder(rootPath, "//foo", "WatchAppBinary").build();
TargetNode<?, ?> watchAppBinaryNode = AppleBinaryBuilder.createBuilder(watchAppBinaryTarget).build();
BuildTarget watchAppTarget = BuildTarget.builder(rootPath, "//foo", "WatchApp").addFlavors(DEFAULT_FLAVOR).build();
TargetNode<?, ?> watchAppNode = AppleBundleBuilder.createBuilder(watchAppTarget).setExtension(Either.ofLeft(AppleBundleExtension.APP)).setXcodeProductType(Optional.of("com.apple.product-type.application.watchapp2")).setInfoPlist(new FakeSourcePath("Info.plist")).setBinary(watchAppBinaryTarget).build();
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).setDeps(ImmutableSortedSet.of(watchAppTarget)).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(watchAppNode, watchAppBinaryNode, hostAppNode, hostAppBinaryNode));
projectGenerator.createXcodeProjects();
PBXTarget target = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), "//foo:HostApp");
assertEquals(target.getProductType(), ProductType.APPLICATION);
ProjectGeneratorTestUtils.assertHasSingletonCopyFilesPhaseWithFileEntries(target, ImmutableList.of("$BUILT_PRODUCTS_DIR/WatchApp.app"));
PBXCopyFilesBuildPhase copyBuildPhase = ProjectGeneratorTestUtils.getSingletonPhaseByType(target, PBXCopyFilesBuildPhase.class);
assertEquals(copyBuildPhase.getDstSubfolderSpec(), CopyFilePhaseDestinationSpec.builder().setDestination(PBXCopyFilesBuildPhase.Destination.PRODUCTS).setPath("$(CONTENTS_FOLDER_PATH)/Watch").build());
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXTarget in project buck by facebook.
the class ProjectGeneratorTest method testAppleBundleRuleWithRNLibraryDependency.
@Test
public void testAppleBundleRuleWithRNLibraryDependency() throws IOException {
BuildTarget rnLibraryTarget = BuildTarget.builder(rootPath, "//foo", "rn_library").addFlavors(DEFAULT_FLAVOR).build();
ProjectFilesystem filesystem = new AllExistingProjectFilesystem();
ReactNativeBuckConfig buckConfig = new ReactNativeBuckConfig(FakeBuckConfig.builder().setSections(ImmutableMap.of("react-native", ImmutableMap.of("packager_worker", "react-native/packager.sh"))).setFilesystem(filesystem).build());
TargetNode<?, ?> rnLibraryNode = IosReactNativeLibraryBuilder.builder(rnLibraryTarget, buckConfig).setBundleName("Apps/Foo/FooBundle.js").setEntryPath(new PathSourcePath(filesystem, Paths.get("js/FooApp.js"))).build();
BuildTarget sharedLibraryTarget = BuildTarget.builder(rootPath, "//dep", "shared").addFlavors(CxxDescriptionEnhancer.SHARED_FLAVOR).build();
TargetNode<?, ?> sharedLibraryNode = AppleLibraryBuilder.createBuilder(sharedLibraryTarget).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(sharedLibraryTarget).setDeps(ImmutableSortedSet.of(rnLibraryTarget)).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(rnLibraryNode, sharedLibraryNode, bundleNode));
projectGenerator.createXcodeProjects();
PBXProject project = projectGenerator.getGeneratedProject();
PBXTarget target = assertTargetExistsAndReturnTarget(project, "//foo:bundle");
assertThat(target.getName(), equalTo("//foo:bundle"));
assertThat(target.isa(), equalTo("PBXNativeTarget"));
PBXShellScriptBuildPhase shellScriptBuildPhase = ProjectGeneratorTestUtils.getSingletonPhaseByType(target, PBXShellScriptBuildPhase.class);
assertThat(shellScriptBuildPhase.getShellScript(), startsWith("BASE_DIR="));
}
Aggregations