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

Optimise Pre-dexing (#2028)

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