Search in sources :

Example 1 with SourceTree

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

the class PbxReferencesGrouper method process.

@Override
public Iterable<PBXReference> process(Iterable<PBXReference> references) {
    Map<SourceTree, Groups> groupsBySourceTree = ImmutableMap.of(SourceTree.GROUP, new Groups("workspace_root", SourceTree.GROUP), SourceTree.SDKROOT, new Groups("SDKROOT", SourceTree.SDKROOT), SourceTree.BUILT_PRODUCTS_DIR, new Groups("BUILT_PRODUCTS_DIR", SourceTree.BUILT_PRODUCTS_DIR));
    ImmutableList.Builder<PBXReference> result = new ImmutableList.Builder<>();
    for (PBXReference reference : references) {
        if (Containing.key(groupsBySourceTree, reference.getSourceTree())) {
            Path containingDir = dirOfContainingPbxGroup(reference);
            Mapping.of(groupsBySourceTree, reference.getSourceTree()).get().add(containingDir, reference);
        } else {
            // The reference is not inside any expected source tree, so don't try anything clever. Just
            // add it to the main group directly (not in a nested PBXGroup).
            result.add(reference);
        }
    }
    for (Groups groupsRoot : groupsBySourceTree.values()) {
        if (!groupsRoot.rootGroup().getChildren().isEmpty()) {
            result.add(groupsRoot.rootGroup());
        }
    }
    return result.build();
}
Also used : Path(java.nio.file.Path) PBXReference(com.facebook.buck.apple.xcode.xcodeproj.PBXReference) ImmutableList(com.google.common.collect.ImmutableList) SourceTree(com.facebook.buck.apple.xcode.xcodeproj.PBXReference.SourceTree)

Aggregations

PBXReference (com.facebook.buck.apple.xcode.xcodeproj.PBXReference)1 SourceTree (com.facebook.buck.apple.xcode.xcodeproj.PBXReference.SourceTree)1 ImmutableList (com.google.common.collect.ImmutableList)1 Path (java.nio.file.Path)1