Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 # | |
| 3 # Copyright 2016 the V8 project authors. All rights reserved. | |
| 4 # Redistribution and use in source and binary forms, with or without | |
| 5 # modification, are permitted provided that the following conditions are | |
| 6 # met: | |
| 7 # | |
| 8 # * Redistributions of source code must retain the above copyright | |
| 9 # notice, this list of conditions and the following disclaimer. | |
| 10 # * Redistributions in binary form must reproduce the above | |
| 11 # copyright notice, this list of conditions and the following | |
| 12 # disclaimer in the documentation and/or other materials provided | |
| 13 # with the distribution. | |
| 14 # * Neither the name of Google Inc. nor the names of its | |
| 15 # contributors may be used to endorse or promote products derived | |
| 16 # from this software without specific prior written permission. | |
| 17 # | |
| 18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 29 | |
| 30 # This script executes the tickprocessor, collects all dumped C++ symbols, | |
| 31 # and merges them into v8.log. | |
| 32 | |
| 33 import os | |
| 34 import platform | |
| 35 import re | |
| 36 import subprocess | |
| 37 import sys | |
| 38 | |
| 39 def isFileExecutable(fPath): | |
| 40 return os.path.isfile(fPath) and os.access(fPath, os.X_OK) | |
| 41 | |
| 42 if __name__ == '__main__': | |
| 43 JS_FILES = ['splaytree.js', 'codemap.js', 'csvparser.js', 'consarray.js', 'pro file.js', 'logreader.js', 'tickprocessor.js', 'SourceMap.js', 'dump-cpp.js'] | |
|
fmeawad
2016/04/19 12:52:25
loose the "-" in the file name, all other file nam
lpy
2016/04/19 21:02:20
Done.
| |
| 44 tools_path = os.path.dirname(os.path.realpath(__file__)) | |
| 45 on_windows = True if platform.system() == 'Windows' else False | |
| 46 for i in range(0, len(JS_FILES)): | |
| 47 JS_FILES[i] = os.path.join(tools_path, JS_FILES[i]) | |
| 48 | |
| 49 args = [] | |
| 50 log_file = 'v8.log' | |
| 51 debug = False | |
| 52 for i in range(1, len(sys.argv)): | |
| 53 if sys.argv[i] == '--debug': | |
| 54 debug = True | |
| 55 continue | |
| 56 args.append(sys.argv[i]) | |
| 57 if not sys.argv[i].startswith('-'): | |
| 58 log_file = sys.argv[i] | |
| 59 | |
| 60 if on_windows: | |
| 61 args.append('--windows') | |
| 62 | |
| 63 with open(log_file, 'r') as f: | |
| 64 lines = f.readlines() | |
| 65 | |
| 66 d8_line = re.search(',\"(.*d8)', ''.join(lines)) | |
| 67 if d8_line: | |
| 68 d8_exec = d8_line.groups()[0] | |
| 69 else: | |
| 70 print 'No d8 binary path found in {}.'.format(log_file) | |
| 71 exit(-1) | |
| 72 | |
| 73 if on_windows: | |
| 74 args = [d8_exec] + JS_FILES + ['--'] + args | |
| 75 else: | |
| 76 args = [d8_exec] + JS_FILES + ['--'] + args | |
| 77 | |
| 78 with open(log_file) as f: | |
| 79 sp = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=f) | |
| 80 out, err = sp.communicate() | |
| 81 if debug: | |
| 82 print err | |
| 83 returncode = sp.returncode | |
| 84 if returncode != 0: | |
| 85 print out | |
| 86 exit(-1) | |
| 87 | |
| 88 if on_windows and out: | |
|
fmeawad
2016/04/19 12:52:25
Have you tried it on a windows machine?
lpy
2016/04/19 21:02:20
No I haven't tried it on windows.
| |
| 89 out = re.sub('\r+\n', '\n', out) | |
| 90 | |
| 91 iswritten = False if out else True | |
|
fmeawad
2016/04/19 12:52:25
is_written
lpy
2016/04/19 21:02:20
Done.
| |
| 92 with open(log_file, 'w+') as f: | |
| 93 for line in lines: | |
| 94 if not iswritten and line.startswith('tick'): | |
| 95 f.write(out) | |
| 96 iswritten = True | |
| 97 f.write(line) | |
| OLD | NEW |