OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2017 The Chromium Authors. All rights reserved. | 2 # Copyright 2017 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Merge the PGC files generated during the profiling step to the PGD database. | 6 """Merge the PGC files generated during the profiling step to the PGD database. |
7 | 7 |
8 This is required to workaround a flakyness in pgomgr.exe where it can run out | 8 This is required to workaround a flakyness in pgomgr.exe where it can run out |
9 of address space while trying to merge all the PGC files at the same time. | 9 of address space while trying to merge all the PGC files at the same time. |
10 """ | 10 """ |
11 | 11 |
12 import glob | 12 import glob |
13 import json | 13 import json |
14 import optparse | 14 import optparse |
15 import os | 15 import os |
16 import subprocess | 16 import subprocess |
17 import sys | 17 import sys |
18 | 18 |
19 | 19 |
| 20 script_dir = os.path.dirname(os.path.realpath(__file__)) |
| 21 sys.path.insert(0, os.path.join(script_dir, os.pardir)) |
| 22 |
| 23 import vs_toolchain |
| 24 |
| 25 |
20 def find_pgomgr(chrome_checkout_dir): | 26 def find_pgomgr(chrome_checkout_dir): |
21 """Find pgomgr.exe.""" | 27 """Find pgomgr.exe.""" |
22 win_toolchain_json_file = os.path.join(chrome_checkout_dir, 'build', | 28 win_toolchain_json_file = os.path.join(chrome_checkout_dir, 'build', |
23 'win_toolchain.json') | 29 'win_toolchain.json') |
24 if not os.path.exists(win_toolchain_json_file): | 30 if not os.path.exists(win_toolchain_json_file): |
25 raise Exception('The toolchain JSON file is missing.') | 31 raise Exception('The toolchain JSON file is missing.') |
26 with open(win_toolchain_json_file) as temp_f: | 32 with open(win_toolchain_json_file) as temp_f: |
27 toolchain_data = json.load(temp_f) | 33 toolchain_data = json.load(temp_f) |
28 if not os.path.isdir(toolchain_data['path']): | 34 if not os.path.isdir(toolchain_data['path']): |
29 raise Exception('The toolchain JSON file is invalid.') | 35 raise Exception('The toolchain JSON file is invalid.') |
30 | 36 |
31 # Always use the x64 version of pgomgr (the x86 one doesn't work on the bot's | 37 # Always use the x64 version of pgomgr (the x86 one doesn't work on the bot's |
32 # environment). | 38 # environment). |
33 pgomgr_dir = os.path.join(toolchain_data['path'], 'VC', 'bin', 'amd64') | 39 if toolchain_data['version'] == '2015': |
| 40 pgomgr_dir = os.path.join(toolchain_data['path'], 'VC', 'bin', 'amd64') |
| 41 elif toolchain_data['version'] == '2017': |
| 42 vc_tools_root = vs_toolchain.FindVCToolsRoot() |
| 43 pgomgr_dir = os.path.join(vc_tools_root, 'HostX64', 'x64') |
34 | 44 |
35 pgomgr_path = os.path.join(pgomgr_dir, 'pgomgr.exe') | 45 pgomgr_path = os.path.join(pgomgr_dir, 'pgomgr.exe') |
36 if not os.path.exists(pgomgr_path): | 46 if not os.path.exists(pgomgr_path): |
37 raise Exception('pgomgr.exe is missing from %s.' % pgomgr_dir) | 47 raise Exception('pgomgr.exe is missing from %s.' % pgomgr_dir) |
38 | 48 |
39 return pgomgr_path | 49 return pgomgr_path |
40 | 50 |
41 | 51 |
42 def main(): | 52 def main(): |
43 parser = optparse.OptionParser(usage='%prog [options]') | 53 parser = optparse.OptionParser(usage='%prog [options]') |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 ]) | 113 ]) |
104 proc = subprocess.Popen(merge_command, stdout=subprocess.PIPE) | 114 proc = subprocess.Popen(merge_command, stdout=subprocess.PIPE) |
105 stdout, stderr = proc.communicate() | 115 stdout, stderr = proc.communicate() |
106 print stdout | 116 print stdout |
107 if proc.returncode != 0: | 117 if proc.returncode != 0: |
108 raise Exception('Error while trying to merge the PGC files:\n%s' % stderr) | 118 raise Exception('Error while trying to merge the PGC files:\n%s' % stderr) |
109 | 119 |
110 | 120 |
111 if __name__ == '__main__': | 121 if __name__ == '__main__': |
112 sys.exit(main()) | 122 sys.exit(main()) |
OLD | NEW |