| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """ Set of basic operations/utilities that are used by the build. """ | 5 """ Set of basic operations/utilities that are used by the build. """ |
| 6 | 6 |
| 7 from contextlib import contextmanager | 7 from contextlib import contextmanager |
| 8 import ast | 8 import ast |
| 9 import base64 | 9 import base64 |
| 10 import cStringIO | 10 import cStringIO |
| (...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 """Flush fh every timeout seconds until kill_event is true.""" | 919 """Flush fh every timeout seconds until kill_event is true.""" |
| 920 while True: | 920 while True: |
| 921 try: | 921 try: |
| 922 fh.flush() | 922 fh.flush() |
| 923 # File handle is closed, exit. | 923 # File handle is closed, exit. |
| 924 except ValueError: | 924 except ValueError: |
| 925 break | 925 break |
| 926 # Wait for kill signal or timeout. | 926 # Wait for kill signal or timeout. |
| 927 if kill_event.wait(timeout): | 927 if kill_event.wait(timeout): |
| 928 break | 928 break |
| 929 print threading.currentThread(), 'TimedFlush: Finished' |
| 929 | 930 |
| 930 # TODO(all): nsylvain's CommandRunner in buildbot_slave is based on this | 931 # TODO(all): nsylvain's CommandRunner in buildbot_slave is based on this |
| 931 # method. Update it when changes are introduced here. | 932 # method. Update it when changes are introduced here. |
| 932 def ProcessRead(readfh, writefh, parser_func=None, filter_obj=None, | 933 def ProcessRead(readfh, writefh, parser_func=None, filter_obj=None, |
| 933 log_event=None): | 934 log_event=None): |
| 934 writefh.flush() | 935 writefh.flush() |
| 935 | 936 |
| 936 # Python on Windows writes the buffer only when it reaches 4k. Ideally | 937 # Python on Windows writes the buffer only when it reaches 4k. Ideally |
| 937 # we would flush a minimum of 10 seconds. However, we only write and | 938 # we would flush a minimum of 10 seconds. However, we only write and |
| 938 # flush no more often than 20 seconds to avoid flooding the master with | 939 # flush no more often than 20 seconds to avoid flooding the master with |
| (...skipping 21 matching lines...) Expand all Loading... |
| 960 | 961 |
| 961 if filter_obj: | 962 if filter_obj: |
| 962 filtered_line = filter_obj.FilterLine(in_line.getvalue()) | 963 filtered_line = filter_obj.FilterLine(in_line.getvalue()) |
| 963 if filtered_line is not None: | 964 if filtered_line is not None: |
| 964 writefh.write(filtered_line) | 965 writefh.write(filtered_line) |
| 965 else: | 966 else: |
| 966 writefh.write(in_line.getvalue()) | 967 writefh.write(in_line.getvalue()) |
| 967 in_line = cStringIO.StringIO() | 968 in_line = cStringIO.StringIO() |
| 968 in_byte = readfh.read(1) | 969 in_byte = readfh.read(1) |
| 969 | 970 |
| 971 print threading.currentThread(), 'ProcessRead: readfh finished.' |
| 972 |
| 970 if log_event and in_line.getvalue(): | 973 if log_event and in_line.getvalue(): |
| 971 log_event.set() | 974 log_event.set() |
| 972 | 975 |
| 973 # Write remaining data and flush on EOF. | 976 # Write remaining data and flush on EOF. |
| 974 if parser_func: | 977 if parser_func: |
| 975 parser_func(in_line.getvalue().strip()) | 978 parser_func(in_line.getvalue().strip()) |
| 976 | 979 |
| 977 if filter_obj: | 980 if filter_obj: |
| 978 if in_line.getvalue(): | 981 if in_line.getvalue(): |
| 979 filtered_line = filter_obj.FilterDone(in_line.getvalue()) | 982 filtered_line = filter_obj.FilterDone(in_line.getvalue()) |
| 980 if filtered_line is not None: | 983 if filtered_line is not None: |
| 981 writefh.write(filtered_line) | 984 writefh.write(filtered_line) |
| 982 else: | 985 else: |
| 983 if in_line.getvalue(): | 986 if in_line.getvalue(): |
| 984 writefh.write(in_line.getvalue()) | 987 writefh.write(in_line.getvalue()) |
| 985 finally: | 988 finally: |
| 989 print threading.currentThread(), 'ProcessRead: cleaning up.' |
| 986 kill_event.set() | 990 kill_event.set() |
| 987 flush_thread.join() | 991 flush_thread.join() |
| 988 writefh.flush() | 992 writefh.flush() |
| 993 print threading.currentThread(), 'ProcessRead: finished.' |
| 989 | 994 |
| 990 pipes = pipes or [] | 995 pipes = pipes or [] |
| 991 | 996 |
| 992 command_str = ' '.join(command) | 997 command_str = ' '.join(command) |
| 993 debug = ('win_chromium_rel_ng' in command_str and | 998 debug = ('win_chromium_rel_ng' in command_str and |
| 994 'layout_test_wrapper' in command_str) | 999 'layout_test_wrapper' in command_str) |
| 995 if debug: | 1000 if debug: |
| 996 print 'Logging extra information to debug layout test hang.' | 1001 print 'Logging extra information to debug layout test hang.' |
| 997 | 1002 |
| 998 # Print the given command (which should be a list of one or more strings). | 1003 # Print the given command (which should be a list of one or more strings). |
| (...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2002 return False | 2007 return False |
| 2003 # Matches e.g. "cl_x86 = path/to/clang-cl.exe" | 2008 # Matches e.g. "cl_x86 = path/to/clang-cl.exe" |
| 2004 clang_cl_re = re.compile( | 2009 clang_cl_re = re.compile( |
| 2005 r'^cl_x\d\d\s+\=\s+(?P<compiler_path>[^ ]+)\s.*$', | 2010 r'^cl_x\d\d\s+\=\s+(?P<compiler_path>[^ ]+)\s.*$', |
| 2006 re.VERBOSE) | 2011 re.VERBOSE) |
| 2007 for line in open(build_file): | 2012 for line in open(build_file): |
| 2008 m = clang_cl_re.match(line) | 2013 m = clang_cl_re.match(line) |
| 2009 if m: | 2014 if m: |
| 2010 return 'clang' in m.group('compiler_path') | 2015 return 'clang' in m.group('compiler_path') |
| 2011 return False | 2016 return False |
| OLD | NEW |