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 if __name__ == '__main__': |
| 40 tools_path = os.path.dirname(os.path.realpath(__file__)) |
| 41 log_file = 'v8.log' |
| 42 exec_file = 'linux-tick-processor' |
| 43 args = ['--dump-cpp'] |
| 44 for i in range(1, len(sys.argv)): |
| 45 args.append(sys.argv[i]) |
| 46 if not sys.argv[i].startswith('-'): |
| 47 log_file = sys.argv[i]; |
| 48 elif sys.argv[i] == '--unix': |
| 49 exec_file = 'linux-tick-processor' |
| 50 elif sys.argv[i] == '--mac': |
| 51 exec_file = 'mac-tick-processor' |
| 52 elif sys.argv[i] == '--windows': |
| 53 exec_file = 'windows-tick-processor.bat' |
| 54 |
| 55 args = [os.path.join(tools_path, exec_file)] + args |
| 56 |
| 57 sp = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=None, |
| 58 stdin=subprocess.PIPE) |
| 59 out, _ = sp.communicate() |
| 60 returncode = sp.returncode |
| 61 if returncode != 0: |
| 62 print out |
| 63 exit(-1) |
| 64 |
| 65 if platform.system() == 'Windows' and out: |
| 66 out = re.sub('\r+\n', '\n', out) |
| 67 |
| 68 with open(log_file, 'r') as f: |
| 69 lines = f.readlines() |
| 70 |
| 71 iswritten = False |
| 72 with open(log_file, 'w+') as f: |
| 73 for line in lines: |
| 74 if not iswritten and line.startswith('tick'): |
| 75 f.write(out) |
| 76 iswritten = True |
| 77 f.write(line) |
OLD | NEW |