chromium-src-build/vs_toolchain.py

543 строки
22 KiB
Python
Исходник Обычный вид История

#!/usr/bin/env python
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import glob
import json
import os
import pipes
import platform
import re
import shutil
import stat
import subprocess
import sys
from gn_helpers import ToGNString
script_dir = os.path.dirname(os.path.realpath(__file__))
json_data_file = os.path.join(script_dir, 'win_toolchain.json')
# Use MSVS2017 as the default toolchain.
CURRENT_DEFAULT_TOOLCHAIN_VERSION = '2017'
def SetEnvironmentAndGetRuntimeDllDirs():
"""Sets up os.environ to use the depot_tools VS toolchain with gyp, and
returns the location of the VC runtime DLLs so they can be copied into
the output directory after gyp generation.
Return value is [x64path, x86path, 'Arm64Unused'] or None. arm64path is
generated separately because there are multiple folders for the arm64 VC
runtime.
"""
vs_runtime_dll_dirs = None
depot_tools_win_toolchain = \
bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')))
# When running on a non-Windows host, only do this if the SDK has explicitly
# been downloaded before (in which case json_data_file will exist).
if ((sys.platform in ('win32', 'cygwin') or os.path.exists(json_data_file))
and depot_tools_win_toolchain):
if ShouldUpdateToolchain():
update_result = Update()
if update_result != 0:
raise Exception('Failed to update, error code %d.' % update_result)
with open(json_data_file, 'r') as tempf:
toolchain_data = json.load(tempf)
toolchain = toolchain_data['path']
version = toolchain_data['version']
win_sdk = toolchain_data.get('win_sdk')
if not win_sdk:
win_sdk = toolchain_data['win8sdk']
wdk = toolchain_data['wdk']
# TODO(scottmg): The order unfortunately matters in these. They should be
# split into separate keys for x64/x86/arm64. (See CopyDlls call below).
# http://crbug.com/345992
vs_runtime_dll_dirs = toolchain_data['runtime_dirs']
# The number of runtime_dirs in the toolchain_data was two (x64/x86) but
# changed to three (x64/x86/arm64) and this code needs to handle both
# possibilities, which can change independently from this code.
if len(vs_runtime_dll_dirs) == 2:
vs_runtime_dll_dirs.append('Arm64Unused')
os.environ['GYP_MSVS_OVERRIDE_PATH'] = toolchain
os.environ['GYP_MSVS_VERSION'] = version
os.environ['WINDOWSSDKDIR'] = win_sdk
os.environ['WDK_DIR'] = wdk
# Include the VS runtime in the PATH in case it's not machine-installed.
runtime_path = os.path.pathsep.join(vs_runtime_dll_dirs)
os.environ['PATH'] = runtime_path + os.path.pathsep + os.environ['PATH']
elif sys.platform == 'win32' and not depot_tools_win_toolchain:
if not 'GYP_MSVS_OVERRIDE_PATH' in os.environ:
os.environ['GYP_MSVS_OVERRIDE_PATH'] = DetectVisualStudioPath()
if not 'GYP_MSVS_VERSION' in os.environ:
os.environ['GYP_MSVS_VERSION'] = GetVisualStudioVersion()
# When using an installed toolchain these files aren't needed in the output
# directory in order to run binaries locally, but they are needed in order
# to create isolates or the mini_installer. Copying them to the output
# directory ensures that they are available when needed.
bitness = platform.architecture()[0]
# When running 64-bit python the x64 DLLs will be in System32
# ARM64 binaries will not be available in the system directories because we
# don't build on ARM64 machines.
x64_path = 'System32' if bitness == '64bit' else 'Sysnative'
WinUWP store application support is out of date This is required to support building Microsoft's WinUWP store application version of WebRTC. vs_toolchain.py - needed to perform environment variable expansion for "Program Files(x86)" to correctly identify Visual Studio installation location config/BUILD.gn - remove delayimp.lib, kernel32.lib and ole32.lib from store applications (instead requires dloadhelper.lib/WindowsApp.lib must be used) BUILDCONFIG.gn - Do not use clang when compiling Windows UWP targets; - Added declare_args for is_target_winuwp rather and stripped multi defined variations of the host_os/current_os == "winrt_10", "winrt_81", "winrt_81_phone" that heavily polluted the platform / target selections (as the current targeting methodology is incorrect anyway). The host_os/current_os is always be "win" and only the target should be Windows UWP / store applications based on the target_os == "winuwp" rather than all the flavors of UWP. - Added filter for _winuwp source files (separate from just windows) - Added default configs for desktop vs store applications to correctly set the defines according to the desktop vs store targets config/win/BUILD.gn - The Windows UWP versioning assumes to be Windows 10 / store app now although a updated GN allows for targeting older Windows UWP versions/SDKs/device families. This allows the definitions for the various application support versioning and application families required for UWP to be set. - The linker calls vsvarsall.bat to be executed via toolchain/win/setup_toolchain.py in order to correctly identify the correct linker library path information for Windows store SDK targets. The hard coded and assumed library paths are fixed in all cases to be discovered from the tooling for forward future platform support in all cases. - Added ARM linkage definitions for the Windows ARM CPU required for properly targeting all three CPUs (x86, x64, arm) for universal store binaries. - Added the proper family C++/C defines required to target the various Windows store application types currently offered for Windows UWP store applications. toolchain/win/BUILD.gn - The name to support the storage of the environment variables now is passed into the setup script to allow for easier extension of the CPUs and target combinations (arm, x64, x86 in the desktop vs store variations) - "desktop" vs "store" is now specified the setup for the correct toolchain targeting - Sets true/false for is_target_winuwp is dependent on the toolchain activated (so configurations will be set correctly when the toolchain is specified for host tool targets required for build tools vs finalized application targets) - Cleaned up the Windows RT section to properly support Windows UWP toolchains toolchain/win/setup_toolchain.py - the setup was missing the arm CPU for universal binaries required for the UWP platform - The calling of vcvarsall.bat was missing the "store" option for store applications and all the CPU offered - Added returning of linker paths by searching the library environments for well-known library files expected in each of the 3 library paths required "lib", "um" and "atlmfc" R=phoglund@google.com Bug: 812814 Change-Id: If1a6b1b1bc3ed940fc8e2ce726ac016e2491e61d Reviewed-on: https://chromium-review.googlesource.com/923161 Commit-Queue: Patrik Höglund <phoglund@chromium.org> Reviewed-by: Dirk Pranke <dpranke@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#545751} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: c5686578e8f519eeec50f574b284fbc12e6e15d8
2018-03-26 13:07:40 +03:00
x64_path = os.path.join(os.path.expandvars('%windir%'), x64_path)
vs_runtime_dll_dirs = [x64_path,
os.path.join(os.path.expandvars('%windir%'),
'SysWOW64'),
'Arm64Unused']
return vs_runtime_dll_dirs
def _RegistryGetValueUsingWinReg(key, value):
"""Use the _winreg module to obtain the value of a registry key.
Args:
key: The registry key.
value: The particular registry value to read.
Return:
contents of the registry key's value, or None on failure. Throws
ImportError if _winreg is unavailable.
"""
import _winreg
try:
root, subkey = key.split('\\', 1)
assert root == 'HKLM' # Only need HKLM for now.
with _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, subkey) as hkey:
return _winreg.QueryValueEx(hkey, value)[0]
except WindowsError:
return None
def _RegistryGetValue(key, value):
try:
return _RegistryGetValueUsingWinReg(key, value)
except ImportError:
raise Exception('The python library _winreg not found.')
def GetVisualStudioVersion():
"""Return GYP_MSVS_VERSION of Visual Studio.
"""
return os.environ.get('GYP_MSVS_VERSION', CURRENT_DEFAULT_TOOLCHAIN_VERSION)
def DetectVisualStudioPath():
"""Return path to the GYP_MSVS_VERSION of Visual Studio.
"""
# Note that this code is used from
# build/toolchain/win/setup_toolchain.py as well.
version_as_year = GetVisualStudioVersion()
year_to_version = {
'2017': '15.0',
}
if version_as_year not in year_to_version:
raise Exception(('Visual Studio version %s (from GYP_MSVS_VERSION)'
' not supported. Supported versions are: %s') % (
version_as_year, ', '.join(year_to_version.keys())))
if version_as_year == '2017':
# The VC++ 2017 install location needs to be located using COM instead of
# the registry. For details see:
# https://blogs.msdn.microsoft.com/heaths/2016/09/15/changes-to-visual-studio-15-setup/
# For now we use a hardcoded default with an environment variable override.
for path in (
os.environ.get('vs2017_install'),
WinUWP store application support is out of date This is required to support building Microsoft's WinUWP store application version of WebRTC. vs_toolchain.py - needed to perform environment variable expansion for "Program Files(x86)" to correctly identify Visual Studio installation location config/BUILD.gn - remove delayimp.lib, kernel32.lib and ole32.lib from store applications (instead requires dloadhelper.lib/WindowsApp.lib must be used) BUILDCONFIG.gn - Do not use clang when compiling Windows UWP targets; - Added declare_args for is_target_winuwp rather and stripped multi defined variations of the host_os/current_os == "winrt_10", "winrt_81", "winrt_81_phone" that heavily polluted the platform / target selections (as the current targeting methodology is incorrect anyway). The host_os/current_os is always be "win" and only the target should be Windows UWP / store applications based on the target_os == "winuwp" rather than all the flavors of UWP. - Added filter for _winuwp source files (separate from just windows) - Added default configs for desktop vs store applications to correctly set the defines according to the desktop vs store targets config/win/BUILD.gn - The Windows UWP versioning assumes to be Windows 10 / store app now although a updated GN allows for targeting older Windows UWP versions/SDKs/device families. This allows the definitions for the various application support versioning and application families required for UWP to be set. - The linker calls vsvarsall.bat to be executed via toolchain/win/setup_toolchain.py in order to correctly identify the correct linker library path information for Windows store SDK targets. The hard coded and assumed library paths are fixed in all cases to be discovered from the tooling for forward future platform support in all cases. - Added ARM linkage definitions for the Windows ARM CPU required for properly targeting all three CPUs (x86, x64, arm) for universal store binaries. - Added the proper family C++/C defines required to target the various Windows store application types currently offered for Windows UWP store applications. toolchain/win/BUILD.gn - The name to support the storage of the environment variables now is passed into the setup script to allow for easier extension of the CPUs and target combinations (arm, x64, x86 in the desktop vs store variations) - "desktop" vs "store" is now specified the setup for the correct toolchain targeting - Sets true/false for is_target_winuwp is dependent on the toolchain activated (so configurations will be set correctly when the toolchain is specified for host tool targets required for build tools vs finalized application targets) - Cleaned up the Windows RT section to properly support Windows UWP toolchains toolchain/win/setup_toolchain.py - the setup was missing the arm CPU for universal binaries required for the UWP platform - The calling of vcvarsall.bat was missing the "store" option for store applications and all the CPU offered - Added returning of linker paths by searching the library environments for well-known library files expected in each of the 3 library paths required "lib", "um" and "atlmfc" R=phoglund@google.com Bug: 812814 Change-Id: If1a6b1b1bc3ed940fc8e2ce726ac016e2491e61d Reviewed-on: https://chromium-review.googlesource.com/923161 Commit-Queue: Patrik Höglund <phoglund@chromium.org> Reviewed-by: Dirk Pranke <dpranke@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#545751} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: c5686578e8f519eeec50f574b284fbc12e6e15d8
2018-03-26 13:07:40 +03:00
os.path.expandvars('%ProgramFiles(x86)%'
'/Microsoft Visual Studio/2017/Enterprise'),
os.path.expandvars('%ProgramFiles(x86)%'
'/Microsoft Visual Studio/2017/Professional'),
os.path.expandvars('%ProgramFiles(x86)%'
'/Microsoft Visual Studio/2017/Community')):
if path and os.path.exists(path):
return path
raise Exception(('Visual Studio Version %s (from GYP_MSVS_VERSION)'
' not found.') % (version_as_year))
def _CopyRuntimeImpl(target, source, verbose=True):
"""Copy |source| to |target| if it doesn't already exist or if it needs to be
updated (comparing last modified time as an approximate float match as for
some reason the values tend to differ by ~1e-07 despite being copies of the
same file... https://crbug.com/603603).
Rework win_toolchains a bit and copy the vs runtime DLLs as needed. In order to run both the visual studio tools and the binaries built by them (and ninja), we need to ensure that the VS runtime DLLs are available in the path. In the GYP build, we accomplish this by copying them into the Debug and Debug_x64 dirs as appropriate inside the gyp_chromium script. In the pure-GN build, then, things would be broken, so we need to modify the GN build to do the copy as well, or we need to inject a step somewhere that happens after GN runs but before Ninja tries to run (since none of the toolchain binaries will work). This patch accomplishes this by calling out to vs_toolchain.py to copy the DLLs as neede when the toolchain is defined. This is somewhat less than ideal (makes 'gn gen' slower) but seems better than forcing devs to have to run an additional command. In addition, the GYP build writes targets into Debug and Debug_x64 concurrently. This doesn't really carry over into GN correctly, and we probably only ever want to write targets into Debug and Debug/64 (or some such). However, the way the toolchains are currently implemented, it's not clear if this really works and the interplay between 32-bit and 64-bit is weird (we apparently normally "force" 32-bit even if we set cpu_arch to 64-bit, and require you to specify force_win64). To work around this and make sure that we copy the right DLLs for the right arch into the outer Debug/ directory, this patch temporarily disables the cross-arch part of the build, forcing the host_toolchain to match the target_toolchain. This likely means that 'cpu_arch="x86"' works (the default), but the 'host' binaries like image_diff and mksnapshot will be compiled in 32-bit mode, not 64-bit mode. 'cpu_arch="x64" force_win64=true' should also work, and produce all-64-bit binaries. 'cpu_arch="x64"' does not work at all and won't until we can clean up the above stuff. R=scottmg@chromium.org, brettw@chromium.org BUG=430661 Review URL: https://codereview.chromium.org/722723004 Cr-Original-Commit-Position: refs/heads/master@{#304310} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 0b95195e49489b7a4d87048d2ce4b747173a5b8a
2014-11-15 03:09:14 +03:00
"""
if (os.path.isdir(os.path.dirname(target)) and
(not os.path.isfile(target) or
abs(os.stat(target).st_mtime - os.stat(source).st_mtime) >= 0.01)):
if verbose:
print 'Copying %s to %s...' % (source, target)
Rework win_toolchains a bit and copy the vs runtime DLLs as needed. In order to run both the visual studio tools and the binaries built by them (and ninja), we need to ensure that the VS runtime DLLs are available in the path. In the GYP build, we accomplish this by copying them into the Debug and Debug_x64 dirs as appropriate inside the gyp_chromium script. In the pure-GN build, then, things would be broken, so we need to modify the GN build to do the copy as well, or we need to inject a step somewhere that happens after GN runs but before Ninja tries to run (since none of the toolchain binaries will work). This patch accomplishes this by calling out to vs_toolchain.py to copy the DLLs as neede when the toolchain is defined. This is somewhat less than ideal (makes 'gn gen' slower) but seems better than forcing devs to have to run an additional command. In addition, the GYP build writes targets into Debug and Debug_x64 concurrently. This doesn't really carry over into GN correctly, and we probably only ever want to write targets into Debug and Debug/64 (or some such). However, the way the toolchains are currently implemented, it's not clear if this really works and the interplay between 32-bit and 64-bit is weird (we apparently normally "force" 32-bit even if we set cpu_arch to 64-bit, and require you to specify force_win64). To work around this and make sure that we copy the right DLLs for the right arch into the outer Debug/ directory, this patch temporarily disables the cross-arch part of the build, forcing the host_toolchain to match the target_toolchain. This likely means that 'cpu_arch="x86"' works (the default), but the 'host' binaries like image_diff and mksnapshot will be compiled in 32-bit mode, not 64-bit mode. 'cpu_arch="x64" force_win64=true' should also work, and produce all-64-bit binaries. 'cpu_arch="x64"' does not work at all and won't until we can clean up the above stuff. R=scottmg@chromium.org, brettw@chromium.org BUG=430661 Review URL: https://codereview.chromium.org/722723004 Cr-Original-Commit-Position: refs/heads/master@{#304310} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 0b95195e49489b7a4d87048d2ce4b747173a5b8a
2014-11-15 03:09:14 +03:00
if os.path.exists(target):
# Make the file writable so that we can delete it now, and keep it
# readable.
os.chmod(target, stat.S_IWRITE | stat.S_IREAD)
Rework win_toolchains a bit and copy the vs runtime DLLs as needed. In order to run both the visual studio tools and the binaries built by them (and ninja), we need to ensure that the VS runtime DLLs are available in the path. In the GYP build, we accomplish this by copying them into the Debug and Debug_x64 dirs as appropriate inside the gyp_chromium script. In the pure-GN build, then, things would be broken, so we need to modify the GN build to do the copy as well, or we need to inject a step somewhere that happens after GN runs but before Ninja tries to run (since none of the toolchain binaries will work). This patch accomplishes this by calling out to vs_toolchain.py to copy the DLLs as neede when the toolchain is defined. This is somewhat less than ideal (makes 'gn gen' slower) but seems better than forcing devs to have to run an additional command. In addition, the GYP build writes targets into Debug and Debug_x64 concurrently. This doesn't really carry over into GN correctly, and we probably only ever want to write targets into Debug and Debug/64 (or some such). However, the way the toolchains are currently implemented, it's not clear if this really works and the interplay between 32-bit and 64-bit is weird (we apparently normally "force" 32-bit even if we set cpu_arch to 64-bit, and require you to specify force_win64). To work around this and make sure that we copy the right DLLs for the right arch into the outer Debug/ directory, this patch temporarily disables the cross-arch part of the build, forcing the host_toolchain to match the target_toolchain. This likely means that 'cpu_arch="x86"' works (the default), but the 'host' binaries like image_diff and mksnapshot will be compiled in 32-bit mode, not 64-bit mode. 'cpu_arch="x64" force_win64=true' should also work, and produce all-64-bit binaries. 'cpu_arch="x64"' does not work at all and won't until we can clean up the above stuff. R=scottmg@chromium.org, brettw@chromium.org BUG=430661 Review URL: https://codereview.chromium.org/722723004 Cr-Original-Commit-Position: refs/heads/master@{#304310} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 0b95195e49489b7a4d87048d2ce4b747173a5b8a
2014-11-15 03:09:14 +03:00
os.unlink(target)
shutil.copy2(source, target)
# Make the file writable so that we can overwrite or delete it later,
# keep it readable.
os.chmod(target, stat.S_IWRITE | stat.S_IREAD)
Rework win_toolchains a bit and copy the vs runtime DLLs as needed. In order to run both the visual studio tools and the binaries built by them (and ninja), we need to ensure that the VS runtime DLLs are available in the path. In the GYP build, we accomplish this by copying them into the Debug and Debug_x64 dirs as appropriate inside the gyp_chromium script. In the pure-GN build, then, things would be broken, so we need to modify the GN build to do the copy as well, or we need to inject a step somewhere that happens after GN runs but before Ninja tries to run (since none of the toolchain binaries will work). This patch accomplishes this by calling out to vs_toolchain.py to copy the DLLs as neede when the toolchain is defined. This is somewhat less than ideal (makes 'gn gen' slower) but seems better than forcing devs to have to run an additional command. In addition, the GYP build writes targets into Debug and Debug_x64 concurrently. This doesn't really carry over into GN correctly, and we probably only ever want to write targets into Debug and Debug/64 (or some such). However, the way the toolchains are currently implemented, it's not clear if this really works and the interplay between 32-bit and 64-bit is weird (we apparently normally "force" 32-bit even if we set cpu_arch to 64-bit, and require you to specify force_win64). To work around this and make sure that we copy the right DLLs for the right arch into the outer Debug/ directory, this patch temporarily disables the cross-arch part of the build, forcing the host_toolchain to match the target_toolchain. This likely means that 'cpu_arch="x86"' works (the default), but the 'host' binaries like image_diff and mksnapshot will be compiled in 32-bit mode, not 64-bit mode. 'cpu_arch="x64" force_win64=true' should also work, and produce all-64-bit binaries. 'cpu_arch="x64"' does not work at all and won't until we can clean up the above stuff. R=scottmg@chromium.org, brettw@chromium.org BUG=430661 Review URL: https://codereview.chromium.org/722723004 Cr-Original-Commit-Position: refs/heads/master@{#304310} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 0b95195e49489b7a4d87048d2ce4b747173a5b8a
2014-11-15 03:09:14 +03:00
def _CopyUCRTRuntime(target_dir, source_dir, target_cpu, dll_pattern, suffix):
"""Copy both the msvcp and vccorlib runtime DLLs, only if the target doesn't
exist, but the target directory does exist."""
if target_cpu == 'arm64':
# Windows ARM64 VCRuntime is located at {toolchain_root}/VC/Redist/MSVC/
# {x.y.z}/[debug_nonredist/]arm64/Microsoft.VC141.CRT/.
vc_redist_root = FindVCRedistRoot()
if suffix.startswith('.'):
source_dir = os.path.join(vc_redist_root,
'arm64', 'Microsoft.VC141.CRT')
else:
source_dir = os.path.join(vc_redist_root, 'debug_nonredist',
'arm64', 'Microsoft.VC141.DebugCRT')
for file_part in ('msvcp', 'vccorlib', 'vcruntime'):
dll = dll_pattern % file_part
target = os.path.join(target_dir, dll)
source = os.path.join(source_dir, dll)
_CopyRuntimeImpl(target, source)
# Copy the UCRT files from the Windows SDK. This location includes the
# api-ms-win-crt-*.dll files that are not found in the Windows directory.
# These files are needed for component builds. If WINDOWSSDKDIR is not set
# use the default SDK path. This will be the case when
# DEPOT_TOOLS_WIN_TOOLCHAIN=0 and vcvarsall.bat has not been run.
win_sdk_dir = os.path.normpath(
os.environ.get('WINDOWSSDKDIR',
Reland "Fixed SDK lookup for non C:\ Windows installation." This reverts commit 864136ef9686128f4afbfe6146cd3e2d08182d52. Reason for revert: While it seems this did trigger the cdb failures in crbug.com/846313, it was not the root cause and reverting it didn't actually help. Original change's description: > Revert "Fixed SDK lookup for non C:\ Windows installation." > > This reverts commit 57fd44c74e13be05a3091976f9bcee39ee8f703e. > > Reason for revert: suspect for messing up symbols on Win7 bot > @ crbug.com/846313 > > Original change's description: > > Fixed SDK lookup for non C:\ Windows installation. > > > > Bug: None > > Change-Id: Ia0aa186d1d39b1beac8ce0152683f774ad5d2eaf > > Reviewed-on: https://chromium-review.googlesource.com/1066065 > > Reviewed-by: Jochen Eisinger <jochen@chromium.org> > > Commit-Queue: Jochen Eisinger <jochen@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#561063} > > TBR=jochen@chromium.org,yura.yaroshevich@gmail.com > > # Not skipping CQ checks because original CL landed > 1 day ago. > > Bug: 846313 > Change-Id: Id93a965aea5555961c539d47e05e79410894eff8 > Reviewed-on: https://chromium-review.googlesource.com/1072307 > Commit-Queue: Gabriel Charette <gab@chromium.org> > Reviewed-by: Gabriel Charette <gab@chromium.org> > Cr-Commit-Position: refs/heads/master@{#561609} TBR=gab@chromium.org,jochen@chromium.org,yura.yaroshevich@gmail.com Bug: 846313 Change-Id: I9955a47bbe8a81a0dcf7befebfc422560f8a1cc4 Reviewed-on: https://chromium-review.googlesource.com/1073314 Reviewed-by: Hans Wennborg <hans@chromium.org> Commit-Queue: Hans Wennborg <hans@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#561873} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 2e7257da41fbc81029fae5f306ae8123ec975f0c
2018-05-25 17:41:24 +03:00
os.path.expandvars('%ProgramFiles(x86)%'
'\\Windows Kits\\10')))
# ARM64 doesn't have a redist for the ucrt DLLs because they are always
# present in the OS.
if target_cpu != 'arm64':
ucrt_dll_dirs = os.path.join(win_sdk_dir, 'Redist', 'ucrt', 'DLLs',
target_cpu)
ucrt_files = glob.glob(os.path.join(ucrt_dll_dirs, 'api-ms-win-*.dll'))
assert len(ucrt_files) > 0
for ucrt_src_file in ucrt_files:
file_part = os.path.basename(ucrt_src_file)
ucrt_dst_file = os.path.join(target_dir, file_part)
_CopyRuntimeImpl(ucrt_dst_file, ucrt_src_file, False)
# We must copy ucrtbase.dll for x64/x86, and ucrtbased.dll for all CPU types.
if target_cpu != 'arm64' or not suffix.startswith('.'):
if not suffix.startswith('.'):
# ucrtbased.dll is located at {win_sdk_dir}/bin/{a.b.c.d}/{target_cpu}/
# ucrt/.
sdk_redist_root = os.path.join(win_sdk_dir, 'bin')
sdk_bin_sub_dirs = os.listdir(sdk_redist_root)
# Select the most recent SDK if there are multiple versions installed.
sdk_bin_sub_dirs.sort(reverse=True)
for directory in sdk_bin_sub_dirs:
sdk_redist_root_version = os.path.join(sdk_redist_root, directory)
if not os.path.isdir(sdk_redist_root_version):
continue
if re.match('10\.\d+\.\d+\.\d+', directory):
source_dir = os.path.join(sdk_redist_root_version, target_cpu, 'ucrt')
break
_CopyRuntimeImpl(os.path.join(target_dir, 'ucrtbase' + suffix),
os.path.join(source_dir, 'ucrtbase' + suffix))
Rework win_toolchains a bit and copy the vs runtime DLLs as needed. In order to run both the visual studio tools and the binaries built by them (and ninja), we need to ensure that the VS runtime DLLs are available in the path. In the GYP build, we accomplish this by copying them into the Debug and Debug_x64 dirs as appropriate inside the gyp_chromium script. In the pure-GN build, then, things would be broken, so we need to modify the GN build to do the copy as well, or we need to inject a step somewhere that happens after GN runs but before Ninja tries to run (since none of the toolchain binaries will work). This patch accomplishes this by calling out to vs_toolchain.py to copy the DLLs as neede when the toolchain is defined. This is somewhat less than ideal (makes 'gn gen' slower) but seems better than forcing devs to have to run an additional command. In addition, the GYP build writes targets into Debug and Debug_x64 concurrently. This doesn't really carry over into GN correctly, and we probably only ever want to write targets into Debug and Debug/64 (or some such). However, the way the toolchains are currently implemented, it's not clear if this really works and the interplay between 32-bit and 64-bit is weird (we apparently normally "force" 32-bit even if we set cpu_arch to 64-bit, and require you to specify force_win64). To work around this and make sure that we copy the right DLLs for the right arch into the outer Debug/ directory, this patch temporarily disables the cross-arch part of the build, forcing the host_toolchain to match the target_toolchain. This likely means that 'cpu_arch="x86"' works (the default), but the 'host' binaries like image_diff and mksnapshot will be compiled in 32-bit mode, not 64-bit mode. 'cpu_arch="x64" force_win64=true' should also work, and produce all-64-bit binaries. 'cpu_arch="x64"' does not work at all and won't until we can clean up the above stuff. R=scottmg@chromium.org, brettw@chromium.org BUG=430661 Review URL: https://codereview.chromium.org/722723004 Cr-Original-Commit-Position: refs/heads/master@{#304310} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 0b95195e49489b7a4d87048d2ce4b747173a5b8a
2014-11-15 03:09:14 +03:00
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'
SetEnvironmentAndGetRuntimeDllDirs()
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 FindVCRedistRoot():
"""In VS2017, Redist binaries are located in
{toolchain_root}/VC/Redist/MSVC/{x.y.z}/{target_cpu}/, the {version_number}
part is likely to change in case of minor update of the toolchain so we don't
hardcode this value here (except for the major number).
This returns the '{toolchain_root}/VC/Redist/MSVC/{x.y.z}/' path.
This function should only be called when using VS2017.
"""
assert GetVisualStudioVersion() == '2017'
SetEnvironmentAndGetRuntimeDllDirs()
assert ('GYP_MSVS_OVERRIDE_PATH' in os.environ)
vc_redist_msvc_root = os.path.join(os.environ['GYP_MSVS_OVERRIDE_PATH'],
'VC', 'Redist', 'MSVC')
for directory in os.listdir(vc_redist_msvc_root):
if not os.path.isdir(os.path.join(vc_redist_msvc_root, directory)):
continue
if re.match('14\.\d+\.\d+', directory):
return os.path.join(vc_redist_msvc_root, directory)
raise Exception('Unable to find the VC redist directory')
def _CopyPGORuntime(target_dir, target_cpu):
"""Copy the runtime dependencies required during a PGO build.
"""
env_version = GetVisualStudioVersion()
# These dependencies will be in a different location depending on the version
# of the toolchain.
if env_version == '2017':
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.
pgo_x86_runtime_dir = os.path.join(pgo_runtime_root, 'HostX86', 'x86')
pgo_x64_runtime_dir = os.path.join(pgo_runtime_root, 'HostX64', 'x64')
pgo_arm64_runtime_dir = os.path.join(pgo_runtime_root, 'arm64')
else:
raise Exception('Unexpected toolchain version: %s.' % env_version)
# We need to copy 2 runtime dependencies used during the profiling step:
# - pgort140.dll: runtime library required to run the instrumented image.
# - pgosweep.exe: executable used to collect the profiling data
pgo_runtimes = ['pgort140.dll', 'pgosweep.exe']
for runtime in pgo_runtimes:
if target_cpu == 'x86':
source = os.path.join(pgo_x86_runtime_dir, runtime)
elif target_cpu == 'x64':
source = os.path.join(pgo_x64_runtime_dir, runtime)
elif target_cpu == 'arm64':
source = os.path.join(pgo_arm64_runtime_dir, runtime)
else:
raise NotImplementedError('Unexpected target_cpu value: ' + target_cpu)
if not os.path.exists(source):
raise Exception('Unable to find %s.' % source)
_CopyRuntimeImpl(os.path.join(target_dir, runtime), source)
def _CopyRuntime(target_dir, source_dir, target_cpu, debug):
"""Copy the VS runtime DLLs, only if the target doesn't exist, but the target
directory does exist. Handles VS 2015 and VS 2017."""
suffix = 'd.dll' if debug else '.dll'
# VS 2017 uses the same CRT DLLs as VS 2015.
_CopyUCRTRuntime(target_dir, source_dir, target_cpu, '%s140' + suffix,
suffix)
Rework win_toolchains a bit and copy the vs runtime DLLs as needed. In order to run both the visual studio tools and the binaries built by them (and ninja), we need to ensure that the VS runtime DLLs are available in the path. In the GYP build, we accomplish this by copying them into the Debug and Debug_x64 dirs as appropriate inside the gyp_chromium script. In the pure-GN build, then, things would be broken, so we need to modify the GN build to do the copy as well, or we need to inject a step somewhere that happens after GN runs but before Ninja tries to run (since none of the toolchain binaries will work). This patch accomplishes this by calling out to vs_toolchain.py to copy the DLLs as neede when the toolchain is defined. This is somewhat less than ideal (makes 'gn gen' slower) but seems better than forcing devs to have to run an additional command. In addition, the GYP build writes targets into Debug and Debug_x64 concurrently. This doesn't really carry over into GN correctly, and we probably only ever want to write targets into Debug and Debug/64 (or some such). However, the way the toolchains are currently implemented, it's not clear if this really works and the interplay between 32-bit and 64-bit is weird (we apparently normally "force" 32-bit even if we set cpu_arch to 64-bit, and require you to specify force_win64). To work around this and make sure that we copy the right DLLs for the right arch into the outer Debug/ directory, this patch temporarily disables the cross-arch part of the build, forcing the host_toolchain to match the target_toolchain. This likely means that 'cpu_arch="x86"' works (the default), but the 'host' binaries like image_diff and mksnapshot will be compiled in 32-bit mode, not 64-bit mode. 'cpu_arch="x64" force_win64=true' should also work, and produce all-64-bit binaries. 'cpu_arch="x64"' does not work at all and won't until we can clean up the above stuff. R=scottmg@chromium.org, brettw@chromium.org BUG=430661 Review URL: https://codereview.chromium.org/722723004 Cr-Original-Commit-Position: refs/heads/master@{#304310} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 0b95195e49489b7a4d87048d2ce4b747173a5b8a
2014-11-15 03:09:14 +03:00
def CopyDlls(target_dir, configuration, target_cpu):
Rework win_toolchains a bit and copy the vs runtime DLLs as needed. In order to run both the visual studio tools and the binaries built by them (and ninja), we need to ensure that the VS runtime DLLs are available in the path. In the GYP build, we accomplish this by copying them into the Debug and Debug_x64 dirs as appropriate inside the gyp_chromium script. In the pure-GN build, then, things would be broken, so we need to modify the GN build to do the copy as well, or we need to inject a step somewhere that happens after GN runs but before Ninja tries to run (since none of the toolchain binaries will work). This patch accomplishes this by calling out to vs_toolchain.py to copy the DLLs as neede when the toolchain is defined. This is somewhat less than ideal (makes 'gn gen' slower) but seems better than forcing devs to have to run an additional command. In addition, the GYP build writes targets into Debug and Debug_x64 concurrently. This doesn't really carry over into GN correctly, and we probably only ever want to write targets into Debug and Debug/64 (or some such). However, the way the toolchains are currently implemented, it's not clear if this really works and the interplay between 32-bit and 64-bit is weird (we apparently normally "force" 32-bit even if we set cpu_arch to 64-bit, and require you to specify force_win64). To work around this and make sure that we copy the right DLLs for the right arch into the outer Debug/ directory, this patch temporarily disables the cross-arch part of the build, forcing the host_toolchain to match the target_toolchain. This likely means that 'cpu_arch="x86"' works (the default), but the 'host' binaries like image_diff and mksnapshot will be compiled in 32-bit mode, not 64-bit mode. 'cpu_arch="x64" force_win64=true' should also work, and produce all-64-bit binaries. 'cpu_arch="x64"' does not work at all and won't until we can clean up the above stuff. R=scottmg@chromium.org, brettw@chromium.org BUG=430661 Review URL: https://codereview.chromium.org/722723004 Cr-Original-Commit-Position: refs/heads/master@{#304310} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 0b95195e49489b7a4d87048d2ce4b747173a5b8a
2014-11-15 03:09:14 +03:00
"""Copy the VS runtime DLLs into the requested directory as needed.
configuration is one of 'Debug' or 'Release'.
target_cpu is one of 'x86', 'x64' or 'arm64'.
Rework win_toolchains a bit and copy the vs runtime DLLs as needed. In order to run both the visual studio tools and the binaries built by them (and ninja), we need to ensure that the VS runtime DLLs are available in the path. In the GYP build, we accomplish this by copying them into the Debug and Debug_x64 dirs as appropriate inside the gyp_chromium script. In the pure-GN build, then, things would be broken, so we need to modify the GN build to do the copy as well, or we need to inject a step somewhere that happens after GN runs but before Ninja tries to run (since none of the toolchain binaries will work). This patch accomplishes this by calling out to vs_toolchain.py to copy the DLLs as neede when the toolchain is defined. This is somewhat less than ideal (makes 'gn gen' slower) but seems better than forcing devs to have to run an additional command. In addition, the GYP build writes targets into Debug and Debug_x64 concurrently. This doesn't really carry over into GN correctly, and we probably only ever want to write targets into Debug and Debug/64 (or some such). However, the way the toolchains are currently implemented, it's not clear if this really works and the interplay between 32-bit and 64-bit is weird (we apparently normally "force" 32-bit even if we set cpu_arch to 64-bit, and require you to specify force_win64). To work around this and make sure that we copy the right DLLs for the right arch into the outer Debug/ directory, this patch temporarily disables the cross-arch part of the build, forcing the host_toolchain to match the target_toolchain. This likely means that 'cpu_arch="x86"' works (the default), but the 'host' binaries like image_diff and mksnapshot will be compiled in 32-bit mode, not 64-bit mode. 'cpu_arch="x64" force_win64=true' should also work, and produce all-64-bit binaries. 'cpu_arch="x64"' does not work at all and won't until we can clean up the above stuff. R=scottmg@chromium.org, brettw@chromium.org BUG=430661 Review URL: https://codereview.chromium.org/722723004 Cr-Original-Commit-Position: refs/heads/master@{#304310} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 0b95195e49489b7a4d87048d2ce4b747173a5b8a
2014-11-15 03:09:14 +03:00
The debug configuration gets both the debug and release DLLs; the
release config only the latter.
"""
vs_runtime_dll_dirs = SetEnvironmentAndGetRuntimeDllDirs()
if not vs_runtime_dll_dirs:
Rework win_toolchains a bit and copy the vs runtime DLLs as needed. In order to run both the visual studio tools and the binaries built by them (and ninja), we need to ensure that the VS runtime DLLs are available in the path. In the GYP build, we accomplish this by copying them into the Debug and Debug_x64 dirs as appropriate inside the gyp_chromium script. In the pure-GN build, then, things would be broken, so we need to modify the GN build to do the copy as well, or we need to inject a step somewhere that happens after GN runs but before Ninja tries to run (since none of the toolchain binaries will work). This patch accomplishes this by calling out to vs_toolchain.py to copy the DLLs as neede when the toolchain is defined. This is somewhat less than ideal (makes 'gn gen' slower) but seems better than forcing devs to have to run an additional command. In addition, the GYP build writes targets into Debug and Debug_x64 concurrently. This doesn't really carry over into GN correctly, and we probably only ever want to write targets into Debug and Debug/64 (or some such). However, the way the toolchains are currently implemented, it's not clear if this really works and the interplay between 32-bit and 64-bit is weird (we apparently normally "force" 32-bit even if we set cpu_arch to 64-bit, and require you to specify force_win64). To work around this and make sure that we copy the right DLLs for the right arch into the outer Debug/ directory, this patch temporarily disables the cross-arch part of the build, forcing the host_toolchain to match the target_toolchain. This likely means that 'cpu_arch="x86"' works (the default), but the 'host' binaries like image_diff and mksnapshot will be compiled in 32-bit mode, not 64-bit mode. 'cpu_arch="x64" force_win64=true' should also work, and produce all-64-bit binaries. 'cpu_arch="x64"' does not work at all and won't until we can clean up the above stuff. R=scottmg@chromium.org, brettw@chromium.org BUG=430661 Review URL: https://codereview.chromium.org/722723004 Cr-Original-Commit-Position: refs/heads/master@{#304310} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 0b95195e49489b7a4d87048d2ce4b747173a5b8a
2014-11-15 03:09:14 +03:00
return
x64_runtime, x86_runtime, arm64_runtime = vs_runtime_dll_dirs
if target_cpu == 'x64':
runtime_dir = x64_runtime
elif target_cpu == 'x86':
runtime_dir = x86_runtime
elif target_cpu == 'arm64':
runtime_dir = arm64_runtime
else:
raise Exception('Unknown target_cpu: ' + target_cpu)
_CopyRuntime(target_dir, runtime_dir, target_cpu, debug=False)
Rework win_toolchains a bit and copy the vs runtime DLLs as needed. In order to run both the visual studio tools and the binaries built by them (and ninja), we need to ensure that the VS runtime DLLs are available in the path. In the GYP build, we accomplish this by copying them into the Debug and Debug_x64 dirs as appropriate inside the gyp_chromium script. In the pure-GN build, then, things would be broken, so we need to modify the GN build to do the copy as well, or we need to inject a step somewhere that happens after GN runs but before Ninja tries to run (since none of the toolchain binaries will work). This patch accomplishes this by calling out to vs_toolchain.py to copy the DLLs as neede when the toolchain is defined. This is somewhat less than ideal (makes 'gn gen' slower) but seems better than forcing devs to have to run an additional command. In addition, the GYP build writes targets into Debug and Debug_x64 concurrently. This doesn't really carry over into GN correctly, and we probably only ever want to write targets into Debug and Debug/64 (or some such). However, the way the toolchains are currently implemented, it's not clear if this really works and the interplay between 32-bit and 64-bit is weird (we apparently normally "force" 32-bit even if we set cpu_arch to 64-bit, and require you to specify force_win64). To work around this and make sure that we copy the right DLLs for the right arch into the outer Debug/ directory, this patch temporarily disables the cross-arch part of the build, forcing the host_toolchain to match the target_toolchain. This likely means that 'cpu_arch="x86"' works (the default), but the 'host' binaries like image_diff and mksnapshot will be compiled in 32-bit mode, not 64-bit mode. 'cpu_arch="x64" force_win64=true' should also work, and produce all-64-bit binaries. 'cpu_arch="x64"' does not work at all and won't until we can clean up the above stuff. R=scottmg@chromium.org, brettw@chromium.org BUG=430661 Review URL: https://codereview.chromium.org/722723004 Cr-Original-Commit-Position: refs/heads/master@{#304310} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 0b95195e49489b7a4d87048d2ce4b747173a5b8a
2014-11-15 03:09:14 +03:00
if configuration == 'Debug':
_CopyRuntime(target_dir, runtime_dir, target_cpu, debug=True)
else:
_CopyPGORuntime(target_dir, target_cpu)
_CopyDebugger(target_dir, target_cpu)
def _CopyDebugger(target_dir, target_cpu):
"""Copy dbghelp.dll and dbgcore.dll into the requested directory as needed.
target_cpu is one of 'x86', 'x64' or 'arm64'.
dbghelp.dll is used when Chrome needs to symbolize stacks. Copying this file
from the SDK directory avoids using the system copy of dbghelp.dll which then
ensures compatibility with recent debug information formats, such as VS
2017 /debug:fastlink PDBs.
dbgcore.dll is needed when using some functions from dbghelp.dll (like
MinidumpWriteDump).
"""
win_sdk_dir = SetEnvironmentAndGetSDKDir()
if not win_sdk_dir:
return
# List of debug files that should be copied, the first element of the tuple is
# the name of the file and the second indicates if it's optional.
debug_files = [('dbghelp.dll', False), ('dbgcore.dll', True)]
for debug_file, is_optional in debug_files:
full_path = os.path.join(win_sdk_dir, 'Debuggers', target_cpu, debug_file)
if not os.path.exists(full_path):
if is_optional:
continue
else:
# TODO(crbug.com/773476): remove version requirement.
raise Exception('%s not found in "%s"\r\nYou must install the '
'"Debugging Tools for Windows" feature from the Windows'
Reland "Switch to VS 2017 15.7.1 with 10.0.17134.0 SDK" This is a reland of 5a7f3c442684be5eeb244b904bbfc8e6edaf6fda goma now supports this compiler and the new warnings were dealt with. Original change's description: > Switch to VS 2017 15.7.1 with 10.0.17134.0 SDK > > This change switches the VS 2017 package to use VS 2017 Update 7.1 while > using the 10.0.17134.12 SDK. The new SDK is needed to support new HDR > features, and to stop forcing external developers to install an old > ([Spring] Creators Update) SDK. This change will also bring in a new > linker and other build tools, but the version of clang-cl will be > unchanged. > > Packaging was done on a Windows Server 2016 VM, cleanly created for this > purpose. > > Compiler was packaged up by downloading VS 2017 Update 7.1, from > https://www.visualstudio.com/vs/, and then passing these parameters to > the installer: > > --add Microsoft.VisualStudio.Workload.NativeDesktop > --add Microsoft.VisualStudio.Component.VC.ATLMFC --includeRecommended > --passive > > Then Add or Remove Programs was used to modify the 10.0.17134.0 SDK to add > the Debuggers package. > > Then the packaging script was run like this: > > python depot_tools\win_toolchain\package_from_installed.py 2017 -w 10.0.17134.0 > > Bug: 773476 > Change-Id: Ic819f3ae79d7e869227bf33fbb8d202e2f57039b > Reviewed-on: https://chromium-review.googlesource.com/1054027 > Reviewed-by: Nico Weber <thakis@chromium.org> > Reviewed-by: Dirk Pranke <dpranke@chromium.org> > Commit-Queue: Bruce Dawson <brucedawson@chromium.org> > Cr-Commit-Position: refs/heads/master@{#559033} Bug: 773476,834213 Change-Id: I903158f9dfa604f250010a7047496509f51782e7 Reviewed-on: https://chromium-review.googlesource.com/1066130 Reviewed-by: Nico Weber <thakis@chromium.org> Reviewed-by: Dirk Pranke <dpranke@chromium.org> Commit-Queue: Bruce Dawson <brucedawson@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#560002} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 82a5f004e0e52897a6e8bac10490a14fc2845625
2018-05-18 23:05:49 +03:00
' 10 SDK. You must use v10.0.17134.0. of the SDK'
% (debug_file, full_path))
target_path = os.path.join(target_dir, debug_file)
_CopyRuntimeImpl(target_path, full_path)
def _GetDesiredVsToolchainHashes():
"""Load a list of SHA1s corresponding to the toolchains that we want installed
to build with."""
env_version = GetVisualStudioVersion()
Add VS 2017 toolchain hash This change adds a hash for the VS 2017 RTM toolchain download in depot tools. This allows Googlers to use VS 2017 to build Chrome without needing to install it, and lets build machines use VS 2017 (although they continue to default to VS 2015. The package was created on a Windows Server 2016 VM. One would hope that the OS used wouldn't matter, but ...? Previous installs of VS 2015 or the platform SDK are likely to leave files lying around that will alter the hash so a clean VM is needed. Then follow these steps: Install VS 2017 Professional RTM, selecting the "Desktop development with C++" component, and add the MFC and ATL support option. After this is done you need to install the debugger packages from the Windows 10 SDK. Go to: https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk and be sure to check the Debugging Tools option. Once the installers have downloaded you can find the x86 and x64 debugger installers in the download directory in "Windows Kits\10\StandaloneSDK\Installers" - run them both. Then run the packaging script, like this: > python depot_tools\win_toolchain\package_from_installed.py 2017 Note that this packages the 10.0.14393.0 SDK, but this is not the same 10.0.14393.0 SDK that was used in the previous VS 2015 packaging. The SDK was updated without changing the version number. Most of the changes should not matter, but be aware. To use this package set these two environment variables: DEPOT_TOOLS_WIN_TOOLCHAIN=1 GYP_MSVS_VERSION=2017 Then run "gclient runhooks" to download the new package. The .ninja files will not automatically update so you may need to run gn gen on your output directories. The 'chrome' target should build cleanly without warnings. However VS 2017 is not yet a supported toolchain so warnings may appear. You may want to use the treat_warnings_as_errors = false build flag. To run VS 2017 tests on the buildbots you need to change the CURRENT_DEFAULT_TOOLCHAIN_VERSION in build\vs_toolchain.py to '2017' and you need to add a landmine to force a rebuild. The build process was tested on two separate VMs to ensure that the results were consistent. They were. BUG=683729 Review-Url: https://codereview.chromium.org/2777643002 Cr-Original-Commit-Position: refs/heads/master@{#459593} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 560bb951d9a6625633fcad4e4168fb7054bb4dfa
2017-03-25 02:10:01 +03:00
if env_version == '2017':
Update toolchain package to fix dbghelp.dll bug This change updates the VS 2017 package to fix a bad version of dbghelp.dll in the Debuggers package, caused by a now-obsolete workaround in the packaging script, removed in crrev.com/c/1086990. The package still uses VS 2017 Update 7.1 and the 10.0.17134.12 SDK. Packaging was done on a Windows Server 2016 VM, cleanly created for this purpose. Compiler was packaged up by downloading VS 2017 Update 7.1, from https://www.visualstudio.com/vs/, and then passing these parameters to the installer: --add Microsoft.VisualStudio.Workload.NativeDesktop --add Microsoft.VisualStudio.Component.VC.ATLMFC --includeRecommended --passive Then Add or Remove Programs was used to modify the 10.0.17134.0 SDK to add the Debuggers package. Then the packaging script was run like this: python depot_tools\win_toolchain\package_from_installed.py 2017 -w 10.0.17134.0 The results were compared to make sure that there were no unintended changes. One quirk is that the new package is missing the arm/arm64 directories in Debuggers, which is correct, whereas the previous package was *not* missing them, for some reason. Other than that there are no unintended changes. Bug: 773476, 846313 Change-Id: I43db2ea95999fb7b2aeb02ba078e70298b62ffad Reviewed-on: https://chromium-review.googlesource.com/1086992 Reviewed-by: Nico Weber <thakis@chromium.org> Commit-Queue: Bruce Dawson <brucedawson@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#565106} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: ac88874511d02aaf42ebbefaf078d8c8f8c2af8a
2018-06-07 02:52:33 +03:00
# VS 2017 Update 7.1 (15.7.1) with 10.0.17134.12 SDK, rebuilt with
# dbghelp.dll fix.
toolchain_hash = '3bc0ec615cf20ee342f3bc29bc991b5ad66d8d2c'
# Third parties that do not have access to the canonical toolchain can map
# canonical toolchain version to their own toolchain versions.
toolchain_hash_mapping_key = 'GYP_MSVS_HASH_%s' % toolchain_hash
return [os.environ.get(toolchain_hash_mapping_key, toolchain_hash)]
raise Exception('Unsupported VS version %s' % env_version)
def ShouldUpdateToolchain():
"""Check if the toolchain should be upgraded."""
if not os.path.exists(json_data_file):
return True
with open(json_data_file, 'r') as tempf:
toolchain_data = json.load(tempf)
version = toolchain_data['version']
env_version = GetVisualStudioVersion()
# If there's a mismatch between the version set in the environment and the one
# in the json file then the toolchain should be updated.
return version != env_version
def Update(force=False):
"""Requests an update of the toolchain to the specific hashes we have at
this revision. The update outputs a .json of the various configuration
information required to pass to gyp which we use in |GetToolchainDir()|.
"""
if force != False and force != '--force':
print >>sys.stderr, 'Unknown parameter "%s"' % force
return 1
if force == '--force' or os.path.exists(json_data_file):
force = True
depot_tools_win_toolchain = \
bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')))
if ((sys.platform in ('win32', 'cygwin') or force) and
depot_tools_win_toolchain):
import find_depot_tools
depot_tools_path = find_depot_tools.add_depot_tools_to_path()
# On Linux, the file system is usually case-sensitive while the Windows
# SDK only works on case-insensitive file systems. If it doesn't already
# exist, set up a ciopfs fuse mount to put the SDK in a case-insensitive
# part of the file system.
toolchain_dir = os.path.join(depot_tools_path, 'win_toolchain', 'vs_files')
# For testing this block, unmount existing mounts with
# fusermount -u third_party/depot_tools/win_toolchain/vs_files
if sys.platform.startswith('linux') and not os.path.ismount(toolchain_dir):
import distutils.spawn
ciopfs = distutils.spawn.find_executable('ciopfs')
if not ciopfs:
# ciopfs not found in PATH; try the one downloaded from the DEPS hook.
ciopfs = os.path.join(script_dir, 'ciopfs')
if not os.path.isdir(toolchain_dir):
os.mkdir(toolchain_dir)
if not os.path.isdir(toolchain_dir + '.ciopfs'):
os.mkdir(toolchain_dir + '.ciopfs')
# Without use_ino, clang's #pragma once and Wnonportable-include-path
# both don't work right, see https://llvm.org/PR34931
# use_ino doesn't slow down builds, so it seems there's no drawback to
# just using it always.
subprocess.check_call([
ciopfs, '-o', 'use_ino', toolchain_dir + '.ciopfs', toolchain_dir])
Reland of Change default Windows compiler to VS 2015 (patchset #1 id:1 of https://codereview.chromium.org/1778343002/ ) Reason for revert: Preparing a revert in order to reland VS 2015. The CL is not reading for committing yet. Original issue's description: > Revert of Change default Windows compiler to VS 2015 (patchset #1 id:1 of https://codereview.chromium.org/1740583002/ ) > > Reason for revert: > Broke isolate tests on Win8 GN (dbg) and Win x64 GN (dbg). > > Original issue's description: > > Reland of Change default Windows compiler to VS 2015 > > > > The change to get_landmines.py is there because modifying this file > > affects analyze behavior so that all tests run. Changing the printed > > message is purely a side effect. > > > > This change also removes some redundant INCLUDE paths. These are > > unnecessary when building with VS 2015 (because it defaults to the > > Windows 10 SDK) and actively harmful (they make the INCLUDE path > > problematically long). > > > > This change was redone in order to fix merge conflicts and because after > > a few weeks a fresh set of approvals seems reasonable. > > > > The original change was landed as crrev.com/1598493004 > > > > BUG=440500, 584782 > > > > Committed: https://crrev.com/d4dcbd342dd54f55383daf8bc44b2c9d97fe0d0b > > Cr-Commit-Position: refs/heads/master@{#380382} > > TBR=scottmg@chromium.org,dpranke@chromium.org,brucedawson@chromium.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=440500, 584782 > > Committed: https://crrev.com/cb3f85f80a2c146e0e4bf064f02bf68acb274ce5 > Cr-Commit-Position: refs/heads/master@{#380395} TBR=scottmg@chromium.org,dpranke@chromium.org,vasilii@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=440500, 584782 Review URL: https://codereview.chromium.org/1783773004 Cr-Original-Commit-Position: refs/heads/master@{#380711} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 2b33e7eee5db5f956426dbf664f68bff3fe7daee
2016-03-11 22:55:25 +03:00
# Necessary so that get_toolchain_if_necessary.py will put the VS toolkit
# in the correct directory.
os.environ['GYP_MSVS_VERSION'] = GetVisualStudioVersion()
get_toolchain_args = [
sys.executable,
os.path.join(depot_tools_path,
'win_toolchain',
'get_toolchain_if_necessary.py'),
'--output-json', json_data_file,
] + _GetDesiredVsToolchainHashes()
if force:
get_toolchain_args.append('--force')
subprocess.check_call(get_toolchain_args)
return 0
def NormalizePath(path):
while path.endswith('\\'):
path = path[:-1]
return path
def SetEnvironmentAndGetSDKDir():
"""Gets location information about the current sdk (must have been
previously updated by 'update'). This is used for the GN build."""
SetEnvironmentAndGetRuntimeDllDirs()
# If WINDOWSSDKDIR is not set, search the default SDK path and set it.
if not 'WINDOWSSDKDIR' in os.environ:
WinUWP store application support is out of date This is required to support building Microsoft's WinUWP store application version of WebRTC. vs_toolchain.py - needed to perform environment variable expansion for "Program Files(x86)" to correctly identify Visual Studio installation location config/BUILD.gn - remove delayimp.lib, kernel32.lib and ole32.lib from store applications (instead requires dloadhelper.lib/WindowsApp.lib must be used) BUILDCONFIG.gn - Do not use clang when compiling Windows UWP targets; - Added declare_args for is_target_winuwp rather and stripped multi defined variations of the host_os/current_os == "winrt_10", "winrt_81", "winrt_81_phone" that heavily polluted the platform / target selections (as the current targeting methodology is incorrect anyway). The host_os/current_os is always be "win" and only the target should be Windows UWP / store applications based on the target_os == "winuwp" rather than all the flavors of UWP. - Added filter for _winuwp source files (separate from just windows) - Added default configs for desktop vs store applications to correctly set the defines according to the desktop vs store targets config/win/BUILD.gn - The Windows UWP versioning assumes to be Windows 10 / store app now although a updated GN allows for targeting older Windows UWP versions/SDKs/device families. This allows the definitions for the various application support versioning and application families required for UWP to be set. - The linker calls vsvarsall.bat to be executed via toolchain/win/setup_toolchain.py in order to correctly identify the correct linker library path information for Windows store SDK targets. The hard coded and assumed library paths are fixed in all cases to be discovered from the tooling for forward future platform support in all cases. - Added ARM linkage definitions for the Windows ARM CPU required for properly targeting all three CPUs (x86, x64, arm) for universal store binaries. - Added the proper family C++/C defines required to target the various Windows store application types currently offered for Windows UWP store applications. toolchain/win/BUILD.gn - The name to support the storage of the environment variables now is passed into the setup script to allow for easier extension of the CPUs and target combinations (arm, x64, x86 in the desktop vs store variations) - "desktop" vs "store" is now specified the setup for the correct toolchain targeting - Sets true/false for is_target_winuwp is dependent on the toolchain activated (so configurations will be set correctly when the toolchain is specified for host tool targets required for build tools vs finalized application targets) - Cleaned up the Windows RT section to properly support Windows UWP toolchains toolchain/win/setup_toolchain.py - the setup was missing the arm CPU for universal binaries required for the UWP platform - The calling of vcvarsall.bat was missing the "store" option for store applications and all the CPU offered - Added returning of linker paths by searching the library environments for well-known library files expected in each of the 3 library paths required "lib", "um" and "atlmfc" R=phoglund@google.com Bug: 812814 Change-Id: If1a6b1b1bc3ed940fc8e2ce726ac016e2491e61d Reviewed-on: https://chromium-review.googlesource.com/923161 Commit-Queue: Patrik Höglund <phoglund@chromium.org> Reviewed-by: Dirk Pranke <dpranke@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#545751} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: c5686578e8f519eeec50f574b284fbc12e6e15d8
2018-03-26 13:07:40 +03:00
default_sdk_path = os.path.expandvars('%ProgramFiles(x86)%'
'\\Windows Kits\\10')
if os.path.isdir(default_sdk_path):
os.environ['WINDOWSSDKDIR'] = default_sdk_path
return NormalizePath(os.environ['WINDOWSSDKDIR'])
def GetToolchainDir():
"""Gets location information about the current toolchain (must have been
previously updated by 'update'). This is used for the GN build."""
runtime_dll_dirs = SetEnvironmentAndGetRuntimeDllDirs()
win_sdk_dir = SetEnvironmentAndGetSDKDir()
print '''vs_path = %s
sdk_path = %s
vs_version = %s
wdk_dir = %s
runtime_dirs = %s
''' % (
ToGNString(NormalizePath(os.environ['GYP_MSVS_OVERRIDE_PATH'])),
ToGNString(win_sdk_dir),
ToGNString(GetVisualStudioVersion()),
ToGNString(NormalizePath(os.environ.get('WDK_DIR', ''))),
ToGNString(os.path.pathsep.join(runtime_dll_dirs or ['None'])))
def main():
commands = {
'update': Update,
'get_toolchain_dir': GetToolchainDir,
Rework win_toolchains a bit and copy the vs runtime DLLs as needed. In order to run both the visual studio tools and the binaries built by them (and ninja), we need to ensure that the VS runtime DLLs are available in the path. In the GYP build, we accomplish this by copying them into the Debug and Debug_x64 dirs as appropriate inside the gyp_chromium script. In the pure-GN build, then, things would be broken, so we need to modify the GN build to do the copy as well, or we need to inject a step somewhere that happens after GN runs but before Ninja tries to run (since none of the toolchain binaries will work). This patch accomplishes this by calling out to vs_toolchain.py to copy the DLLs as neede when the toolchain is defined. This is somewhat less than ideal (makes 'gn gen' slower) but seems better than forcing devs to have to run an additional command. In addition, the GYP build writes targets into Debug and Debug_x64 concurrently. This doesn't really carry over into GN correctly, and we probably only ever want to write targets into Debug and Debug/64 (or some such). However, the way the toolchains are currently implemented, it's not clear if this really works and the interplay between 32-bit and 64-bit is weird (we apparently normally "force" 32-bit even if we set cpu_arch to 64-bit, and require you to specify force_win64). To work around this and make sure that we copy the right DLLs for the right arch into the outer Debug/ directory, this patch temporarily disables the cross-arch part of the build, forcing the host_toolchain to match the target_toolchain. This likely means that 'cpu_arch="x86"' works (the default), but the 'host' binaries like image_diff and mksnapshot will be compiled in 32-bit mode, not 64-bit mode. 'cpu_arch="x64" force_win64=true' should also work, and produce all-64-bit binaries. 'cpu_arch="x64"' does not work at all and won't until we can clean up the above stuff. R=scottmg@chromium.org, brettw@chromium.org BUG=430661 Review URL: https://codereview.chromium.org/722723004 Cr-Original-Commit-Position: refs/heads/master@{#304310} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 0b95195e49489b7a4d87048d2ce4b747173a5b8a
2014-11-15 03:09:14 +03:00
'copy_dlls': CopyDlls,
}
if len(sys.argv) < 2 or sys.argv[1] not in commands:
print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands)
return 1
Rework win_toolchains a bit and copy the vs runtime DLLs as needed. In order to run both the visual studio tools and the binaries built by them (and ninja), we need to ensure that the VS runtime DLLs are available in the path. In the GYP build, we accomplish this by copying them into the Debug and Debug_x64 dirs as appropriate inside the gyp_chromium script. In the pure-GN build, then, things would be broken, so we need to modify the GN build to do the copy as well, or we need to inject a step somewhere that happens after GN runs but before Ninja tries to run (since none of the toolchain binaries will work). This patch accomplishes this by calling out to vs_toolchain.py to copy the DLLs as neede when the toolchain is defined. This is somewhat less than ideal (makes 'gn gen' slower) but seems better than forcing devs to have to run an additional command. In addition, the GYP build writes targets into Debug and Debug_x64 concurrently. This doesn't really carry over into GN correctly, and we probably only ever want to write targets into Debug and Debug/64 (or some such). However, the way the toolchains are currently implemented, it's not clear if this really works and the interplay between 32-bit and 64-bit is weird (we apparently normally "force" 32-bit even if we set cpu_arch to 64-bit, and require you to specify force_win64). To work around this and make sure that we copy the right DLLs for the right arch into the outer Debug/ directory, this patch temporarily disables the cross-arch part of the build, forcing the host_toolchain to match the target_toolchain. This likely means that 'cpu_arch="x86"' works (the default), but the 'host' binaries like image_diff and mksnapshot will be compiled in 32-bit mode, not 64-bit mode. 'cpu_arch="x64" force_win64=true' should also work, and produce all-64-bit binaries. 'cpu_arch="x64"' does not work at all and won't until we can clean up the above stuff. R=scottmg@chromium.org, brettw@chromium.org BUG=430661 Review URL: https://codereview.chromium.org/722723004 Cr-Original-Commit-Position: refs/heads/master@{#304310} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 0b95195e49489b7a4d87048d2ce4b747173a5b8a
2014-11-15 03:09:14 +03:00
return commands[sys.argv[1]](*sys.argv[2:])
if __name__ == '__main__':
sys.exit(main())