Commit ab3a1821 authored by sebmarchand's avatar sebmarchand Committed by Commit bot

Update merge_pgc_files.py in preparation for VS2017

pgomgr.exe has been moved to a different location in VS2017 so the logic
that find it should be updated.

It can't just be copied to the build directory because we always run the
x64 bit version of this binary (and we don't want to mix x86 and x64
binaries in the same build dir)

BUG=719319

Review-Url: https://codereview.chromium.org/2884613003
Cr-Commit-Position: refs/heads/master@{#473438}
parent 26e4f40a
......@@ -218,6 +218,28 @@ def _CopyUCRTRuntime(target_dir, source_dir, target_cpu, dll_pattern, suffix):
os.path.join(source_dir, 'ucrtbase' + suffix))
def FindVCToolsRoot():
"""In VS2017 the PGO runtime dependencies are located in
{toolchain_root}/VC/Tools/MSVC/{x.y.z}/bin/Host{target_cpu}/{target_cpu}/, the
{version_number} part is likely to change in case of a minor update of the
toolchain so we don't hardcode this value here (except for the major number).
This returns the '{toolchain_root}/VC/Tools/MSVC/{x.y.z}/bin/' path.
This function should only be called when using VS2017.
"""
assert GetVisualStudioVersion() == '2017'
assert ('GYP_MSVS_OVERRIDE_PATH' in os.environ)
vc_tools_msvc_root = os.path.join(os.environ['GYP_MSVS_OVERRIDE_PATH'],
'VC', 'Tools', 'MSVC')
for directory in os.listdir(vc_tools_msvc_root):
if not os.path.isdir(os.path.join(vc_tools_msvc_root, directory)):
continue
if re.match('14\.\d+\.\d+', directory):
return os.path.join(vc_tools_msvc_root, directory, 'bin')
raise Exception('Unable to find the VC tools directory.')
def _CopyPGORuntime(target_dir, target_cpu):
"""Copy the runtime dependencies required during a PGO build.
"""
......@@ -229,20 +251,7 @@ def _CopyPGORuntime(target_dir, target_cpu):
'VC', 'bin')
pgo_x64_runtime_dir = os.path.join(pgo_x86_runtime_dir, 'amd64')
elif env_version == '2017':
# In VS2017 the PGO runtime dependencies are located in
# {toolchain_root}/VC/Tools/MSVC/{x.y.z}/bin/Host{target_cpu}/{target_cpu}/,
# the {version_number} part is likely to change in case of a minor update of
# the toolchain so we don't hardcode this value here (except for the major
# number).
vc_tools_msvc_root = os.path.join(os.environ.get('GYP_MSVS_OVERRIDE_PATH'),
'VC', 'Tools', 'MSVC')
pgo_runtime_root = None
for directory in os.listdir(vc_tools_msvc_root):
if not os.path.isdir(os.path.join(vc_tools_msvc_root, directory)):
continue
if re.match('14\.\d+\.\d+', directory):
pgo_runtime_root = os.path.join(vc_tools_msvc_root, directory, 'bin')
break
pgo_runtime_root = FindVCToolsRoot()
assert pgo_runtime_root
# There's no version of pgosweep.exe in HostX64/x86, so we use the copy
# from HostX86/x86.
......
......@@ -17,6 +17,12 @@ import subprocess
import sys
script_dir = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, os.path.join(script_dir, os.pardir))
import vs_toolchain
def find_pgomgr(chrome_checkout_dir):
"""Find pgomgr.exe."""
win_toolchain_json_file = os.path.join(chrome_checkout_dir, 'build',
......@@ -30,7 +36,11 @@ def find_pgomgr(chrome_checkout_dir):
# Always use the x64 version of pgomgr (the x86 one doesn't work on the bot's
# environment).
pgomgr_dir = os.path.join(toolchain_data['path'], 'VC', 'bin', 'amd64')
if toolchain_data['version'] == '2015':
pgomgr_dir = os.path.join(toolchain_data['path'], 'VC', 'bin', 'amd64')
elif toolchain_data['version'] == '2017':
vc_tools_root = vs_toolchain.FindVCToolsRoot()
pgomgr_dir = os.path.join(vc_tools_root, 'HostX64', 'x64')
pgomgr_path = os.path.join(pgomgr_dir, 'pgomgr.exe')
if not os.path.exists(pgomgr_path):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment