Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(541)

Side by Side Diff: build/android/gyp/util/build_utils.py

Issue 58563004: Don't swallow "aapt crunch" build errors. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « build/android/gyp/process_resources.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import fnmatch 5 import fnmatch
6 import json 6 import json
7 import os 7 import os
8 import pipes 8 import pipes
9 import shlex 9 import shlex
10 import shutil 10 import shutil
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 def ReadJson(path): 76 def ReadJson(path):
77 with open(path, 'r') as jsonfile: 77 with open(path, 'r') as jsonfile:
78 return json.load(jsonfile) 78 return json.load(jsonfile)
79 79
80 80
81 # This can be used in most cases like subprocess.check_call. The output, 81 # This can be used in most cases like subprocess.check_call. The output,
82 # particularly when the command fails, better highlights the command's failure. 82 # particularly when the command fails, better highlights the command's failure.
83 # This call will directly exit on a failure in the subprocess so that no python 83 # This call will directly exit on a failure in the subprocess so that no python
84 # stacktrace is printed after the output of the failed command (and will 84 # stacktrace is printed after the output of the failed command (and will
85 # instead print a python stack trace before the output of the failed command) 85 # instead print a python stack trace before the output of the failed command)
86 def CheckCallDie(args, suppress_output=False, cwd=None): 86 def CheckCallDie(args, suppress_output=False, cwd=None, fail_if_stderr=False):
87 if not cwd: 87 if not cwd:
88 cwd = os.getcwd() 88 cwd = os.getcwd()
89 89
90 child = subprocess.Popen(args, 90 child = subprocess.Popen(args,
91 stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=cwd) 91 stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd)
92 92
93 stdout, _ = child.communicate() 93 stdout, stderr = child.communicate()
94 94
95 if child.returncode: 95 returncode = child.returncode
96 if fail_if_stderr and stderr and returncode == 0:
97 returncode = 1
98
99 if returncode:
96 stacktrace = traceback.extract_stack() 100 stacktrace = traceback.extract_stack()
97 print >> sys.stderr, ''.join(traceback.format_list(stacktrace)) 101 print >> sys.stderr, ''.join(traceback.format_list(stacktrace))
98 # A user should be able to simply copy and paste the command that failed 102 # A user should be able to simply copy and paste the command that failed
99 # into their shell. 103 # into their shell.
100 copyable_command = ' '.join(map(pipes.quote, args)) 104 copyable_command = ' '.join(map(pipes.quote, args))
101 copyable_command = ('( cd ' + os.path.abspath(cwd) + '; ' 105 copyable_command = ('( cd ' + os.path.abspath(cwd) + '; '
102 + copyable_command + ' )') 106 + copyable_command + ' )')
103 print >> sys.stderr, 'Command failed:', copyable_command, '\n' 107 print >> sys.stderr, 'Command failed:', copyable_command, '\n'
104 108
105 if stdout: 109 if stdout:
106 print stdout, 110 print stdout,
111 if stderr:
112 print >> sys.stderr, stderr,
107 113
108 # Directly exit to avoid printing stacktrace. 114 # Directly exit to avoid printing stacktrace.
109 sys.exit(child.returncode) 115 sys.exit(returncode)
110 116
111 else: 117 else:
112 if stdout and not suppress_output: 118 if not suppress_output:
113 print stdout, 119 if stdout:
114 return stdout 120 print stdout,
121 if stderr:
122 print >> sys.stderr, stderr,
123 return stdout + stderr
cjhopman 2013/11/05 01:10:45 This might screw up the log quietening in ant.py.
newt (away) 2013/11/05 15:28:41 Yes, we might need to readjust, though I think the
115 124
116 125
117 def GetModifiedTime(path): 126 def GetModifiedTime(path):
118 # For a symlink, the modified time should be the greater of the link's 127 # For a symlink, the modified time should be the greater of the link's
119 # modified time and the modified time of the target. 128 # modified time and the modified time of the target.
120 return max(os.lstat(path).st_mtime, os.stat(path).st_mtime) 129 return max(os.lstat(path).st_mtime, os.stat(path).st_mtime)
121 130
122 131
123 def IsTimeStale(output, inputs): 132 def IsTimeStale(output, inputs):
124 if not os.path.exists(output): 133 if not os.path.exists(output):
(...skipping 12 matching lines...) Expand all
137 146
138 147
139 def PrintWarning(message): 148 def PrintWarning(message):
140 print 'WARNING: ' + message 149 print 'WARNING: ' + message
141 150
142 151
143 def PrintBigWarning(message): 152 def PrintBigWarning(message):
144 print '***** ' * 8 153 print '***** ' * 8
145 PrintWarning(message) 154 PrintWarning(message)
146 print '***** ' * 8 155 print '***** ' * 8
OLDNEW
« no previous file with comments | « build/android/gyp/process_resources.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698