use of com.android.dx.dex.file.DexFile in project kotlin by JetBrains.
the class DxChecker method checkFileWithDx.
private static void checkFileWithDx(byte[] bytes, @NotNull String relativePath, @NotNull Main.Arguments arguments) {
DirectClassFile cf = new DirectClassFile(bytes, relativePath, true);
cf.setAttributeFactory(StdAttributeFactory.THE_ONE);
CfTranslator.translate(cf, bytes, arguments.cfOptions, arguments.dexOptions, new DexFile(arguments.dexOptions));
}
use of com.android.dx.dex.file.DexFile in project bazel by bazelbuild.
the class DexConverter method toDexFile.
public DexFile toDexFile(byte[] classfile, String classfilePath) {
DexFile result = dexing.newDexFile();
dexing.addToDexFile(result, Dexing.parseClassFile(classfile, classfilePath));
return result;
}
use of com.android.dx.dex.file.DexFile in project buck by facebook.
the class Main method runMultiDex.
private int runMultiDex() throws IOException {
assert !args.incremental;
if (args.mainDexListFile != null) {
classesInMainDex = new HashSet<String>();
readPathsFromFile(args.mainDexListFile, classesInMainDex);
}
dexOutPool = Executors.newFixedThreadPool(args.numThreads);
if (!processAllFiles()) {
return 1;
}
if (!libraryDexBuffers.isEmpty()) {
throw new DexException("Library dex files are not supported in multi-dex mode");
}
if (outputDex != null) {
// this array is null if no classes were defined
dexOutputFutures.add(dexOutPool.submit(new DexWriter(outputDex)));
// Effectively free up the (often massive) DexFile memory.
outputDex = null;
}
try {
dexOutPool.shutdown();
if (!dexOutPool.awaitTermination(600L, TimeUnit.SECONDS)) {
throw new RuntimeException("Timed out waiting for dex writer threads.");
}
for (Future<byte[]> f : dexOutputFutures) {
dexOutputArrays.add(f.get());
}
} catch (InterruptedException ex) {
dexOutPool.shutdownNow();
throw new RuntimeException("A dex writer thread has been interrupted.");
} catch (Exception e) {
dexOutPool.shutdownNow();
throw new RuntimeException("Unexpected exception in dex writer thread");
}
if (args.jarOutput) {
for (int i = 0; i < dexOutputArrays.size(); i++) {
outputResources.put(getDexFileName(i), dexOutputArrays.get(i));
}
if (!createJar(args.outName)) {
return 3;
}
} else if (args.outName != null) {
File outDir = new File(args.outName);
assert outDir.isDirectory();
for (int i = 0; i < dexOutputArrays.size(); i++) {
OutputStream out = new FileOutputStream(new File(outDir, getDexFileName(i)));
try {
out.write(dexOutputArrays.get(i));
} finally {
closeOutput(out);
}
}
}
return 0;
}
use of com.android.dx.dex.file.DexFile in project dexmaker by linkedin.
the class DexMaker method getDexFile.
DexFile getDexFile() {
if (outputDex == null) {
DexOptions options = new DexOptions();
options.targetApiLevel = DexFormat.API_NO_EXTENDED_OPCODES;
outputDex = new DexFile(options);
}
return outputDex;
}
use of com.android.dx.dex.file.DexFile in project buck by facebook.
the class Main method runMonoDex.
private int runMonoDex() throws IOException {
File incrementalOutFile = null;
if (args.incremental) {
if (args.outName == null) {
err.println("error: no incremental output name specified");
return -1;
}
incrementalOutFile = new File(args.outName);
if (incrementalOutFile.exists()) {
minimumFileAge = incrementalOutFile.lastModified();
}
}
if (!processAllFiles()) {
return 1;
}
if (args.incremental && !anyFilesProcessed) {
// this was a no-op incremental build
return 0;
}
// this array is null if no classes were defined
byte[] outArray = null;
if (!outputDex.isEmpty() || (args.humanOutName != null)) {
outArray = writeDex(outputDex);
if (outArray == null) {
return 2;
}
computeReferencedResources();
}
if (args.incremental) {
outArray = mergeIncremental(outArray, incrementalOutFile);
}
outArray = mergeLibraryDexBuffers(outArray);
if (args.jarOutput) {
// Effectively free up the (often massive) DexFile memory.
outputDex = null;
if (outArray != null) {
outputResources.put(DexFormat.DEX_IN_JAR_NAME, outArray);
}
if (!createJar(args.outName)) {
return 3;
}
} else if (outArray != null && args.outName != null) {
OutputStream out = openOutput(args.outName);
out.write(outArray);
closeOutput(out);
}
return 0;
}
Aggregations