summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoit Lamarche <benoitlamarche@google.com>2014-09-09 16:55:21 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-09-09 16:55:22 +0000
commite8f5b536da8a9dd165ee55f4bd6960e982805392 (patch)
treeb7dd71de5710a391ad2e6c53ee2198e10b313354
parentd8ede61283a8641f48fa4ba977086bf2bca58d34 (diff)
parent8a5d5ccc26c97d555024c36f54140f07a4b40b8c (diff)
downloadandroid_dalvik-e8f5b536da8a9dd165ee55f4bd6960e982805392.tar.gz
android_dalvik-e8f5b536da8a9dd165ee55f4bd6960e982805392.tar.bz2
android_dalvik-e8f5b536da8a9dd165ee55f4bd6960e982805392.zip
Merge "Fixes command line too long error on Windows" into lmp-dev
-rw-r--r--dx/src/com/android/dx/command/Main.java3
-rw-r--r--dx/src/com/android/dx/command/dexer/Main.java35
2 files changed, 31 insertions, 7 deletions
diff --git a/dx/src/com/android/dx/command/Main.java b/dx/src/com/android/dx/command/Main.java
index 1132edb78..9834987e5 100644
--- a/dx/src/com/android/dx/command/Main.java
+++ b/dx/src/com/android/dx/command/Main.java
@@ -35,6 +35,7 @@ public class Main {
"[--core-library]\n" +
" [--num-threads=<n>] [--incremental] [--force-jumbo]\n" +
" [--multi-dex [--main-dex-list=<file> [--minimal-main-dex]]\n" +
+ " [--input-list=<file>]\n" +
" [<file>.class | <file>.{zip,jar,apk} | <directory>] ...\n" +
" Convert a set of classfiles into a dex file, optionally " +
"embedded in a\n" +
@@ -52,6 +53,8 @@ public class Main {
" --minimal-main-dex: only classes selected by --main-dex-list are " +
"to be put in\n" +
" the main dex.\n" +
+ " --input-list: <file> is a list of inputs.\n" +
+ " Each line in <file> must end with one of: .class .jar .zip .apk or be a directory.\n" +
" dx --annotool --annotation=<class> [--element=<element types>]\n" +
" [--print=<print types>]\n" +
" dx --dump [--debug] [--strict] [--bytes] [--optimize]\n" +
diff --git a/dx/src/com/android/dx/command/dexer/Main.java b/dx/src/com/android/dx/command/dexer/Main.java
index c5f9c94f6..46703721e 100644
--- a/dx/src/com/android/dx/command/dexer/Main.java
+++ b/dx/src/com/android/dx/command/dexer/Main.java
@@ -326,7 +326,7 @@ public class Main {
assert args.numThreads == 1;
if (args.mainDexListFile != null) {
- classesInMainDex = loadMainDexListFile(args.mainDexListFile);
+ classesInMainDex = readPathsFromFile(args.mainDexListFile);
}
if (!processAllFiles()) {
@@ -380,17 +380,17 @@ public class Main {
}
}
- private static Set<String> loadMainDexListFile(String mainDexListFile) throws IOException {
- Set<String> mainDexList = new HashSet<String>();
+ private static Set<String> readPathsFromFile(String fileName) throws IOException {
+ Set<String> paths = new HashSet<String>();
BufferedReader bfr = null;
try {
- FileReader fr = new FileReader(mainDexListFile);
+ FileReader fr = new FileReader(fileName);
bfr = new BufferedReader(fr);
String line;
while (null != (line = bfr.readLine())) {
- mainDexList.add(fixPath(line));
+ paths.add(fixPath(line));
}
} finally {
@@ -398,7 +398,7 @@ public class Main {
bfr.close();
}
}
- return mainDexList;
+ return paths;
}
/**
@@ -1194,6 +1194,8 @@ public class Main {
private static final String INCREMENTAL_OPTION = "--incremental";
+ private static final String INPUT_LIST_OPTION = "--input-list";
+
/** whether to run in debug mode */
public boolean debug = false;
@@ -1287,6 +1289,9 @@ public class Main {
* mainDexListFile is specified and non empty. */
public boolean minimalMainDex = false;
+ /** Optional list containing inputs read in from a file. */
+ private Set<String> inputList = null;
+
private int maxNumberOfIdxPerDex = DexFormat.MAX_MEMBER_IDX + 1;
private static class ArgumentsParser {
@@ -1488,13 +1493,29 @@ public class Main {
minimalMainDex = true;
} else if (parser.isArg("--set-max-idx-number=")) { // undocumented test option
maxNumberOfIdxPerDex = Integer.parseInt(parser.getLastValue());
- } else {
+ } else if(parser.isArg(INPUT_LIST_OPTION + "=")) {
+ File inputListFile = new File(parser.getLastValue());
+ try{
+ inputList = readPathsFromFile(inputListFile.getAbsolutePath());
+ } catch(IOException e) {
+ System.err.println(
+ "Unable to read input list file: " + inputListFile.getName());
+ // problem reading the file so we should halt execution
+ throw new UsageException();
+ }
+ } else {
System.err.println("unknown option: " + parser.getCurrent());
throw new UsageException();
}
}
fileNames = parser.getRemaining();
+ if(inputList != null && !inputList.isEmpty()) {
+ // append the file names to the end of the input list
+ inputList.addAll(Arrays.asList(fileNames));
+ fileNames = inputList.toArray(new String[inputList.size()]);
+ }
+
if (fileNames.length == 0) {
if (!emptyOk) {
System.err.println("no input files specified");