use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableList in project buck by facebook.
the class AppleCxxPlatforms method getSwiftPlatform.
private static Optional<SwiftPlatform> getSwiftPlatform(String platformName, String targetArchitectureName, String version, AbstractAppleSdkPaths sdkPaths, ImmutableList<Path> toolSearchPaths, ExecutableFinder executableFinder) {
ImmutableList<String> swiftParams = ImmutableList.of("-frontend", "-sdk", sdkPaths.getSdkPath().toString(), "-target", targetArchitectureName);
ImmutableList.Builder<String> swiftStdlibToolParamsBuilder = ImmutableList.builder();
swiftStdlibToolParamsBuilder.add("--copy").add("--verbose").add("--strip-bitcode").add("--platform").add(platformName);
for (Path toolchainPath : sdkPaths.getToolchainPaths()) {
swiftStdlibToolParamsBuilder.add("--toolchain").add(toolchainPath.toString());
}
Optional<Tool> swift = getOptionalToolWithParams("swift", toolSearchPaths, executableFinder, version, swiftParams);
Optional<Tool> swiftStdLibTool = getOptionalToolWithParams("swift-stdlib-tool", toolSearchPaths, executableFinder, version, swiftStdlibToolParamsBuilder.build());
if (swift.isPresent() && swiftStdLibTool.isPresent()) {
return Optional.of(SwiftPlatforms.build(platformName, sdkPaths.getToolchainPaths(), swift.get(), swiftStdLibTool.get()));
} else {
return Optional.empty();
}
}
use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableList in project buck by facebook.
the class PreDexMerge method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
ImmutableList.Builder<Step> steps = ImmutableList.builder();
steps.add(new MkdirStep(getProjectFilesystem(), primaryDexPath.getParent()));
if (dexSplitMode.isShouldSplitDex()) {
addStepsForSplitDex(steps, buildableContext);
} else {
addStepsForSingleDex(steps, buildableContext);
}
return steps.build();
}
use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableList in project buck by facebook.
the class MergeAndroidResourcesStep method writePerPackageRDotJava.
@VisibleForTesting
void writePerPackageRDotJava(SortedSetMultimap<String, RDotTxtEntry> packageToResources, ProjectFilesystem filesystem) throws IOException {
for (String rDotJavaPackage : packageToResources.keySet()) {
Path outputFile = getPathToRDotJava(rDotJavaPackage);
filesystem.mkdirs(outputFile.getParent());
try (PrintWriter writer = new PrintWriter(filesystem.newFileOutputStream(outputFile))) {
writer.format("package %s;\n\n", rDotJavaPackage);
writer.format("public class %s {\n", rName);
ImmutableList.Builder<String> customDrawablesBuilder = ImmutableList.builder();
ImmutableList.Builder<String> grayscaleImagesBuilder = ImmutableList.builder();
RDotTxtEntry.RType lastType = null;
for (RDotTxtEntry res : packageToResources.get(rDotJavaPackage)) {
RDotTxtEntry.RType type = res.type;
if (!type.equals(lastType)) {
// If the previous type needs to be closed, close it.
if (lastType != null) {
writer.println(" }\n");
}
// Now start the block for the new type.
writer.format(" public static class %s {\n", type);
lastType = type;
}
// Write out the resource.
// Write as an int.
writer.format(" public static%s%s %s=%s;\n", forceFinalResourceIds ? " final " : " ", res.idType, res.name, res.idValue);
if (type == RDotTxtEntry.RType.DRAWABLE && res.customType == RDotTxtEntry.CustomDrawableType.CUSTOM) {
customDrawablesBuilder.add(res.idValue);
} else if (type == RDotTxtEntry.RType.DRAWABLE && res.customType == RDotTxtEntry.CustomDrawableType.GRAYSCALE_IMAGE) {
grayscaleImagesBuilder.add(res.idValue);
}
}
// closed.
if (lastType != null) {
writer.println(" }\n");
}
ImmutableList<String> customDrawables = customDrawablesBuilder.build();
if (customDrawables.size() > 0) {
// Add a new field for the custom drawables.
writer.format(" public static final int[] custom_drawables = ");
writer.format("{ %s };\n", Joiner.on(",").join(customDrawables));
writer.format("\n");
}
ImmutableList<String> grayscaleImages = grayscaleImagesBuilder.build();
if (grayscaleImages.size() > 0) {
// Add a new field for the custom drawables.
writer.format(" public static final int[] grayscale_images = ");
writer.format("{ %s };\n", Joiner.on(",").join(grayscaleImages));
writer.format("\n");
}
// Close the class definition.
writer.println("}");
}
}
}
use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableList in project buck by facebook.
the class AppleAssetCatalog method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
ImmutableList.Builder<Step> stepsBuilder = ImmutableList.builder();
stepsBuilder.add(new MakeCleanDirectoryStep(getProjectFilesystem(), outputDir));
stepsBuilder.add(new MkdirStep(getProjectFilesystem(), outputPlist.getParent()));
ImmutableSortedSet<Path> absoluteAssetCatalogDirs = context.getSourcePathResolver().getAllAbsolutePaths(assetCatalogDirs);
stepsBuilder.add(new ActoolStep(getProjectFilesystem().getRootPath(), applePlatformName, actool.getEnvironment(context.getSourcePathResolver()), actool.getCommandPrefix(context.getSourcePathResolver()), absoluteAssetCatalogDirs, getProjectFilesystem().resolve(outputDir), getProjectFilesystem().resolve(outputPlist), appIcon, launchImage, optimization));
buildableContext.recordArtifact(getOutputDir());
buildableContext.recordArtifact(outputPlist);
return stepsBuilder.build();
}
use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableList in project buck by facebook.
the class SplitZipStep method execute.
@Override
public StepExecutionResult execute(ExecutionContext context) {
try {
Set<Path> inputJarPaths = inputPathsToSplit.stream().map(filesystem::resolve).collect(MoreCollectors.toImmutableSet());
Supplier<ImmutableList<ClassNode>> classes = ClassNodeListSupplier.createMemoized(inputJarPaths);
ProguardTranslatorFactory translatorFactory = ProguardTranslatorFactory.create(filesystem, proguardFullConfigFile, proguardMappingFile, skipProguard);
Predicate<String> requiredInPrimaryZip = createRequiredInPrimaryZipPredicate(translatorFactory, classes);
final ImmutableSet<String> wantedInPrimaryZip = getWantedPrimaryDexEntries(translatorFactory, classes);
final ImmutableSet<String> secondaryHeadSet = getSecondaryHeadSet(translatorFactory);
final ImmutableSet<String> secondaryTailSet = getSecondaryTailSet(translatorFactory);
final ImmutableMultimap<APKModule, String> additionalDexStoreClasses = APKModuleGraph.getAPKModuleToClassesMap(apkModuleToJarPathMap, translatorFactory.createObfuscationFunction(), filesystem);
ZipSplitterFactory zipSplitterFactory;
zipSplitterFactory = new DalvikAwareZipSplitterFactory(dexSplitMode.getLinearAllocHardLimit(), wantedInPrimaryZip);
outputFiles = zipSplitterFactory.newInstance(filesystem, inputJarPaths, primaryJarPath, secondaryJarDir, secondaryJarPattern, additionalDexStoreJarDir, requiredInPrimaryZip, secondaryHeadSet, secondaryTailSet, additionalDexStoreClasses, apkModuleGraph, dexSplitMode.getDexSplitStrategy(), ZipSplitter.CanaryStrategy.INCLUDE_CANARIES, filesystem.getPathForRelativePath(pathToReportDir)).execute();
for (APKModule dexStore : outputFiles.keySet()) {
if (dexStore.getName().equals(SECONDARY_DEX_ID)) {
try (BufferedWriter secondaryMetaInfoWriter = Files.newWriter(secondaryJarMetaPath.toFile(), Charsets.UTF_8)) {
writeMetaList(secondaryMetaInfoWriter, SECONDARY_DEX_ID, ImmutableSet.of(), outputFiles.get(dexStore).asList(), dexSplitMode.getDexStore());
}
} else {
try (BufferedWriter secondaryMetaInfoWriter = Files.newWriter(addtionalDexStoreJarMetaPath.resolve("assets").resolve(dexStore.getName()).resolve("metadata.txt").toFile(), Charsets.UTF_8)) {
writeMetaList(secondaryMetaInfoWriter, dexStore.getName(), apkModuleGraph.getGraph().getOutgoingNodesFor(dexStore), outputFiles.get(dexStore).asList(), dexSplitMode.getDexStore());
}
}
}
return StepExecutionResult.SUCCESS;
} catch (IOException e) {
context.logError(e, "There was an error running SplitZipStep.");
return StepExecutionResult.ERROR;
}
}
Aggregations