Search in sources :

Example 6 with PBXReference

use of com.facebook.buck.apple.xcode.xcodeproj.PBXReference in project bazel by bazelbuild.

the class PbxReferencesGrouper method dirOfContainingPbxGroup.

/**
   * The directory of the PBXGroup that will contain the given reference. For most references, this
   * is just the actual parent directory. For {@code PBXVariantGroup}s, whose children are not
   * guaranteed to be in any common directory except the client root, this returns the deepest
   * common container of each child in the group.
   */
private Path dirOfContainingPbxGroup(PBXReference reference) {
    if (reference instanceof PBXVariantGroup) {
        PBXVariantGroup variantGroup = (PBXVariantGroup) reference;
        Path path = Paths.get(variantGroup.getChildren().get(0).getPath());
        for (PBXReference child : variantGroup.getChildren()) {
            path = deepestCommonContainer(path, path(child.getPath()));
        }
        return path;
    } else {
        return parent(path(reference.getPath()));
    }
}
Also used : Path(java.nio.file.Path) PBXReference(com.facebook.buck.apple.xcode.xcodeproj.PBXReference) PBXVariantGroup(com.facebook.buck.apple.xcode.xcodeproj.PBXVariantGroup)

Example 7 with PBXReference

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

the class ProjectGeneratorTest method testProjectStructureWithInfoPlist.

@Test
public void testProjectStructureWithInfoPlist() throws IOException {
    BuildTarget libraryTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
    BuildTarget bundleTarget = BuildTarget.builder(rootPath, "//foo", "bundle").build();
    TargetNode<?, ?> libraryNode = AppleLibraryBuilder.createBuilder(libraryTarget).setExportedHeaders(ImmutableSortedSet.of(new FakeSourcePath("foo.h"))).build();
    TargetNode<?, ?> bundleNode = AppleBundleBuilder.createBuilder(bundleTarget).setBinary(libraryTarget).setExtension(Either.ofLeft(AppleBundleExtension.FRAMEWORK)).setInfoPlist(new FakeSourcePath(("Info.plist"))).build();
    ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(libraryNode, bundleNode));
    projectGenerator.createXcodeProjects();
    PBXProject project = projectGenerator.getGeneratedProject();
    PBXGroup bundleGroup = project.getMainGroup().getOrCreateChildGroupByName(bundleTarget.getFullyQualifiedName());
    PBXGroup sourcesGroup = bundleGroup.getOrCreateChildGroupByName("Sources");
    assertThat(bundleGroup.getChildren(), hasSize(2));
    Iterable<String> childNames = Iterables.transform(sourcesGroup.getChildren(), PBXReference::getName);
    assertThat(childNames, hasItem("Info.plist"));
}
Also used : FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) PBXReference(com.facebook.buck.apple.xcode.xcodeproj.PBXReference) BuildTarget(com.facebook.buck.model.BuildTarget) PBXGroup(com.facebook.buck.apple.xcode.xcodeproj.PBXGroup) PBXProject(com.facebook.buck.apple.xcode.xcodeproj.PBXProject) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) NSString(com.dd.plist.NSString) Test(org.junit.Test)

Aggregations

PBXReference (com.facebook.buck.apple.xcode.xcodeproj.PBXReference)7 PBXGroup (com.facebook.buck.apple.xcode.xcodeproj.PBXGroup)4 PBXProject (com.facebook.buck.apple.xcode.xcodeproj.PBXProject)4 NSString (com.dd.plist.NSString)3 BuildTarget (com.facebook.buck.model.BuildTarget)3 Path (java.nio.file.Path)3 Test (org.junit.Test)3 PBXFileReference (com.facebook.buck.apple.xcode.xcodeproj.PBXFileReference)2 PBXVariantGroup (com.facebook.buck.apple.xcode.xcodeproj.PBXVariantGroup)2 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 NSArray (com.dd.plist.NSArray)1 NSDictionary (com.dd.plist.NSDictionary)1 PBXBuildFile (com.facebook.buck.apple.xcode.xcodeproj.PBXBuildFile)1 PBXFrameworksBuildPhase (com.facebook.buck.apple.xcode.xcodeproj.PBXFrameworksBuildPhase)1 PBXNativeTarget (com.facebook.buck.apple.xcode.xcodeproj.PBXNativeTarget)1 SourceTree (com.facebook.buck.apple.xcode.xcodeproj.PBXReference.SourceTree)1 PBXResourcesBuildPhase (com.facebook.buck.apple.xcode.xcodeproj.PBXResourcesBuildPhase)1 PBXShellScriptBuildPhase (com.facebook.buck.apple.xcode.xcodeproj.PBXShellScriptBuildPhase)1 PBXSourcesBuildPhase (com.facebook.buck.apple.xcode.xcodeproj.PBXSourcesBuildPhase)1