Commit e345a356 authored by Csaba Kozák's avatar Csaba Kozák Committed by Benoit Lamarche
Browse files

Command line option for disabling warnings

This commit adds a new command line option to dx:
--no-warning.
If the caller appends this to the arguments, dx won't print
warnings to System.err. This can be useful if the user
dexes external jars with old class format, so dx would
print lot of warning about those.

Bug: https://code.google.com/p/android/issues/detail?id=78285

Signed-off-by: default avatarCsaba Kozák <kozakcsabi@gmail.com>

(cherry picked from commit ef1de423)

Change-Id: I6d09c684b5eb97aa28e0b12e3ef44b46293c7dec
parent 008da7d4
......@@ -16,6 +16,8 @@
package com.android.dx.command;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
/**
......@@ -34,4 +36,15 @@ public class DxConsole {
* Error output stream. Links to {@code System.err} by default.
*/
public static PrintStream err = System.err;
/**
* Output stream which prints to nowhere.
*/
public static final PrintStream noop = new PrintStream(new OutputStream() {
@Override
public void write(int b) throws IOException {
// noop
}
});
}
......@@ -33,7 +33,7 @@ public class Main {
"[--dump-width=<n>]\n" +
" [--dump-method=<name>[*]] [--verbose-dump] [--no-files] " +
"[--core-library]\n" +
" [--num-threads=<n>] [--incremental] [--force-jumbo]\n" +
" [--num-threads=<n>] [--incremental] [--force-jumbo] [--no-warning]\n" +
" [--multi-dex [--main-dex-list=<file> [--minimal-main-dex]]\n" +
" [--input-list=<file>]\n" +
" [<file>.class | <file>.{zip,jar,apk} | <directory>] ...\n" +
......
......@@ -1199,6 +1199,9 @@ public class Main {
/** whether to run in debug mode */
public boolean debug = false;
/** whether to emit warning messages */
public boolean warnings = true;
/** whether to emit high-level verbose human-oriented output */
public boolean verbose = false;
......@@ -1409,6 +1412,8 @@ public class Main {
while(parser.getNext()) {
if (parser.isArg("--debug")) {
debug = true;
} else if (parser.isArg("--no-warning")) {
warnings = false;
} else if (parser.isArg("--verbose")) {
verbose = true;
} else if (parser.isArg("--verbose-dump")) {
......@@ -1580,7 +1585,12 @@ public class Main {
cfOptions.optimizeListFile = optimizeListFile;
cfOptions.dontOptimizeListFile = dontOptimizeListFile;
cfOptions.statistics = statistics;
cfOptions.warn = DxConsole.err;
if (warnings) {
cfOptions.warn = DxConsole.err;
} else {
cfOptions.warn = DxConsole.noop;
}
dexOptions = new DexOptions();
dexOptions.forceJumbo = forceJumbo;
......
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