Chromium Code Reviews| Index: dart/tools/build.py |
| diff --git a/dart/tools/build.py b/dart/tools/build.py |
| index df6d55fbf784f7d2b4b67fbc30b59f5811b96d24..0af090371713672c9b3f79fa87210853c6198fcb 100755 |
| --- a/dart/tools/build.py |
| +++ b/dart/tools/build.py |
| @@ -224,29 +224,52 @@ def CurrentDirectoryBaseName(): |
| return os.path.relpath(os.curdir, start=os.pardir) |
| -def ParseXcodebuild(args): |
| +def FilterEmptyXcodebuildSections(process): |
| """ |
| - Run xcodebuild and returns the process object. |
| - Output is parsed to filter out build actions that had no output. |
| + Filter output from xcodebuild so empty sections are less verbose. |
| + |
| + The output from xcodebuild looks like this: |
| + |
| +Build settings from command line: |
| + SYMROOT = .../xcodebuild |
| + |
| +=== BUILD AGGREGATE TARGET samples OF PROJECT dart WITH CONFIGURATION ReleaseIA32 === |
|
kustermann
2013/04/05 15:31:01
You could abbreviate these lines with '...' so we
ahe
2013/04/05 15:45:44
Done.
|
| +Check dependencies |
| + |
| + |
| +=== BUILD AGGREGATE TARGET upload_sdk OF PROJECT dart WITH CONFIGURATION ReleaseIA32 === |
| +Check dependencies |
| + |
| +PhaseScriptExecution "Action \"upload_sdk_py\"" xcodebuild/dart.build/ReleaseIA32/upload_sdk.build/Script-822253BD7234630D393BA4AC.sh |
| + cd ... |
| + /bin/sh -c .../xcodebuild/dart.build/ReleaseIA32/upload_sdk.build/Script-822253BD7234630D393BA4AC.sh |
| + |
| + |
| +** BUILD SUCCEEDED ** |
| + |
| """ |
| def is_empty_chunk(chunk): |
| empty_chunk = ['Check dependencies', '', ''] |
| return not chunk or (len(chunk) == 4 and chunk[1:] == empty_chunk) |
| - process = subprocess.Popen(args, |
| - bufsize=0, |
| - stdin=None, |
| - stdout=subprocess.PIPE, |
| - stderr=subprocess.STDOUT) |
| + def unbuffered(callable): |
| + # Use iter to disable buffering in for-in. |
| + return iter(callable, b'') |
|
kustermann
2013/04/05 15:31:01
The 'b' should not be necessary here.
ahe
2013/04/05 15:45:44
Done.
|
| + |
| section = None |
| chunk = [] |
| - for line in process.stdout: |
| + # Is stdout a terminal? |
| + isatty = sys.stdout.isatty() |
| + for line in unbuffered(process.stdout.readline): |
| line = line.rstrip() |
| if line.startswith('=== BUILD ') or line.startswith('** BUILD '): |
| if not is_empty_chunk(chunk): |
| print '\n'.join(chunk) |
| section = line |
| + if isatty: |
| + # If stdout is a terminal, emit "progress" information. |
| + print '%s[2K%s\r' % (chr(27), section), |
| chunk = [] |
| if not section: |
| print line |
| @@ -254,7 +277,6 @@ def ParseXcodebuild(args): |
| chunk.append(line) |
| if not is_empty_chunk(chunk): |
| print '\n'.join(chunk) |
| - return process |
| def Main(): |
| @@ -274,7 +296,7 @@ def Main(): |
| else: |
| target = args[0] |
| - parse_xcodebuild = False |
| + filter_xcodebuild_output = False |
| # Remember path |
| old_path = os.environ['PATH'] |
| # Build the targets for each requested configuration. |
| @@ -283,7 +305,7 @@ def Main(): |
| for arch in options.arch: |
| build_config = utils.GetBuildConf(mode, arch) |
| if HOST_OS == 'macos': |
| - parse_xcodebuild = True |
| + filter_xcodebuild_output = True |
| project_file = 'dart.xcodeproj' |
| if os.path.exists('dart-%s.gyp' % CurrentDirectoryBaseName()): |
| project_file = 'dart-%s.xcodeproj' % CurrentDirectoryBaseName() |
| @@ -352,8 +374,13 @@ def Main(): |
| print ' '.join(args) |
| process = None |
| - if parse_xcodebuild: |
| - process = ParseXcodebuild(args) |
| + if filter_xcodebuild_output: |
| + process = subprocess.Popen(args, |
| + stdin=None, |
| + bufsize=1, # Line buffered. |
| + stdout=subprocess.PIPE, |
| + stderr=subprocess.STDOUT) |
| + FilterEmptyXcodebuildSections(process) |
| else: |
| process = subprocess.Popen(args, stdin=None) |
| process.wait() |