Search in sources :

Example 16 with ImmutableList

use of org.apache.flink.shaded.guava30.com.google.common.collect.ImmutableList in project buck by facebook.

the class MultiarchFile method getBuildSteps.

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
    buildableContext.recordArtifact(output);
    ImmutableList.Builder<Step> steps = ImmutableList.builder();
    steps.add(new MkdirStep(getProjectFilesystem(), output.getParent()));
    lipoBinaries(context, steps);
    copyLinkMaps(buildableContext, steps);
    return steps.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) MkdirStep(com.facebook.buck.step.fs.MkdirStep) Step(com.facebook.buck.step.Step) CopyStep(com.facebook.buck.step.fs.CopyStep) MkdirStep(com.facebook.buck.step.fs.MkdirStep) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) DefaultShellStep(com.facebook.buck.shell.DefaultShellStep)

Example 17 with ImmutableList

use of org.apache.flink.shaded.guava30.com.google.common.collect.ImmutableList in project buck by facebook.

the class MultiarchFileInfos method generateThinFlavors.

/**
   * Expand flavors representing a fat binary into its thin binary equivalents.
   *
   * Useful when dealing with functions unaware of fat binaries.
   *
   * This does not actually check that the particular flavor set is valid.
   */
public static ImmutableList<ImmutableSortedSet<Flavor>> generateThinFlavors(Set<Flavor> platformFlavors, SortedSet<Flavor> flavors) {
    Set<Flavor> platformFreeFlavors = Sets.difference(flavors, platformFlavors);
    ImmutableList.Builder<ImmutableSortedSet<Flavor>> thinTargetsBuilder = ImmutableList.builder();
    for (Flavor flavor : flavors) {
        if (platformFlavors.contains(flavor)) {
            thinTargetsBuilder.add(ImmutableSortedSet.<Flavor>naturalOrder().addAll(platformFreeFlavors).add(flavor).build());
        }
    }
    return thinTargetsBuilder.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet) Flavor(com.facebook.buck.model.Flavor)

Example 18 with ImmutableList

use of org.apache.flink.shaded.guava30.com.google.common.collect.ImmutableList in project buck by facebook.

the class ProvisioningProfileCopyStep method execute.

