private boolean waitForPredexFile(Item item, File outFile, boolean multiDex) throws InterruptedException, IOException { // wait until the file is pre-dexed by the first thread. item.getLatch().await(); // check that the generated file actually exists if (item.areOutputFilesPresent()) { if (multiDex) { // output should be a folder for (File sourceFile : item.getOutputFiles()) { File destFile = new File(outFile, sourceFile.getName()); checkSame(sourceFile, destFile); Files.copy(sourceFile, destFile); } } else { // file already pre-dex, just copy the output. if (item.getOutputFiles().isEmpty()) { throw new RuntimeException(item.toString()); } checkSame(item.getOutputFiles().get(0), outFile); Files.copy(item.getOutputFiles().get(0), outFile); } incrementHits(); return true; } return false; }
/** * Converts the bytecode to Dalvik format * @param inputFile the input file * @param outFile the output file or folder if multi-dex is enabled. * @param multiDex whether multidex is enabled. * @param dexOptions dex options * * @throws IOException * @throws InterruptedException * @throws ProcessException */ public void preDexLibrary( @NonNull File inputFile, @NonNull File outFile, boolean multiDex, @NonNull DexOptions dexOptions) throws IOException, InterruptedException, ProcessException { checkState(mTargetInfo != null, "Cannot call preDexLibrary() before setTargetInfo() is called."); BuildToolInfo buildToolInfo = mTargetInfo.getBuildTools(); PreDexCache.getCache().preDexLibrary( inputFile, outFile, multiDex, dexOptions, buildToolInfo, mVerboseExec, mJavaProcessExecutor, mProcessOutputHandler); }
dexOptions.getJumboMode()); Pair<Item, Boolean> pair = getItem(itemKey); Item item = pair.getFirst(); item.getOutputFiles().addAll(files); incrementMisses(); } catch (ProcessException exception) { checkSame(sourceFile, destFile); Files.copy(sourceFile, destFile); throw new RuntimeException(item.toString()); checkSame(item.getOutputFiles().get(0), outFile); Files.copy(item.getOutputFiles().get(0), outFile); incrementHits();
Pair<Item, Boolean> pair = getItem(logger, itemKey); Item item = pair.getFirst(); logger.verbose("Item from cache %1$s", item.toString()); if (waitForPredexFile(item, outFile, multiDex)) { return; pair = regenerateItem(logger, itemKey); item = pair.getFirst(); item.getOutputFiles().addAll(files); incrementMisses(); } catch (ProcessException exception) { if (!waitForPredexFile(item, outFile, multiDex)) { throw new RuntimeException(String.format("Cannot obtain or regenerate item %s", item.getSourceFile()));
PreDexCache.getCache().preDexLibrary( this, inputFile,