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

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

Issue 223703002: Add DART_BUILD_NOTIFICATION_DELAY to control notifications (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments Created 6 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 re 10 import re
11 import shutil 11 import shutil
12 import subprocess 12 import subprocess
13 import sys 13 import sys
14 import time
14 import utils 15 import utils
15 16
16 HOST_OS = utils.GuessOS() 17 HOST_OS = utils.GuessOS()
17 HOST_CPUS = utils.GuessCpus() 18 HOST_CPUS = utils.GuessCpus()
18 SCRIPT_DIR = os.path.dirname(sys.argv[0]) 19 SCRIPT_DIR = os.path.dirname(sys.argv[0])
19 DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..')) 20 DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..'))
20 THIRD_PARTY_ROOT = os.path.join(DART_ROOT, 'third_party') 21 THIRD_PARTY_ROOT = os.path.join(DART_ROOT, 'third_party')
21 22
22 arm_cc_error = """ 23 arm_cc_error = """
23 Couldn't find the arm cross compiler. 24 Couldn't find the arm cross compiler.
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 has_interesting_info = True 296 has_interesting_info = True
296 if has_interesting_info: 297 if has_interesting_info:
297 print '\n'.join(chunk) 298 print '\n'.join(chunk)
298 chunk = [] 299 chunk = []
299 else: 300 else:
300 chunk.append(line) 301 chunk.append(line)
301 if not is_empty_chunk(chunk): 302 if not is_empty_chunk(chunk):
302 print '\n'.join(chunk) 303 print '\n'.join(chunk)
303 304
304 305
305 def NotifyBuildDone(build_config, success): 306 def NotifyBuildDone(build_config, success, start):
306 if not success: 307 if not success:
307 print "BUILD FAILED" 308 print "BUILD FAILED"
308 309
309 sys.stdout.flush() 310 sys.stdout.flush()
310 311
312 # Display a notification if build time exceeded DART_BUILD_NOTIFICATION_DELAY.
313 notification_delay = float(
314 os.getenv('DART_BUILD_NOTIFICATION_DELAY', default=sys.float_info.max))
315 if (time.time() - start) < notification_delay:
316 return
317
311 if success: 318 if success:
312 message = 'Build succeeded.' 319 message = 'Build succeeded.'
313 else: 320 else:
314 message = 'Build failed.' 321 message = 'Build failed.'
315 title = build_config 322 title = build_config
316 323
317 command = None 324 command = None
318 if HOST_OS == 'macos': 325 if HOST_OS == 'macos':
319 # Use AppleScript to display a UI non-modal notification. 326 # Use AppleScript to display a UI non-modal notification.
320 script = 'display notification "%s" with title "%s" sound name "Glass"' % ( 327 script = 'display notification "%s" with title "%s" sound name "Glass"' % (
(...skipping 27 matching lines...) Expand all
348 targets = ['all'] 355 targets = ['all']
349 else: 356 else:
350 targets = args 357 targets = args
351 358
352 filter_xcodebuild_output = False 359 filter_xcodebuild_output = False
353 # Build all targets for each requested configuration. 360 # Build all targets for each requested configuration.
354 for target in targets: 361 for target in targets:
355 for target_os in options.os: 362 for target_os in options.os:
356 for mode in options.mode: 363 for mode in options.mode:
357 for arch in options.arch: 364 for arch in options.arch:
365 start_time = time.time()
358 os.environ['DART_BUILD_MODE'] = mode 366 os.environ['DART_BUILD_MODE'] = mode
359 build_config = utils.GetBuildConf(mode, arch, target_os) 367 build_config = utils.GetBuildConf(mode, arch, target_os)
360 if HOST_OS == 'macos': 368 if HOST_OS == 'macos':
361 filter_xcodebuild_output = True 369 filter_xcodebuild_output = True
362 project_file = 'dart.xcodeproj' 370 project_file = 'dart.xcodeproj'
363 if os.path.exists('dart-%s.gyp' % CurrentDirectoryBaseName()): 371 if os.path.exists('dart-%s.gyp' % CurrentDirectoryBaseName()):
364 project_file = 'dart-%s.xcodeproj' % CurrentDirectoryBaseName() 372 project_file = 'dart-%s.xcodeproj' % CurrentDirectoryBaseName()
365 args = ['xcodebuild', 373 args = ['xcodebuild',
366 '-project', 374 '-project',
367 project_file, 375 project_file,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 process = subprocess.Popen(args, 436 process = subprocess.Popen(args,
429 stdin=None, 437 stdin=None,
430 bufsize=1, # Line buffered. 438 bufsize=1, # Line buffered.
431 stdout=subprocess.PIPE, 439 stdout=subprocess.PIPE,
432 stderr=subprocess.STDOUT) 440 stderr=subprocess.STDOUT)
433 FilterEmptyXcodebuildSections(process) 441 FilterEmptyXcodebuildSections(process)
434 else: 442 else:
435 process = subprocess.Popen(args, stdin=None) 443 process = subprocess.Popen(args, stdin=None)
436 process.wait() 444 process.wait()
437 if process.returncode != 0: 445 if process.returncode != 0:
438 NotifyBuildDone(build_config, success=False) 446 NotifyBuildDone(build_config, success=False, start=start_time)
439 return 1 447 return 1
440 else: 448 else:
441 NotifyBuildDone(build_config, success=True) 449 NotifyBuildDone(build_config, success=True, start=start_time)
442 450
443 return 0 451 return 0
444 452
445 453
446 if __name__ == '__main__': 454 if __name__ == '__main__':
447 sys.exit(Main()) 455 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