use of com.taobao.android.dx.cf.direct.ClassPathOpener.FileNameFilter in project atlas by alibaba.
the class Main method processAllFiles.
/**
* Constructs the output {@link DexFile}, fill it in with all the
* specified classes, and populate the resources map if required.
*
* @return whether processing was successful
*/
private boolean processAllFiles() {
createDexFile();
if (args.jarOutput) {
outputResources = new TreeMap<String, byte[]>();
}
anyFilesProcessed = false;
String[] fileNames = args.fileNames;
if (args.numThreads > 1) {
threadPool = Executors.newFixedThreadPool(args.numThreads);
parallelProcessorFutures = new ArrayList<Future<Void>>();
}
try {
if (args.mainDexListFile != null) {
// with --main-dex-list
FileNameFilter mainPassFilter = args.strictNameCheck ? new MainDexListFilter() : new BestEffortMainDexListFilter();
// forced in main dex
for (int i = 0; i < fileNames.length; i++) {
processOne(fileNames[i], mainPassFilter);
}
if (dexOutputArrays.size() > 0) {
throw new DexException("Too many classes in " + Arguments.MAIN_DEX_LIST_OPTION + ", main dex capacity exceeded");
}
if (args.minimalMainDex) {
// start second pass directly in a secondary dex file.
createDexFile();
}
// remaining files
for (int i = 0; i < fileNames.length; i++) {
processOne(fileNames[i], new NotFilter(mainPassFilter));
}
} else {
// without --main-dex-list
for (int i = 0; i < fileNames.length; i++) {
processOne(fileNames[i], ClassPathOpener.acceptAll);
}
}
} catch (StopProcessing ex) {
/*
* Ignore it and just let the error reporting do
* their things.
*/
}
if (args.numThreads > 1) {
try {
threadPool.shutdown();
if (!threadPool.awaitTermination(600L, TimeUnit.SECONDS)) {
throw new RuntimeException("Timed out waiting for threads.");
}
} catch (InterruptedException ex) {
threadPool.shutdownNow();
throw new RuntimeException("A thread has been interrupted.");
}
try {
for (Future<?> future : parallelProcessorFutures) {
future.get();
}
} catch (ExecutionException e) {
Throwable cause = e.getCause();
// should remain
if (cause instanceof Error) {
throw (Error) e.getCause();
} else {
throw new AssertionError(e.getCause());
}
} catch (InterruptedException e) {
// any InterruptedException
throw new AssertionError(e);
}
}
int errorNum = errors.get();
if (errorNum != 0) {
dxConsole.err.println(errorNum + " error" + ((errorNum == 1) ? "" : "s") + "; aborting");
return false;
}
if (args.incremental && !anyFilesProcessed) {
return true;
}
if (!(anyFilesProcessed || args.emptyOk)) {
dxConsole.err.println("no classfiles specified");
return false;
}
if (args.optimize && args.statistics) {
args.cfOptions.codeStatistics.dumpStatistics(dxConsole.out);
}
return true;
}
Aggregations