Index: build/android/gyp/ant.py |
diff --git a/build/android/gyp/ant.py b/build/android/gyp/ant.py |
index 06b0447fead1e437f3443398a2692f92c55b6238..fc1b3afbf920074dc1faeb4d0c9b5a27a725fec5 100755 |
--- a/build/android/gyp/ant.py |
+++ b/build/android/gyp/ant.py |
@@ -10,6 +10,9 @@ Ant build scripts output "BUILD SUCCESSFUL" and build timing at the end of |
every build. In the Android build, this just adds a lot of useless noise to the |
build output. This script forwards its arguments to ant, and prints Ant's |
output up until the BUILD SUCCESSFUL line. |
+ |
+Also, when a command fails, this script will re-run that ant command with the |
+'-verbose' argument so that the failure is easier to debug. |
""" |
import sys |
@@ -20,13 +23,25 @@ from util import build_utils |
def main(argv): |
try: |
- stdout = build_utils.CheckOutput(['ant'] + argv[1:]) |
+ args = argv[1:] |
+ stdout = build_utils.CheckOutput(['ant'] + args) |
except build_utils.CalledProcessError as e: |
- traceback.print_exc() |
- if '-quiet' in e.args: |
- sys.stderr.write('Tip: run the ant command above without the -quiet flag ' |
- 'to see more details on the error\n') |
- sys.exit(1) |
+ # It is very difficult to diagnose ant failures without the '-verbose' |
+ # argument. So, when an ant command fails, re-run it with '-verbose' so that |
+ # the cause of the failure is easier to identify. |
+ verbose_args = ['-verbose'] + [a for a in argv[1:] if a != '-quiet'] |
+ try: |
+ stdout = build_utils.CheckOutput(['ant'] + verbose_args) |
+ except build_utils.CalledProcessError as e: |
+ traceback.print_exc() |
+ sys.exit(1) |
+ |
+ # If this did sys.exit(1), building again would succeed (which would be |
+ # awkward). Instead, just print a big warning. |
+ build_util.PrintBigWarning( |
+ 'This is unexpected. `ant ' + ' '.join(args) + '` failed.' + |
+ 'But, running `ant ' + ' '.join(verbose_args) + '` passed.') |
+ |
stdout = stdout.strip().split('\n') |
for line in stdout: |
if line.strip() == 'BUILD SUCCESSFUL': |