use of com.facebook.buck.apple.xcode.xcodeproj.PBXProject in project buck by facebook.
the class ProjectGeneratorTest method testRuleAddsReference.
private void testRuleAddsReference(BuildTarget ruleTarget, TargetNode<?, ?> ruleNode, String path) throws IOException {
BuildTarget libraryTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
TargetNode<?, ?> libraryNode = AppleLibraryBuilder.createBuilder(libraryTarget).setDeps(ImmutableSortedSet.of(ruleTarget)).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(ruleNode, libraryNode));
projectGenerator.createXcodeProjects();
PBXProject project = projectGenerator.getGeneratedProject();
PBXGroup targetGroup = project.getMainGroup().getOrCreateChildGroupByName(libraryTarget.getFullyQualifiedName());
PBXGroup resourcesGroup = targetGroup.getOrCreateChildGroupByName("Resources");
assertThat(resourcesGroup.getChildren(), hasSize(1));
PBXFileReference ruleReference = (PBXFileReference) Iterables.get(resourcesGroup.getChildren(), 0);
assertEquals(path, ruleReference.getName());
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXProject in project buck by facebook.
the class ProjectGeneratorTest method testAssetCatalogsUnderLibraryNotTest.
@Test
public void testAssetCatalogsUnderLibraryNotTest() throws IOException {
BuildTarget libraryTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
BuildTarget testTarget = BuildTarget.builder(rootPath, "//foo", "test").build();
BuildTarget assetCatalogTarget = BuildTarget.builder(rootPath, "//foo", "asset_catalog").build();
TargetNode<?, ?> libraryNode = AppleLibraryBuilder.createBuilder(libraryTarget).setTests(ImmutableSortedSet.of(testTarget)).setDeps(ImmutableSortedSet.of(assetCatalogTarget)).build();
TargetNode<?, ?> testNode = AppleTestBuilder.createBuilder(testTarget).setConfigs(ImmutableSortedMap.of("Default", ImmutableMap.of())).setInfoPlist(new FakeSourcePath("Info.plist")).setDeps(ImmutableSortedSet.of(libraryTarget)).build();
TargetNode<?, ?> assetCatalogNode = AppleAssetCatalogBuilder.createBuilder(assetCatalogTarget).setDirs(ImmutableSortedSet.of(new FakeSourcePath("AssetCatalog.xcassets"))).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(libraryNode, testNode, assetCatalogNode), ImmutableSet.of(ProjectGenerator.Option.USE_SHORT_NAMES_FOR_TARGETS));
projectGenerator.createXcodeProjects();
PBXProject project = projectGenerator.getGeneratedProject();
PBXGroup mainGroup = project.getMainGroup();
PBXTarget fooLibTarget = assertTargetExistsAndReturnTarget(project, "lib");
assertTrue(FluentIterable.from(fooLibTarget.getBuildPhases()).filter(PBXResourcesBuildPhase.class).isEmpty());
PBXGroup libResourcesGroup = mainGroup.getOrCreateChildGroupByName("lib").getOrCreateChildGroupByName("Resources");
PBXFileReference assetCatalogFile = (PBXFileReference) libResourcesGroup.getChildren().get(0);
assertEquals("AssetCatalog.xcassets", assetCatalogFile.getName());
PBXTarget fooTestTarget = assertTargetExistsAndReturnTarget(project, "test");
PBXResourcesBuildPhase resourcesBuildPhase = ProjectGeneratorTestUtils.getSingletonPhaseByType(fooTestTarget, PBXResourcesBuildPhase.class);
assertThat(resourcesBuildPhase.getFiles(), hasSize(1));
assertThat(assertFileRefIsRelativeAndResolvePath(resourcesBuildPhase.getFiles().get(0).getFileRef()), equalTo(projectFilesystem.resolve("AssetCatalog.xcassets").toString()));
PBXGroup testResourcesGroup = mainGroup.getOrCreateChildGroupByName("test").getOrCreateChildGroupByName("Resources");
assetCatalogFile = (PBXFileReference) testResourcesGroup.getChildren().get(0);
assertEquals("AssetCatalog.xcassets", assetCatalogFile.getName());
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXProject in project buck by facebook.
the class ProjectGeneratorTest method resourceDirectoriesHaveFolderType.
@Test
public void resourceDirectoriesHaveFolderType() throws IOException {
BuildTarget directoryTarget = BuildTarget.builder(rootPath, "//foo", "dir").build();
BuildTarget resourceTarget = BuildTarget.builder(rootPath, "//foo", "res").build();
BuildTarget libraryTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
TargetNode<?, ?> directoryNode = ExportFileBuilder.newExportFileBuilder(directoryTarget).build();
TargetNode<?, ?> resourceNode = AppleResourceBuilder.createBuilder(resourceTarget).setDirs(ImmutableSet.of(new DefaultBuildTargetSourcePath(directoryTarget))).setFiles(ImmutableSet.of()).build();
TargetNode<?, ?> libraryNode = AppleLibraryBuilder.createBuilder(libraryTarget).setDeps(ImmutableSortedSet.of(resourceTarget)).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(directoryNode, resourceNode, libraryNode));
projectGenerator.createXcodeProjects();
PBXProject project = projectGenerator.getGeneratedProject();
PBXGroup mainGroup = project.getMainGroup();
PBXGroup resourcesGroup = mainGroup.getOrCreateDescendantGroupByPath(ImmutableList.of("//foo:lib", "Resources"));
PBXFileReference resource = (PBXFileReference) Iterables.get(resourcesGroup.getChildren(), 0);
assertThat(resource.getName(), equalTo("dir"));
assertThat(resource.getExplicitFileType(), equalTo(Optional.of("folder")));
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXProject in project buck by facebook.
the class NewNativeTargetProjectMutatorTest method setUp.
@Before
public void setUp() {
assumeTrue(Platform.detect() == Platform.MACOS || Platform.detect() == Platform.LINUX);
generatedProject = new PBXProject("TestProject");
sourcePathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
pathRelativizer = new PathRelativizer(Paths.get("_output"), sourcePathResolver::getRelativePath);
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXProject in project buck by facebook.
the class ProjectGeneratorTest method testHeaderSymlinkTreesWithTestsAndBinaryBundles.
@Test
public void testHeaderSymlinkTreesWithTestsAndBinaryBundles() throws IOException {
BuildTarget binaryTarget = BuildTarget.builder(rootPath, "//foo", "bin").build();
BuildTarget bundleTarget = BuildTarget.builder(rootPath, "//foo", "bundle").build();
BuildTarget testTarget = BuildTarget.builder(rootPath, "//foo", "test").build();
TargetNode<?, ?> binaryNode = AppleBinaryBuilder.createBuilder(binaryTarget).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("foo.h"), ImmutableList.of("public")), SourceWithFlags.of(new FakeSourcePath("bar.h")))).build();
TargetNode<?, ?> bundleNode = AppleBundleBuilder.createBuilder(bundleTarget).setBinary(binaryTarget).setExtension(Either.ofLeft(AppleBundleExtension.APP)).setInfoPlist(new FakeSourcePath("Info.plist")).setTests(ImmutableSortedSet.of(testTarget)).build();
TargetNode<?, ?> testNode = AppleTestBuilder.createBuilder(testTarget).setConfigs(ImmutableSortedMap.of("Default", ImmutableMap.of())).setInfoPlist(new FakeSourcePath("Info.plist")).setDeps(ImmutableSortedSet.of(bundleTarget)).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(binaryNode, bundleNode, testNode));
projectGenerator.createXcodeProjects();
PBXProject project = projectGenerator.getGeneratedProject();
PBXTarget testPBXTarget = assertTargetExistsAndReturnTarget(project, "//foo:test");
ImmutableMap<String, String> buildSettings = getBuildSettings(testTarget, testPBXTarget, "Default");
assertEquals("test binary should use header symlink trees for both public and non-public headers " + "of the tested binary in HEADER_SEARCH_PATHS", "$(inherited) " + "../buck-out/gen/_p/LpygK8zq5F-priv/.hmap " + "../buck-out/gen/_p/LpygK8zq5F-pub/.hmap " + "../buck-out/gen/_p/4UdYl649ee-pub/.hmap " + "../buck-out/gen/_p/4UdYl649ee-priv/.hmap " + "../buck-out", buildSettings.get("HEADER_SEARCH_PATHS"));
assertEquals("USER_HEADER_SEARCH_PATHS should not be set", null, buildSettings.get("USER_HEADER_SEARCH_PATHS"));
}
Aggregations