@Override
public StepExecutionResult execute(ExecutionContext context) throws InterruptedException {
    final String bundleID;
    try {
        bundleID = AppleInfoPlistParsing.getBundleIdFromPlistStream(filesystem.getInputStreamForRelativePath(infoPlist)).get();
    } catch (IOException e) {
        throw new HumanReadableException("Unable to get bundle ID from info.plist: " + infoPlist);
    }
    final Optional<ImmutableMap<String, NSObject>> entitlements;
    final String prefix;
    if (entitlementsPlist.isPresent()) {
        try {
            NSDictionary entitlementsPlistDict = (NSDictionary) PropertyListParser.parse(entitlementsPlist.get().toFile());
            entitlements = Optional.of(ImmutableMap.copyOf(entitlementsPlistDict.getHashMap()));
            prefix = ProvisioningProfileMetadata.prefixFromEntitlements(entitlements.get()).orElse("*");
        } catch (IOException e) {
            throw new HumanReadableException("Unable to find entitlement .plist: " + entitlementsPlist.get());
        } catch (Exception e) {
            throw new HumanReadableException("Malformed entitlement .plist: " + entitlementsPlist.get());
        }
    } else {
        entitlements = ProvisioningProfileStore.MATCH_ANY_ENTITLEMENT;
        prefix = "*";
    }
    final Optional<ImmutableList<CodeSignIdentity>> identities;
    if (!codeSignIdentityStore.getIdentities().isEmpty()) {
        identities = Optional.of(codeSignIdentityStore.getIdentities());
    } else {
        identities = ProvisioningProfileStore.MATCH_ANY_IDENTITY;
    }
    Optional<ProvisioningProfileMetadata> bestProfile = provisioningProfileUUID.isPresent() ? provisioningProfileStore.getProvisioningProfileByUUID(provisioningProfileUUID.get()) : provisioningProfileStore.getBestProvisioningProfile(bundleID, platform, entitlements, identities);
    if (dryRunResultsPath.isPresent()) {
        try {
            NSDictionary dryRunResult = new NSDictionary();
            dryRunResult.put(BUNDLE_ID, bundleID);
            dryRunResult.put(ENTITLEMENTS, entitlements.orElse(ImmutableMap.of()));
            if (bestProfile.isPresent()) {
                dryRunResult.put(PROFILE_UUID, bestProfile.get().getUUID());
                dryRunResult.put(PROFILE_FILENAME, bestProfile.get().getProfilePath().getFileName().toString());
                dryRunResult.put(TEAM_IDENTIFIER, bestProfile.get().getEntitlements().get("com.apple.developer.team-identifier"));
            }
            filesystem.writeContentsToPath(dryRunResult.toXMLPropertyList(), dryRunResultsPath.get());
        } catch (IOException e) {
            context.logError(e, "Failed when trying to write dry run results: %s", getDescription(context));
            return StepExecutionResult.ERROR;
        }
    }
    selectedProvisioningProfileFuture.set(bestProfile);
    if (!bestProfile.isPresent()) {
        String message = "No valid non-expired provisioning profiles match for " + prefix + "." + bundleID;
        if (dryRunResultsPath.isPresent()) {
            LOG.warn(message);
            return StepExecutionResult.SUCCESS;
        } else {
            throw new HumanReadableException(message);
        }
    }
    Path provisioningProfileSource = bestProfile.get().getProfilePath();
    // Copy the actual .mobileprovision.
    try {
        filesystem.copy(provisioningProfileSource, provisioningProfileDestination, CopySourceMode.FILE);
    } catch (IOException e) {
        context.logError(e, "Failed when trying to copy: %s", getDescription(context));
        return StepExecutionResult.ERROR;
    }
    // Merge the entitlements with the profile, and write out.
    if (entitlementsPlist.isPresent()) {
        return (new PlistProcessStep(filesystem, entitlementsPlist.get(), Optional.empty(), signingEntitlementsTempPath, bestProfile.get().getMergeableEntitlements(), ImmutableMap.of(), PlistProcessStep.OutputFormat.XML)).execute(context);
    } else {
        // No entitlements.plist explicitly specified; write out the minimal entitlements needed.
        String appID = bestProfile.get().getAppID().getFirst() + "." + bundleID;
        NSDictionary entitlementsPlist = new NSDictionary();
        entitlementsPlist.putAll(bestProfile.get().getMergeableEntitlements());
        entitlementsPlist.put(APPLICATION_IDENTIFIER, appID);
        entitlementsPlist.put(KEYCHAIN_ACCESS_GROUPS, new String[] { appID });
        return (new WriteFileStep(filesystem, entitlementsPlist.toXMLPropertyList(), signingEntitlementsTempPath, /* executable */
        false)).execute(context);
    }
}
Also used : Path(java.nio.file.Path) NSDictionary(com.dd.plist.NSDictionary) ImmutableList(com.google.common.collect.ImmutableList) IOException(java.io.IOException) ImmutableMap(com.google.common.collect.ImmutableMap) IOException(java.io.IOException) HumanReadableException(com.facebook.buck.util.HumanReadableException) HumanReadableException(com.facebook.buck.util.HumanReadableException) WriteFileStep(com.facebook.buck.step.fs.WriteFileStep)

Example 19 with ImmutableList

use of org.apache.flink.shaded.guava30.com.google.common.collect.ImmutableList in project buck by facebook.

the class RuleUtils method createGroupsFromEntryMaps.

