Search in sources :

Example 1 with AppleBundleExtension

use of com.facebook.buck.apple.AppleBundleExtension in project buck by facebook.

the class ProjectGenerator method getDestinationSpec.

private Optional<CopyFilePhaseDestinationSpec> getDestinationSpec(TargetNode<?, ?> targetNode) {
    if (targetNode.getDescription() instanceof AppleBundleDescription) {
        AppleBundleDescription.Arg arg = (AppleBundleDescription.Arg) targetNode.getConstructorArg();
        AppleBundleExtension extension = arg.extension.isLeft() ? arg.extension.getLeft() : AppleBundleExtension.BUNDLE;
        switch(extension) {
            case FRAMEWORK:
                return Optional.of(CopyFilePhaseDestinationSpec.of(PBXCopyFilesBuildPhase.Destination.FRAMEWORKS));
            case APPEX:
            case PLUGIN:
                return Optional.of(CopyFilePhaseDestinationSpec.of(PBXCopyFilesBuildPhase.Destination.PLUGINS));
            case APP:
                if (isWatchApplicationNode(targetNode)) {
                    return Optional.of(CopyFilePhaseDestinationSpec.builder().setDestination(PBXCopyFilesBuildPhase.Destination.PRODUCTS).setPath("$(CONTENTS_FOLDER_PATH)/Watch").build());
                } else {
                    return Optional.of(CopyFilePhaseDestinationSpec.of(PBXCopyFilesBuildPhase.Destination.EXECUTABLES));
                }
            case BUNDLE:
                return Optional.of(CopyFilePhaseDestinationSpec.of(PBXCopyFilesBuildPhase.Destination.PLUGINS));
            //$CASES-OMITTED$
            default:
                return Optional.of(CopyFilePhaseDestinationSpec.of(PBXCopyFilesBuildPhase.Destination.PRODUCTS));
        }
    } else if (targetNode.getDescription() instanceof AppleLibraryDescription || targetNode.getDescription() instanceof CxxLibraryDescription) {
        if (targetNode.getBuildTarget().getFlavors().contains(CxxDescriptionEnhancer.SHARED_FLAVOR)) {
            return Optional.of(CopyFilePhaseDestinationSpec.of(PBXCopyFilesBuildPhase.Destination.FRAMEWORKS));
        } else {
            return Optional.empty();
        }
    } else if (targetNode.getDescription() instanceof AppleBinaryDescription) {
        return Optional.of(CopyFilePhaseDestinationSpec.of(PBXCopyFilesBuildPhase.Destination.EXECUTABLES));
    } else if (targetNode.getDescription() instanceof HalideLibraryDescription) {
        return Optional.empty();
    } else if (targetNode.getDescription() instanceof CoreDataModelDescription || targetNode.getDescription() instanceof SceneKitAssetsDescription) {
        return Optional.of(CopyFilePhaseDestinationSpec.of(PBXCopyFilesBuildPhase.Destination.RESOURCES));
    } else {
        throw new RuntimeException("Unexpected type: " + targetNode.getDescription().getClass());
    }
}
Also used : SceneKitAssetsDescription(com.facebook.buck.apple.SceneKitAssetsDescription) CxxLibraryDescription(com.facebook.buck.cxx.CxxLibraryDescription) AppleNativeTargetDescriptionArg(com.facebook.buck.apple.AppleNativeTargetDescriptionArg) StringWithMacrosArg(com.facebook.buck.rules.args.StringWithMacrosArg) AppleWrapperResourceArg(com.facebook.buck.apple.AppleWrapperResourceArg) CoreDataModelDescription(com.facebook.buck.apple.CoreDataModelDescription) AppleBundleDescription(com.facebook.buck.apple.AppleBundleDescription) HalideLibraryDescription(com.facebook.buck.halide.HalideLibraryDescription) AppleBundleExtension(com.facebook.buck.apple.AppleBundleExtension) AppleBinaryDescription(com.facebook.buck.apple.AppleBinaryDescription) AppleLibraryDescription(com.facebook.buck.apple.AppleLibraryDescription)

Aggregations

AppleBinaryDescription (com.facebook.buck.apple.AppleBinaryDescription)1 AppleBundleDescription (com.facebook.buck.apple.AppleBundleDescription)1 AppleBundleExtension (com.facebook.buck.apple.AppleBundleExtension)1 AppleLibraryDescription (com.facebook.buck.apple.AppleLibraryDescription)1 AppleNativeTargetDescriptionArg (com.facebook.buck.apple.AppleNativeTargetDescriptionArg)1 AppleWrapperResourceArg (com.facebook.buck.apple.AppleWrapperResourceArg)1 CoreDataModelDescription (com.facebook.buck.apple.CoreDataModelDescription)1 SceneKitAssetsDescription (com.facebook.buck.apple.SceneKitAssetsDescription)1 CxxLibraryDescription (com.facebook.buck.cxx.CxxLibraryDescription)1 HalideLibraryDescription (com.facebook.buck.halide.HalideLibraryDescription)1 StringWithMacrosArg (com.facebook.buck.rules.args.StringWithMacrosArg)1