Search in sources :

Example 11 with PBXBuildPhase

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

the class ProjectGenerator method getCopyFilesBuildPhases.

private ImmutableList<PBXBuildPhase> getCopyFilesBuildPhases(Iterable<TargetNode<?, ?>> copiedNodes) {
    // Bucket build rules into bins by their destinations
    ImmutableSetMultimap.Builder<CopyFilePhaseDestinationSpec, TargetNode<?, ?>> ruleByDestinationSpecBuilder = ImmutableSetMultimap.builder();
    for (TargetNode<?, ?> copiedNode : copiedNodes) {
        Optional<CopyFilePhaseDestinationSpec> optionalDestinationSpec = getDestinationSpec(copiedNode);
        if (optionalDestinationSpec.isPresent()) {
            ruleByDestinationSpecBuilder.put(optionalDestinationSpec.get(), copiedNode);
        }
    }
    ImmutableList.Builder<PBXBuildPhase> phases = ImmutableList.builder();
    ImmutableSetMultimap<CopyFilePhaseDestinationSpec, TargetNode<?, ?>> ruleByDestinationSpec = ruleByDestinationSpecBuilder.build();
    // Emit a copy files phase for each destination.
    for (CopyFilePhaseDestinationSpec destinationSpec : ruleByDestinationSpec.keySet()) {
        Iterable<TargetNode<?, ?>> targetNodes = ruleByDestinationSpec.get(destinationSpec);
        phases.add(getSingleCopyFilesBuildPhase(destinationSpec, targetNodes));
    }
    return phases.build();
}
Also used : CopyFilePhaseDestinationSpec(com.facebook.buck.apple.xcode.xcodeproj.CopyFilePhaseDestinationSpec) TargetNode(com.facebook.buck.rules.TargetNode) ImmutableSetMultimap(com.google.common.collect.ImmutableSetMultimap) ImmutableList(com.google.common.collect.ImmutableList) PBXBuildPhase(com.facebook.buck.apple.xcode.xcodeproj.PBXBuildPhase)

Example 12 with PBXBuildPhase

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

the class NewNativeTargetProjectMutator method addResourcesBuildPhase.

private PBXBuildPhase addResourcesBuildPhase(PBXNativeTarget target, PBXGroup targetGroup) {
    ImmutableSet.Builder<Path> resourceFiles = ImmutableSet.builder();
    ImmutableSet.Builder<Path> resourceDirs = ImmutableSet.builder();
    ImmutableSet.Builder<Path> variantResourceFiles = ImmutableSet.builder();
    collectResourcePathsFromConstructorArgs(recursiveResources, recursiveAssetCatalogs, wrapperResources, resourceFiles, resourceDirs, variantResourceFiles);
    final PBXBuildPhase phase = new PBXResourcesBuildPhase();
    addResourcesFileReference(targetGroup, resourceFiles.build(), resourceDirs.build(), variantResourceFiles.build(), input -> {
        PBXBuildFile buildFile = new PBXBuildFile(input);
        phase.getFiles().add(buildFile);
    }, input -> {
        PBXBuildFile buildFile = new PBXBuildFile(input);
        phase.getFiles().add(buildFile);
    });
    if (!phase.getFiles().isEmpty()) {
        target.getBuildPhases().add(phase);
        LOG.debug("Added resources build phase %s", phase);
    }
    return phase;
}
Also used : SourceTreePath(com.facebook.buck.apple.xcode.xcodeproj.SourceTreePath) Path(java.nio.file.Path) FrameworkPath(com.facebook.buck.rules.coercer.FrameworkPath) SourcePath(com.facebook.buck.rules.SourcePath) ImmutableSet(com.google.common.collect.ImmutableSet) PBXBuildFile(com.facebook.buck.apple.xcode.xcodeproj.PBXBuildFile) PBXBuildPhase(com.facebook.buck.apple.xcode.xcodeproj.PBXBuildPhase) PBXResourcesBuildPhase(com.facebook.buck.apple.xcode.xcodeproj.PBXResourcesBuildPhase)

Aggregations

PBXBuildPhase (com.facebook.buck.apple.xcode.xcodeproj.PBXBuildPhase)12 Test (org.junit.Test)8 TargetNode (com.facebook.buck.rules.TargetNode)7 PBXTarget (com.facebook.buck.apple.xcode.xcodeproj.PBXTarget)6 BuildTarget (com.facebook.buck.model.BuildTarget)6 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)6 SourcePath (com.facebook.buck.rules.SourcePath)6 PBXCopyFilesBuildPhase (com.facebook.buck.apple.xcode.xcodeproj.PBXCopyFilesBuildPhase)5 SourceTreePath (com.facebook.buck.apple.xcode.xcodeproj.SourceTreePath)5 PathSourcePath (com.facebook.buck.rules.PathSourcePath)5 TargetGraph (com.facebook.buck.rules.TargetGraph)5 FrameworkPath (com.facebook.buck.rules.coercer.FrameworkPath)5 Path (java.nio.file.Path)5 AppleDependenciesCache (com.facebook.buck.apple.AppleDependenciesCache)4 PBXShellScriptBuildPhase (com.facebook.buck.apple.xcode.xcodeproj.PBXShellScriptBuildPhase)4 AlwaysFoundExecutableFinder (com.facebook.buck.io.AlwaysFoundExecutableFinder)4 DefaultBuildTargetSourcePath (com.facebook.buck.rules.DefaultBuildTargetSourcePath)4 CopyFilePhaseDestinationSpec (com.facebook.buck.apple.xcode.xcodeproj.CopyFilePhaseDestinationSpec)3 PBXBuildFile (com.facebook.buck.apple.xcode.xcodeproj.PBXBuildFile)3 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)3