use of com.google.common.collect.ImmutableMap in project buck by facebook.
the class RuleKeyBuilder method setReflectively.
/** Recursively serializes the value. Serialization of the key is handled outside. */
protected RuleKeyBuilder<RULE_KEY> setReflectively(@Nullable Object val) {
if (val instanceof RuleKeyAppendable) {
return setAppendableRuleKey((RuleKeyAppendable) val);
}
if (val instanceof BuildRule) {
return setBuildRule((BuildRule) val);
}
if (val instanceof Supplier) {
try (Scope containerScope = scopedHasher.wrapperScope(Wrapper.SUPPLIER)) {
Object newVal = ((Supplier<?>) val).get();
return setReflectively(newVal);
}
}
if (val instanceof Optional) {
Object o = ((Optional<?>) val).orElse(null);
try (Scope wraperScope = scopedHasher.wrapperScope(Wrapper.OPTIONAL)) {
return setReflectively(o);
}
}
if (val instanceof Either) {
Either<?, ?> either = (Either<?, ?>) val;
if (either.isLeft()) {
try (Scope wraperScope = scopedHasher.wrapperScope(Wrapper.EITHER_LEFT)) {
return setReflectively(either.getLeft());
}
} else {
try (Scope wraperScope = scopedHasher.wrapperScope(Wrapper.EITHER_RIGHT)) {
return setReflectively(either.getRight());
}
}
}
// Note {@link java.nio.file.Path} implements "Iterable", so we explicitly exclude it here.
if (val instanceof Iterable && !(val instanceof Path)) {
try (ContainerScope containerScope = scopedHasher.containerScope(Container.LIST)) {
for (Object element : (Iterable<?>) val) {
try (Scope elementScope = containerScope.elementScope()) {
setReflectively(element);
}
}
return this;
}
}
if (val instanceof Iterator) {
Iterator<?> iterator = (Iterator<?>) val;
try (ContainerScope containerScope = scopedHasher.containerScope(Container.LIST)) {
while (iterator.hasNext()) {
try (Scope elementScope = containerScope.elementScope()) {
setReflectively(iterator.next());
}
}
}
return this;
}
if (val instanceof Map) {
if (!(val instanceof SortedMap || val instanceof ImmutableMap)) {
logger.warn("Adding an unsorted map to the rule key. " + "Expect unstable ordering and caches misses: %s", val);
}
try (ContainerScope containerScope = scopedHasher.containerScope(Container.MAP)) {
for (Map.Entry<?, ?> entry : ((Map<?, ?>) val).entrySet()) {
try (Scope elementScope = containerScope.elementScope()) {
setReflectively(entry.getKey());
}
try (Scope elementScope = containerScope.elementScope()) {
setReflectively(entry.getValue());
}
}
}
return this;
}
if (val instanceof Path) {
throw new HumanReadableException("It's not possible to reliably disambiguate Paths. They are disallowed from rule keys");
}
if (val instanceof SourcePath) {
try {
return setSourcePath((SourcePath) val);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
if (val instanceof NonHashableSourcePathContainer) {
SourcePath sourcePath = ((NonHashableSourcePathContainer) val).getSourcePath();
return setNonHashingSourcePath(sourcePath);
}
if (val instanceof SourceWithFlags) {
SourceWithFlags source = (SourceWithFlags) val;
try {
setSourcePath(source.getSourcePath());
} catch (IOException e) {
throw new RuntimeException(e);
}
setReflectively(source.getFlags());
return this;
}
return setSingleValue(val);
}
use of com.google.common.collect.ImmutableMap in project buck by facebook.
the class RustCompileRule method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext buildContext, BuildableContext buildableContext) {
Path output = getOutput();
buildableContext.recordArtifact(output);
SourcePathResolver resolver = buildContext.getSourcePathResolver();
return ImmutableList.of(new MakeCleanDirectoryStep(getProjectFilesystem(), scratchDir), new SymlinkFilesIntoDirectoryStep(getProjectFilesystem(), getProjectFilesystem().getRootPath(), srcs.stream().map(resolver::getRelativePath).collect(MoreCollectors.toImmutableList()), scratchDir), new MakeCleanDirectoryStep(getProjectFilesystem(), getOutputDir(getBuildTarget(), getProjectFilesystem())), new ShellStep(getProjectFilesystem().getRootPath()) {
@Override
protected ImmutableList<String> getShellCommandInternal(ExecutionContext executionContext) {
ImmutableList<String> linkerCmd = linker.getCommandPrefix(resolver);
ImmutableList.Builder<String> cmd = ImmutableList.builder();
Path src = scratchDir.resolve(resolver.getRelativePath(rootModule));
cmd.addAll(compiler.getCommandPrefix(resolver)).addAll(executionContext.getAnsi().isAnsiTerminal() ? ImmutableList.of("--color=always") : ImmutableList.of()).add(String.format("-Clinker=%s", linkerCmd.get(0))).addAll(processLinkerArgs(linkerCmd.subList(1, linkerCmd.size()))).addAll(processLinkerArgs(Arg.stringify(linkerArgs, buildContext.getSourcePathResolver()))).addAll(Arg.stringify(args, buildContext.getSourcePathResolver())).add("-o", output.toString()).add(src.toString());
return cmd.build();
}
/*
* Make sure all stderr output from rustc is emitted, since its either a warning or an
* error. In general Rust code should have zero warnings, or all warnings as errors.
* Regardless, respect requests for silence.
*/
@Override
protected boolean shouldPrintStderr(Verbosity verbosity) {
return !verbosity.isSilent();
}
@Override
public ImmutableMap<String, String> getEnvironmentVariables(ExecutionContext context) {
return compiler.getEnvironment(buildContext.getSourcePathResolver());
}
@Override
public String getShortName() {
return "rust-build";
}
});
}
use of com.google.common.collect.ImmutableMap in project buck by facebook.
the class AppleCxxPlatforms method buildWithExecutableChecker.
@VisibleForTesting
static AppleCxxPlatform buildWithExecutableChecker(ProjectFilesystem filesystem, AppleSdk targetSdk, String minVersion, String targetArchitecture, final AppleSdkPaths sdkPaths, BuckConfig buckConfig, AppleConfig appleConfig, ExecutableFinder executableFinder, Optional<ProcessExecutor> processExecutor, Optional<AppleToolchain> swiftToolChain) {
AppleCxxPlatform.Builder platformBuilder = AppleCxxPlatform.builder();
ImmutableList.Builder<Path> toolSearchPathsBuilder = ImmutableList.builder();
// Search for tools from most specific to least specific.
toolSearchPathsBuilder.add(sdkPaths.getSdkPath().resolve(USR_BIN)).add(sdkPaths.getSdkPath().resolve("Developer").resolve(USR_BIN)).add(sdkPaths.getPlatformPath().resolve("Developer").resolve(USR_BIN));
for (Path toolchainPath : sdkPaths.getToolchainPaths()) {
toolSearchPathsBuilder.add(toolchainPath.resolve(USR_BIN));
}
if (sdkPaths.getDeveloperPath().isPresent()) {
toolSearchPathsBuilder.add(sdkPaths.getDeveloperPath().get().resolve(USR_BIN));
toolSearchPathsBuilder.add(sdkPaths.getDeveloperPath().get().resolve("Tools"));
}
// TODO(bhamiltoncx): Add more and better cflags.
ImmutableList.Builder<String> cflagsBuilder = ImmutableList.builder();
cflagsBuilder.add("-isysroot", sdkPaths.getSdkPath().toString());
cflagsBuilder.add("-iquote", filesystem.getRootPath().toString());
cflagsBuilder.add("-arch", targetArchitecture);
cflagsBuilder.add(targetSdk.getApplePlatform().getMinVersionFlagPrefix() + minVersion);
if (targetSdk.getApplePlatform().equals(ApplePlatform.WATCHOS)) {
cflagsBuilder.add("-fembed-bitcode");
}
ImmutableList.Builder<String> ldflagsBuilder = ImmutableList.builder();
ldflagsBuilder.addAll(Linkers.iXlinker("-sdk_version", targetSdk.getVersion(), "-ObjC"));
if (targetSdk.getApplePlatform().equals(ApplePlatform.WATCHOS)) {
ldflagsBuilder.addAll(Linkers.iXlinker("-bitcode_verify", "-bitcode_hide_symbols", "-bitcode_symbol_map"));
}
// Populate Xcode version keys from Xcode's own Info.plist if available.
Optional<String> xcodeBuildVersion = Optional.empty();
Optional<Path> developerPath = sdkPaths.getDeveloperPath();
if (developerPath.isPresent()) {
Path xcodeBundlePath = developerPath.get().getParent();
if (xcodeBundlePath != null) {
File xcodeInfoPlistPath = xcodeBundlePath.resolve("Info.plist").toFile();
try {
NSDictionary parsedXcodeInfoPlist = (NSDictionary) PropertyListParser.parse(xcodeInfoPlistPath);
NSObject xcodeVersionObject = parsedXcodeInfoPlist.objectForKey("DTXcode");
if (xcodeVersionObject != null) {
Optional<String> xcodeVersion = Optional.of(xcodeVersionObject.toString());
platformBuilder.setXcodeVersion(xcodeVersion);
}
} catch (IOException e) {
LOG.warn("Error reading Xcode's info plist %s; ignoring Xcode versions", xcodeInfoPlistPath);
} catch (PropertyListFormatException | ParseException | ParserConfigurationException | SAXException e) {
LOG.warn("Error in parsing %s; ignoring Xcode versions", xcodeInfoPlistPath);
}
}
// different than the build number in the Info.plist, sigh.
if (processExecutor.isPresent()) {
xcodeBuildVersion = appleConfig.getXcodeBuildVersionSupplier(developerPath.get(), processExecutor.get()).get();
platformBuilder.setXcodeBuildVersion(xcodeBuildVersion);
LOG.debug("Xcode build version is: " + xcodeBuildVersion.orElse("<absent>"));
}
}
ImmutableList.Builder<String> versions = ImmutableList.builder();
versions.add(targetSdk.getVersion());
ImmutableList<String> toolchainVersions = targetSdk.getToolchains().stream().map(AppleToolchain::getVersion).flatMap(Optionals::toStream).collect(MoreCollectors.toImmutableList());
if (toolchainVersions.isEmpty()) {
if (!xcodeBuildVersion.isPresent()) {
throw new HumanReadableException("Failed to read toolchain versions and Xcode version.");
}
versions.add(xcodeBuildVersion.get());
} else {
versions.addAll(toolchainVersions);
}
String version = Joiner.on(':').join(versions.build());
ImmutableList<Path> toolSearchPaths = toolSearchPathsBuilder.build();
Tool clangPath = VersionedTool.of(getToolPath("clang", toolSearchPaths, executableFinder), "apple-clang", version);
Tool clangXxPath = VersionedTool.of(getToolPath("clang++", toolSearchPaths, executableFinder), "apple-clang++", version);
Tool ar = VersionedTool.of(getToolPath("ar", toolSearchPaths, executableFinder), "apple-ar", version);
Tool ranlib = VersionedTool.builder().setPath(getToolPath("ranlib", toolSearchPaths, executableFinder)).setName("apple-ranlib").setVersion(version).build();
Tool strip = VersionedTool.of(getToolPath("strip", toolSearchPaths, executableFinder), "apple-strip", version);
Tool nm = VersionedTool.of(getToolPath("nm", toolSearchPaths, executableFinder), "apple-nm", version);
Tool actool = VersionedTool.of(getToolPath("actool", toolSearchPaths, executableFinder), "apple-actool", version);
Tool ibtool = VersionedTool.of(getToolPath("ibtool", toolSearchPaths, executableFinder), "apple-ibtool", version);
Tool momc = VersionedTool.of(getToolPath("momc", toolSearchPaths, executableFinder), "apple-momc", version);
Tool xctest = VersionedTool.of(getToolPath("xctest", toolSearchPaths, executableFinder), "apple-xctest", version);
Tool dsymutil = VersionedTool.of(getToolPath("dsymutil", toolSearchPaths, executableFinder), "apple-dsymutil", version);
Tool lipo = VersionedTool.of(getToolPath("lipo", toolSearchPaths, executableFinder), "apple-lipo", version);
Tool lldb = VersionedTool.of(getToolPath("lldb", toolSearchPaths, executableFinder), "lldb", version);
Optional<Path> stubBinaryPath = targetSdk.getApplePlatform().getStubBinaryPath().map(input -> sdkPaths.getSdkPath().resolve(input));
CxxBuckConfig config = new CxxBuckConfig(buckConfig);
UserFlavor targetFlavor = UserFlavor.of(Flavor.replaceInvalidCharacters(targetSdk.getName() + "-" + targetArchitecture), String.format("SDK: %s, architecture: %s", targetSdk.getName(), targetArchitecture));
ImmutableBiMap.Builder<Path, Path> sanitizerPaths = ImmutableBiMap.builder();
sanitizerPaths.put(sdkPaths.getSdkPath(), Paths.get("APPLE_SDKROOT"));
sanitizerPaths.put(sdkPaths.getPlatformPath(), Paths.get("APPLE_PLATFORM_DIR"));
if (sdkPaths.getDeveloperPath().isPresent()) {
sanitizerPaths.put(sdkPaths.getDeveloperPath().get(), Paths.get("APPLE_DEVELOPER_DIR"));
}
DebugPathSanitizer compilerDebugPathSanitizer = new PrefixMapDebugPathSanitizer(config.getDebugPathSanitizerLimit(), File.separatorChar, Paths.get("."), sanitizerPaths.build(), filesystem.getRootPath().toAbsolutePath(), CxxToolProvider.Type.CLANG, filesystem);
DebugPathSanitizer assemblerDebugPathSanitizer = new MungingDebugPathSanitizer(config.getDebugPathSanitizerLimit(), File.separatorChar, Paths.get("."), sanitizerPaths.build());
ImmutableList<String> cflags = cflagsBuilder.build();
ImmutableMap.Builder<String, String> macrosBuilder = ImmutableMap.builder();
macrosBuilder.put("SDKROOT", sdkPaths.getSdkPath().toString());
macrosBuilder.put("PLATFORM_DIR", sdkPaths.getPlatformPath().toString());
macrosBuilder.put("CURRENT_ARCH", targetArchitecture);
if (sdkPaths.getDeveloperPath().isPresent()) {
macrosBuilder.put("DEVELOPER_DIR", sdkPaths.getDeveloperPath().get().toString());
}
ImmutableMap<String, String> macros = macrosBuilder.build();
Optional<String> buildVersion = Optional.empty();
Path platformVersionPlistPath = sdkPaths.getPlatformPath().resolve("version.plist");
try (InputStream versionPlist = Files.newInputStream(platformVersionPlistPath)) {
NSDictionary versionInfo = (NSDictionary) PropertyListParser.parse(versionPlist);
if (versionInfo != null) {
NSObject productBuildVersion = versionInfo.objectForKey("ProductBuildVersion");
if (productBuildVersion != null) {
buildVersion = Optional.of(productBuildVersion.toString());
} else {
LOG.warn("In %s, missing ProductBuildVersion. Build version will be unset for this platform.", platformVersionPlistPath);
}
} else {
LOG.warn("Empty version plist in %s. Build version will be unset for this platform.", platformVersionPlistPath);
}
} catch (NoSuchFileException e) {
LOG.warn("%s does not exist. Build version will be unset for this platform.", platformVersionPlistPath);
} catch (PropertyListFormatException | SAXException | ParserConfigurationException | ParseException | IOException e) {
// Some other error occurred, print the exception since it may contain error details.
LOG.warn(e, "Failed to parse %s. Build version will be unset for this platform.", platformVersionPlistPath);
}
PreprocessorProvider aspp = new PreprocessorProvider(new ConstantToolProvider(clangPath), CxxToolProvider.Type.CLANG);
CompilerProvider as = new CompilerProvider(new ConstantToolProvider(clangPath), CxxToolProvider.Type.CLANG);
PreprocessorProvider cpp = new PreprocessorProvider(new ConstantToolProvider(clangPath), CxxToolProvider.Type.CLANG);
CompilerProvider cc = new CompilerProvider(new ConstantToolProvider(clangPath), CxxToolProvider.Type.CLANG);
PreprocessorProvider cxxpp = new PreprocessorProvider(new ConstantToolProvider(clangXxPath), CxxToolProvider.Type.CLANG);
CompilerProvider cxx = new CompilerProvider(new ConstantToolProvider(clangXxPath), CxxToolProvider.Type.CLANG);
ImmutableList.Builder<String> whitelistBuilder = ImmutableList.builder();
whitelistBuilder.add("^" + Pattern.quote(sdkPaths.getSdkPath().toString()) + "\\/.*");
whitelistBuilder.add("^" + Pattern.quote(sdkPaths.getPlatformPath().toString() + "/Developer/Library/Frameworks") + "\\/.*");
for (Path toolchainPath : sdkPaths.getToolchainPaths()) {
LOG.debug("Apple toolchain path: %s", toolchainPath);
try {
whitelistBuilder.add("^" + Pattern.quote(toolchainPath.toRealPath().toString()) + "\\/.*");
} catch (IOException e) {
LOG.warn(e, "Apple toolchain path could not be resolved: %s", toolchainPath);
}
}
HeaderVerification headerVerification = config.getHeaderVerification().withPlatformWhitelist(whitelistBuilder.build());
LOG.debug("Headers verification platform whitelist: %s", headerVerification.getPlatformWhitelist());
CxxPlatform cxxPlatform = CxxPlatforms.build(targetFlavor, Platform.MACOS, config, as, aspp, cc, cxx, cpp, cxxpp, new DefaultLinkerProvider(LinkerProvider.Type.DARWIN, new ConstantToolProvider(clangXxPath)), ImmutableList.<String>builder().addAll(cflags).addAll(ldflagsBuilder.build()).build(), strip, new BsdArchiver(ar), ranlib, new PosixNmSymbolNameTool(nm), cflagsBuilder.build(), ImmutableList.of(), cflags, ImmutableList.of(), "dylib", "%s.dylib", "a", "o", compilerDebugPathSanitizer, assemblerDebugPathSanitizer, macros, Optional.empty(), headerVerification);
ApplePlatform applePlatform = targetSdk.getApplePlatform();
ImmutableList.Builder<Path> swiftOverrideSearchPathBuilder = ImmutableList.builder();
AppleSdkPaths.Builder swiftSdkPathsBuilder = AppleSdkPaths.builder().from(sdkPaths);
if (swiftToolChain.isPresent()) {
swiftOverrideSearchPathBuilder.add(swiftToolChain.get().getPath().resolve(USR_BIN));
swiftSdkPathsBuilder.setToolchainPaths(ImmutableList.of(swiftToolChain.get().getPath()));
}
Optional<SwiftPlatform> swiftPlatform = getSwiftPlatform(applePlatform.getName(), targetArchitecture + "-apple-" + applePlatform.getSwiftName().orElse(applePlatform.getName()) + minVersion, version, swiftSdkPathsBuilder.build(), swiftOverrideSearchPathBuilder.addAll(toolSearchPaths).build(), executableFinder);
platformBuilder.setCxxPlatform(cxxPlatform).setSwiftPlatform(swiftPlatform).setAppleSdk(targetSdk).setAppleSdkPaths(sdkPaths).setMinVersion(minVersion).setBuildVersion(buildVersion).setActool(actool).setIbtool(ibtool).setMomc(momc).setCopySceneKitAssets(getOptionalTool("copySceneKitAssets", toolSearchPaths, executableFinder, version)).setXctest(xctest).setDsymutil(dsymutil).setLipo(lipo).setStubBinary(stubBinaryPath).setLldb(lldb).setCodesignAllocate(getOptionalTool("codesign_allocate", toolSearchPaths, executableFinder, version)).setCodesignProvider(appleConfig.getCodesignProvider());
return platformBuilder.build();
}
use of com.google.common.collect.ImmutableMap in project buck by facebook.
the class PreDexMerge method addStepsForSplitDex.
private void addStepsForSplitDex(ImmutableList.Builder<Step> steps, BuildableContext buildableContext) {
// Collect all of the DexWithClasses objects to use for merging.
ImmutableMultimap.Builder<APKModule, DexWithClasses> dexFilesToMergeBuilder = ImmutableMultimap.builder();
dexFilesToMergeBuilder.putAll(FluentIterable.from(preDexDeps.entries()).transform(input -> new AbstractMap.SimpleEntry<>(input.getKey(), DexWithClasses.TO_DEX_WITH_CLASSES.apply(input.getValue()))).filter(input -> input.getValue() != null).toSet());
final SplitDexPaths paths = new SplitDexPaths();
final ImmutableSet.Builder<Path> secondaryDexDirectories = ImmutableSet.builder();
if (dexSplitMode.getDexStore() == DexStore.RAW) {
// Raw classes*.dex files go in the top-level of the APK.
secondaryDexDirectories.add(paths.jarfilesSubdir);
} else {
// Otherwise, we want to include the metadata and jars as assets.
secondaryDexDirectories.add(paths.metadataDir);
secondaryDexDirectories.add(paths.jarfilesDir);
}
//always add additional dex stores and metadata as assets
secondaryDexDirectories.add(paths.additionalJarfilesDir);
// Do not clear existing directory which might contain secondary dex files that are not
// re-merged (since their contents did not change).
steps.add(new MkdirStep(getProjectFilesystem(), paths.jarfilesSubdir));
steps.add(new MkdirStep(getProjectFilesystem(), paths.additionalJarfilesSubdir));
steps.add(new MkdirStep(getProjectFilesystem(), paths.successDir));
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), paths.metadataSubdir));
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), paths.scratchDir));
buildableContext.addMetadata(SECONDARY_DEX_DIRECTORIES_KEY, secondaryDexDirectories.build().stream().map(Object::toString).collect(MoreCollectors.toImmutableList()));
buildableContext.recordArtifact(primaryDexPath);
buildableContext.recordArtifact(paths.jarfilesSubdir);
buildableContext.recordArtifact(paths.metadataSubdir);
buildableContext.recordArtifact(paths.successDir);
buildableContext.recordArtifact(paths.additionalJarfilesSubdir);
PreDexedFilesSorter preDexedFilesSorter = new PreDexedFilesSorter(Optional.ofNullable(DexWithClasses.TO_DEX_WITH_CLASSES.apply(dexForUberRDotJava)), dexFilesToMergeBuilder.build(), dexSplitMode.getPrimaryDexPatterns(), apkModuleGraph, paths.scratchDir, // to set the dex weight limit during pre-dex merging.
dexSplitMode.getLinearAllocHardLimit(), dexSplitMode.getDexStore(), paths.jarfilesSubdir, paths.additionalJarfilesSubdir);
final ImmutableMap<String, PreDexedFilesSorter.Result> sortResults = preDexedFilesSorter.sortIntoPrimaryAndSecondaryDexes(getProjectFilesystem(), steps);
PreDexedFilesSorter.Result rootApkModuleResult = sortResults.get(APKModuleGraph.ROOT_APKMODULE_NAME);
if (rootApkModuleResult == null) {
throw new HumanReadableException("No classes found in primary or secondary dexes");
}
Multimap<Path, Path> aggregatedOutputToInputs = HashMultimap.create();
ImmutableMap.Builder<Path, Sha1HashCode> dexInputHashesBuilder = ImmutableMap.builder();
for (PreDexedFilesSorter.Result result : sortResults.values()) {
if (!result.apkModule.equals(apkModuleGraph.getRootAPKModule())) {
Path dexOutputPath = paths.additionalJarfilesSubdir.resolve(result.apkModule.getName());
steps.add(new MkdirStep(getProjectFilesystem(), dexOutputPath));
}
aggregatedOutputToInputs.putAll(result.secondaryOutputToInputs);
dexInputHashesBuilder.putAll(result.dexInputHashes);
}
final ImmutableMap<Path, Sha1HashCode> dexInputHashes = dexInputHashesBuilder.build();
steps.add(new SmartDexingStep(getProjectFilesystem(), primaryDexPath, Suppliers.ofInstance(rootApkModuleResult.primaryDexInputs), Optional.of(paths.jarfilesSubdir), Optional.of(Suppliers.ofInstance(aggregatedOutputToInputs)), () -> dexInputHashes, paths.successDir, DX_MERGE_OPTIONS, dxExecutorService, xzCompressionLevel, dxMaxHeapSize));
// Record the primary dex SHA1 so exopackage apks can use it to compute their ABI keys.
// Single dex apks cannot be exopackages, so they will never need ABI keys.
steps.add(new RecordFileSha1Step(getProjectFilesystem(), primaryDexPath, PRIMARY_DEX_HASH_KEY, buildableContext));
for (PreDexedFilesSorter.Result result : sortResults.values()) {
if (!result.apkModule.equals(apkModuleGraph.getRootAPKModule())) {
Path dexMetadataOutputPath = paths.additionalJarfilesSubdir.resolve(result.apkModule.getName()).resolve("metadata.txt");
addMetadataWriteStep(result, steps, dexMetadataOutputPath);
}
}
addMetadataWriteStep(rootApkModuleResult, steps, paths.metadataFile);
}
use of com.google.common.collect.ImmutableMap in project buck by facebook.
the class ProguardMapping method readClassMapping.
public static ImmutableMap<String, String> readClassMapping(Iterable<String> lines) {
ImmutableMap.Builder<String, String> classMappingBuilder = ImmutableMap.builder();
for (String line : lines) {
if (line.charAt(0) == ' ') {
// This is a member mapping, which we don't handle yet.
continue;
}
Matcher matcher = CLASS_LINE_PATTERN.matcher(line);
if (!matcher.matches()) {
throw new IllegalArgumentException("Invalid line in proguard mapping: " + line);
}
classMappingBuilder.put(matcher.group(1), matcher.group(2));
}
return classMappingBuilder.build();
}
Aggregations