Unverified Commit 13653adc authored by Pavitra Golchha's avatar Pavitra Golchha Committed by GitHub

Optimise Pre-dexing (#2028)

parent 0097591e
......@@ -16,20 +16,19 @@
package com.google.appinventor.buildserver;
import com.google.common.hash.HashCode;
import com.google.common.hash.HashFunction;
import com.google.common.hash.Hashing;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import com.google.common.hash.HashCode;
import com.google.common.hash.HashFunction;
import com.google.common.hash.Hashing;
/**
* Dex task, modified from the Android SDK to run in BuildServer.
......@@ -46,11 +45,12 @@ public class DexExecTask {
private boolean mDisableDexMerger = false;
private static Map<String, String> alreadyChecked = new HashMap<String, String>();
private static Object semaphore = new Object(); // Used to protect dex cache creation
private static final Object semaphore = new Object(); // Used to protect dex cache creation
/**
* Sets the value of the "executable" attribute.
*
* @param executable the value.
*/
public void setExecutable(String executable) {
......@@ -59,6 +59,7 @@ public class DexExecTask {
/**
* Sets the value of the "verbose" attribute.
*
* @param verbose the value.
*/
public void setVerbose(boolean verbose) {
......@@ -67,6 +68,7 @@ public class DexExecTask {
/**
* Sets the value of the "output" attribute.
*
* @param output the value.
*/
public void setOutput(String output) {
......@@ -79,6 +81,7 @@ public class DexExecTask {
/**
* Sets the value of the "nolocals" attribute.
*
* @param verbose the value.
*/
public void setNoLocals(boolean nolocals) {
......@@ -100,11 +103,10 @@ public class DexExecTask {
return true;
}
synchronized(semaphore) {
synchronized (semaphore) {
final int count = inputs.size();
boolean allSuccessful = true;
for (int i = 0 ; i < count; i++) {
for (int i = 0; i < count; i++) {
File input = inputs.get(i);
if (input.isFile()) {
// check if this libs needs to be pre-dexed
......@@ -112,7 +114,7 @@ public class DexExecTask {
File dexedLib = new File(mDexedLibs, fileName);
String dexedLibPath = dexedLib.getAbsolutePath();
if (dexedLib.isFile() == false/*||
if (!dexedLib.isFile()/*||
dexedLib.lastModified() < input.lastModified()*/) {
System.out.println(
......@@ -123,8 +125,8 @@ public class DexExecTask {
dexedLib.delete();
}
boolean dexSuccess = runDx(input, dexedLibPath, false /*showInput*/);
allSuccessful = allSuccessful && dexSuccess;
boolean dexSuccess = runDx(input, dexedLibPath, /*showInputs=*/ false);
if (!dexSuccess) return false;
} else {
System.out.println(
String.format("Using Pre-Dexed %1$s <- %2$s",
......@@ -135,7 +137,7 @@ public class DexExecTask {
inputs.set(i, dexedLib);
}
}
return allSuccessful;
return true;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment