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

Side by Side Diff: dart/tools/build.py

Issue 13470019: Parse output from xcodebuild to make it easier to spot problems with non-incremental builds. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 8 months 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 | « no previous file | 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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
4 # for details. All rights reserved. Use of this source code is governed by a 4 # for details. All rights reserved. Use of this source code is governed by a
5 # BSD-style license that can be found in the LICENSE file. 5 # BSD-style license that can be found in the LICENSE file.
6 # 6 #
7 7
8 import optparse 8 import optparse
9 import os 9 import os
10 import shutil 10 import shutil
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 with open(build_cookie_path, 'w') as f: 217 with open(build_cookie_path, 'w') as f:
218 f.write(target_os) 218 f.write(target_os)
219 GClientRunHooks() 219 GClientRunHooks()
220 220
221 221
222 def CurrentDirectoryBaseName(): 222 def CurrentDirectoryBaseName():
223 """Returns the name of the current directory""" 223 """Returns the name of the current directory"""
224 return os.path.relpath(os.curdir, start=os.pardir) 224 return os.path.relpath(os.curdir, start=os.pardir)
225 225
226 226
227 def ParseXcodebuild(args):
228 """
229 Run xcodebuild and returns the process object.
230 Output is parsed to filter out build actions that had no output.
231 """
kustermann 2013/04/02 21:13:15 A small comment explaining the 'output format' of
ahe 2013/04/05 15:03:43 Done.
232
233 def is_empty_chunk(chunk):
234 empty_chunk = ['Check dependencies', '', '']
235 return not chunk or (len(chunk) == 4 and chunk[1:] == empty_chunk)
236
237 process = subprocess.Popen(args,
238 bufsize=0,
kustermann 2013/04/02 21:13:15 I think 'bufsize=0' is the default -- you could re
ahe 2013/04/05 15:03:43 Yes. In addition it turns out that "for line in p
239 stdin=None,
240 stdout=subprocess.PIPE,
241 stderr=subprocess.STDOUT)
242 section = None
243 chunk = []
244 for line in process.stdout:
245 line = line.rstrip()
246 if line.startswith('=== BUILD ') or line.startswith('** BUILD '):
247 if not is_empty_chunk(chunk):
248 print '\n'.join(chunk)
249 section = line
250 chunk = []
251 if not section:
252 print line
253 else:
254 chunk.append(line)
255 if not is_empty_chunk(chunk):
256 print '\n'.join(chunk)
257 return process
258
259
227 def Main(): 260 def Main():
228 utils.ConfigureJava() 261 utils.ConfigureJava()
229 # Parse the options. 262 # Parse the options.
230 parser = BuildOptions() 263 parser = BuildOptions()
231 (options, args) = parser.parse_args() 264 (options, args) = parser.parse_args()
232 if not ProcessOptions(options, args): 265 if not ProcessOptions(options, args):
233 parser.print_help() 266 parser.print_help()
234 return 1 267 return 1
235 # Determine which targets to build. By default we build the "all" target. 268 # Determine which targets to build. By default we build the "all" target.
236 if len(args) == 0: 269 if len(args) == 0:
237 if HOST_OS == 'macos': 270 if HOST_OS == 'macos':
238 target = 'All' 271 target = 'All'
239 else: 272 else:
240 target = 'all' 273 target = 'all'
241 else: 274 else:
242 target = args[0] 275 target = args[0]
243 276
277 parse_xcodebuild = False
kustermann 2013/04/02 21:13:15 The intention is not to parse the output of xcodeb
ahe 2013/04/05 15:03:43 Done.
244 # Remember path 278 # Remember path
245 old_path = os.environ['PATH'] 279 old_path = os.environ['PATH']
246 # Build the targets for each requested configuration. 280 # Build the targets for each requested configuration.
247 for target_os in options.os: 281 for target_os in options.os:
248 for mode in options.mode: 282 for mode in options.mode:
249 for arch in options.arch: 283 for arch in options.arch:
250 build_config = utils.GetBuildConf(mode, arch) 284 build_config = utils.GetBuildConf(mode, arch)
251 if HOST_OS == 'macos': 285 if HOST_OS == 'macos':
286 parse_xcodebuild = True
252 project_file = 'dart.xcodeproj' 287 project_file = 'dart.xcodeproj'
253 if os.path.exists('dart-%s.gyp' % CurrentDirectoryBaseName()): 288 if os.path.exists('dart-%s.gyp' % CurrentDirectoryBaseName()):
254 project_file = 'dart-%s.xcodeproj' % CurrentDirectoryBaseName() 289 project_file = 'dart-%s.xcodeproj' % CurrentDirectoryBaseName()
255 args = ['xcodebuild', 290 args = ['xcodebuild',
256 '-project', 291 '-project',
257 project_file, 292 project_file,
258 '-target', 293 '-target',
259 target, 294 target,
260 '-configuration', 295 '-configuration',
261 build_config, 296 build_config,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 % os.environ['ANDROID_TOOLCHAIN']) 344 % os.environ['ANDROID_TOOLCHAIN'])
310 toolsOverride = SetTools(arch, toolchainprefix) 345 toolsOverride = SetTools(arch, toolchainprefix)
311 if toolsOverride: 346 if toolsOverride:
312 printToolOverrides = target_os != 'android' 347 printToolOverrides = target_os != 'android'
313 for k, v in toolsOverride.iteritems(): 348 for k, v in toolsOverride.iteritems():
314 args.append( k + "=" + v) 349 args.append( k + "=" + v)
315 if printToolOverrides: 350 if printToolOverrides:
316 print k + " = " + v 351 print k + " = " + v
317 352
318 print ' '.join(args) 353 print ' '.join(args)
319 process = subprocess.Popen(args) 354 process = None
355 if parse_xcodebuild:
356 process = ParseXcodebuild(args)
357 else:
358 process = subprocess.Popen(args, stdin=None)
kustermann 2013/04/02 21:13:15 You could do something like this: if filter_xcode
ahe 2013/04/05 15:03:43 Done.
320 process.wait() 359 process.wait()
321 if process.returncode != 0: 360 if process.returncode != 0:
322 print "BUILD FAILED" 361 print "BUILD FAILED"
323 return 1 362 return 1
324 363
325 return 0 364 return 0
326 365
327 366
328 if __name__ == '__main__': 367 if __name__ == '__main__':
329 sys.exit(Main()) 368 sys.exit(Main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698