use of 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();
}
use of 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();
}
use of 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);
}
}
use of 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();
}
use of 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();
}
Aggregations