@VisibleForTesting
static ImmutableList<GroupedSource> createGroupsFromEntryMaps(Multimap<Path, String> subgroups, Multimap<Path, GroupedSource> entries, Comparator<GroupedSource> comparator, Path rootGroupPath, Path groupPath) {
    ImmutableList.Builder<GroupedSource> groupBuilder = ImmutableList.builder();
    for (String subgroupName : ImmutableSortedSet.copyOf(subgroups.get(groupPath))) {
        Path subgroupPath = groupPath.resolve(subgroupName);
        groupBuilder.add(GroupedSource.ofSourceGroup(subgroupName, subgroupPath.subpath(rootGroupPath.getNameCount(), subgroupPath.getNameCount()), createGroupsFromEntryMaps(subgroups, entries, comparator, rootGroupPath, subgroupPath)));
    }
    SortedSet<GroupedSource> sortedEntries = ImmutableSortedSet.copyOf(comparator, entries.get(groupPath));
    for (GroupedSource groupedSource : sortedEntries) {
        groupBuilder.add(groupedSource);
    }
    return groupBuilder.build().asList();
}
Also used : SourcePath(com.facebook.buck.rules.SourcePath) Path(java.nio.file.Path) ImmutableList(com.google.common.collect.ImmutableList) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 20 with ImmutableList

use of org.apache.flink.shaded.guava30.com.google.common.collect.ImmutableList in project buck by facebook.

the class SceneKitAssets method getBuildSteps.

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
    ImmutableList.Builder<Step> stepsBuilder = ImmutableList.builder();
    stepsBuilder.add(new MakeCleanDirectoryStep(getProjectFilesystem(), outputDir));
    for (SourcePath inputPath : sceneKitAssetsPaths) {
        final Path absoluteInputPath = context.getSourcePathResolver().getAbsolutePath(inputPath);
        if (copySceneKitAssets.isPresent()) {
            stepsBuilder.add(new ShellStep(getProjectFilesystem().getRootPath()) {

                @Override
                protected ImmutableList<String> getShellCommandInternal(ExecutionContext executionContext) {
                    ImmutableList.Builder<String> commandBuilder = ImmutableList.builder();
                    commandBuilder.addAll(copySceneKitAssets.get().getCommandPrefix(context.getSourcePathResolver()));
                    commandBuilder.add(absoluteInputPath.toString(), "-o", getProjectFilesystem().resolve(outputDir).resolve(absoluteInputPath.getFileName()).toString(), "--target-platform=" + sdkName, "--target-version=" + minOSVersion);
                    return commandBuilder.build();
                }

                @Override
                public ImmutableMap<String, String> getEnvironmentVariables(ExecutionContext executionContext) {
                    return copySceneKitAssets.get().getEnvironment(context.getSourcePathResolver());
                }

                @Override
                public String getShortName() {
                    return "copy-scenekit-assets";
                }
            });
        } else {
            stepsBuilder.add(CopyStep.forDirectory(getProjectFilesystem(), absoluteInputPath, outputDir, CopyStep.DirectoryMode.CONTENTS_ONLY));
        }
    }
    buildableContext.recordArtifact(context.getSourcePathResolver().getRelativePath(getSourcePathToOutput()));
    return stepsBuilder.build();
}
Also used : ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) SourcePath(com.facebook.buck.rules.SourcePath) ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) SourcePath(com.facebook.buck.rules.SourcePath) Path(java.nio.file.Path) ExecutionContext(com.facebook.buck.step.ExecutionContext) ImmutableList(com.google.common.collect.ImmutableList) ShellStep(com.facebook.buck.shell.ShellStep) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) Step(com.facebook.buck.step.Step) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) CopyStep(com.facebook.buck.step.fs.CopyStep) ShellStep(com.facebook.buck.shell.ShellStep) ImmutableMap(com.google.common.collect.ImmutableMap)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1056 List (java.util.List)291 ArrayList (java.util.ArrayList)166 Test (org.junit.Test)156 Path (java.nio.file.Path)149 Map (java.util.Map)149 ImmutableMap (com.google.common.collect.ImmutableMap)124 IOException (java.io.IOException)111 Set (java.util.Set)99 ImmutableSet (com.google.common.collect.ImmutableSet)97 SourcePath (com.facebook.buck.rules.SourcePath)91 Optional (java.util.Optional)87 HashMap (java.util.HashMap)84 Step (com.facebook.buck.step.Step)76 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)71 Collectors (java.util.stream.Collectors)61 File (java.io.File)58 HashSet (java.util.HashSet)57 Nullable (javax.annotation.Nullable)54 ExplicitBuildTargetSourcePath (com.facebook.buck.rules.ExplicitBuildTargetSourcePath)52