OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 import glob | 6 import glob |
7 import json | 7 import json |
8 import os | 8 import os |
9 import pipes | 9 import pipes |
10 import platform | 10 import platform |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 ucrt_files = glob.glob(os.path.join(ucrt_dll_dirs, 'api-ms-win-*.dll')) | 211 ucrt_files = glob.glob(os.path.join(ucrt_dll_dirs, 'api-ms-win-*.dll')) |
212 assert len(ucrt_files) > 0 | 212 assert len(ucrt_files) > 0 |
213 for ucrt_src_file in ucrt_files: | 213 for ucrt_src_file in ucrt_files: |
214 file_part = os.path.basename(ucrt_src_file) | 214 file_part = os.path.basename(ucrt_src_file) |
215 ucrt_dst_file = os.path.join(target_dir, file_part) | 215 ucrt_dst_file = os.path.join(target_dir, file_part) |
216 _CopyRuntimeImpl(ucrt_dst_file, ucrt_src_file, False) | 216 _CopyRuntimeImpl(ucrt_dst_file, ucrt_src_file, False) |
217 _CopyRuntimeImpl(os.path.join(target_dir, 'ucrtbase' + suffix), | 217 _CopyRuntimeImpl(os.path.join(target_dir, 'ucrtbase' + suffix), |
218 os.path.join(source_dir, 'ucrtbase' + suffix)) | 218 os.path.join(source_dir, 'ucrtbase' + suffix)) |
219 | 219 |
220 | 220 |
221 def FindVCToolsRoot(): | |
222 """In VS2017 the PGO runtime dependencies are located in | |
223 {toolchain_root}/VC/Tools/MSVC/{x.y.z}/bin/Host{target_cpu}/{target_cpu}/, the | |
224 {version_number} part is likely to change in case of a minor update of the | |
225 toolchain so we don't hardcode this value here (except for the major number). | |
226 | |
227 This returns the '{toolchain_root}/VC/Tools/MSVC/{x.y.z}/bin/' path. | |
228 | |
229 This function should only be called when using VS2017. | |
230 """ | |
231 assert GetVisualStudioVersion() == '2017' | |
232 assert ('GYP_MSVS_OVERRIDE_PATH' in os.environ) | |
233 vc_tools_msvc_root = os.path.join(os.environ['GYP_MSVS_OVERRIDE_PATH'], | |
234 'VC', 'Tools', 'MSVC') | |
235 for directory in os.listdir(vc_tools_msvc_root): | |
236 if not os.path.isdir(os.path.join(vc_tools_msvc_root, directory)): | |
237 continue | |
238 if re.match('14\.\d+\.\d+', directory): | |
239 return os.path.join(vc_tools_msvc_root, directory, 'bin') | |
240 raise Exception('Unable to find the VC tools directory.') | |
241 | |
242 | |
243 def _CopyPGORuntime(target_dir, target_cpu): | 221 def _CopyPGORuntime(target_dir, target_cpu): |
244 """Copy the runtime dependencies required during a PGO build. | 222 """Copy the runtime dependencies required during a PGO build. |
245 """ | 223 """ |
246 env_version = GetVisualStudioVersion() | 224 env_version = GetVisualStudioVersion() |
247 # These dependencies will be in a different location depending on the version | 225 # These dependencies will be in a different location depending on the version |
248 # of the toolchain. | 226 # of the toolchain. |
249 if env_version == '2015': | 227 if env_version == '2015': |
250 pgo_x86_runtime_dir = os.path.join(os.environ.get('GYP_MSVS_OVERRIDE_PATH'), | 228 pgo_x86_runtime_dir = os.path.join(os.environ.get('GYP_MSVS_OVERRIDE_PATH'), |
251 'VC', 'bin') | 229 'VC', 'bin') |
252 pgo_x64_runtime_dir = os.path.join(pgo_x86_runtime_dir, 'amd64') | 230 pgo_x64_runtime_dir = os.path.join(pgo_x86_runtime_dir, 'amd64') |
253 elif env_version == '2017': | 231 elif env_version == '2017': |
254 pgo_runtime_root = FindVCToolsRoot() | 232 # In VS2017 the PGO runtime dependencies are located in |
| 233 # {toolchain_root}/VC/Tools/MSVC/{x.y.z}/bin/Host{target_cpu}/{target_cpu}/, |
| 234 # the {version_number} part is likely to change in case of a minor update of |
| 235 # the toolchain so we don't hardcode this value here (except for the major |
| 236 # number). |
| 237 vc_tools_msvc_root = os.path.join(os.environ.get('GYP_MSVS_OVERRIDE_PATH'), |
| 238 'VC', 'Tools', 'MSVC') |
| 239 pgo_runtime_root = None |
| 240 for directory in os.listdir(vc_tools_msvc_root): |
| 241 if not os.path.isdir(os.path.join(vc_tools_msvc_root, directory)): |
| 242 continue |
| 243 if re.match('14\.\d+\.\d+', directory): |
| 244 pgo_runtime_root = os.path.join(vc_tools_msvc_root, directory, 'bin') |
| 245 break |
255 assert pgo_runtime_root | 246 assert pgo_runtime_root |
256 # There's no version of pgosweep.exe in HostX64/x86, so we use the copy | 247 # There's no version of pgosweep.exe in HostX64/x86, so we use the copy |
257 # from HostX86/x86. | 248 # from HostX86/x86. |
258 pgo_x86_runtime_dir = os.path.join(pgo_runtime_root, 'HostX86', 'x86') | 249 pgo_x86_runtime_dir = os.path.join(pgo_runtime_root, 'HostX86', 'x86') |
259 pgo_x64_runtime_dir = os.path.join(pgo_runtime_root, 'HostX64', 'x64') | 250 pgo_x64_runtime_dir = os.path.join(pgo_runtime_root, 'HostX64', 'x64') |
260 else: | 251 else: |
261 raise Exception('Unexpected toolchain version: %s.' % env_version) | 252 raise Exception('Unexpected toolchain version: %s.' % env_version) |
262 | 253 |
263 # We need to copy 2 runtime dependencies used during the profiling step: | 254 # We need to copy 2 runtime dependencies used during the profiling step: |
264 # - pgort140.dll: runtime library required to run the instrumented image. | 255 # - pgort140.dll: runtime library required to run the instrumented image. |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 'copy_dlls': CopyDlls, | 430 'copy_dlls': CopyDlls, |
440 } | 431 } |
441 if len(sys.argv) < 2 or sys.argv[1] not in commands: | 432 if len(sys.argv) < 2 or sys.argv[1] not in commands: |
442 print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands) | 433 print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands) |
443 return 1 | 434 return 1 |
444 return commands[sys.argv[1]](*sys.argv[2:]) | 435 return commands[sys.argv[1]](*sys.argv[2:]) |
445 | 436 |
446 | 437 |
447 if __name__ == '__main__': | 438 if __name__ == '__main__': |
448 sys.exit(main()) | 439 sys.exit(main()) |
OLD | NEW |