Source release v3.3.0
This commit is contained in:
106
third_party/gyp/MSVSVersion.py
vendored
106
third_party/gyp/MSVSVersion.py
vendored
@@ -13,12 +13,16 @@ import gyp
|
||||
import glob
|
||||
|
||||
|
||||
def JoinPath(*args):
|
||||
return os.path.normpath(os.path.join(*args))
|
||||
|
||||
|
||||
class VisualStudioVersion(object):
|
||||
"""Information regarding a version of Visual Studio."""
|
||||
|
||||
def __init__(self, short_name, description,
|
||||
solution_version, project_version, flat_sln, uses_vcxproj,
|
||||
path, sdk_based, default_toolset=None):
|
||||
path, sdk_based, default_toolset=None, compatible_sdks=None):
|
||||
self.short_name = short_name
|
||||
self.description = description
|
||||
self.solution_version = solution_version
|
||||
@@ -28,6 +32,9 @@ class VisualStudioVersion(object):
|
||||
self.path = path
|
||||
self.sdk_based = sdk_based
|
||||
self.default_toolset = default_toolset
|
||||
compatible_sdks = compatible_sdks or []
|
||||
compatible_sdks.sort(key=lambda v: float(v.replace('v', '')), reverse=True)
|
||||
self.compatible_sdks = compatible_sdks
|
||||
|
||||
def ShortName(self):
|
||||
return self.short_name
|
||||
@@ -68,45 +75,59 @@ class VisualStudioVersion(object):
|
||||
of a user override."""
|
||||
return self.default_toolset
|
||||
|
||||
|
||||
def _SetupScriptInternal(self, target_arch):
|
||||
"""Returns a command (with arguments) to be used to set up the
|
||||
environment."""
|
||||
assert target_arch in ('x86', 'x64'), "target_arch not supported"
|
||||
# If WindowsSDKDir is set and SetEnv.Cmd exists then we are using the
|
||||
# depot_tools build tools and should run SetEnv.Cmd to set up the
|
||||
# environment. The check for WindowsSDKDir alone is not sufficient because
|
||||
# this is set by running vcvarsall.bat.
|
||||
assert target_arch in ('x86', 'x64')
|
||||
sdk_dir = os.environ.get('WindowsSDKDir')
|
||||
if sdk_dir:
|
||||
setup_path = os.path.normpath(os.path.join(sdk_dir, 'Bin/SetEnv.Cmd'))
|
||||
sdk_dir = os.environ.get('WindowsSDKDir', '')
|
||||
setup_path = JoinPath(sdk_dir, 'Bin', 'SetEnv.Cmd')
|
||||
if self.sdk_based and sdk_dir and os.path.exists(setup_path):
|
||||
return [setup_path, '/' + target_arch]
|
||||
else:
|
||||
# We don't use VC/vcvarsall.bat for x86 because vcvarsall calls
|
||||
# vcvars32, which it can only find if VS??COMNTOOLS is set, which it
|
||||
# isn't always.
|
||||
if target_arch == 'x86':
|
||||
if self.short_name >= '2013' and self.short_name[-1] != 'e' and (
|
||||
os.environ.get('PROCESSOR_ARCHITECTURE') == 'AMD64' or
|
||||
os.environ.get('PROCESSOR_ARCHITEW6432') == 'AMD64'):
|
||||
# VS2013 and later, non-Express have a x64-x86 cross that we want
|
||||
# to prefer.
|
||||
return [os.path.normpath(
|
||||
os.path.join(self.path, 'VC/vcvarsall.bat')), 'amd64_x86']
|
||||
# Otherwise, the standard x86 compiler.
|
||||
return [os.path.normpath(
|
||||
os.path.join(self.path, 'Common7/Tools/vsvars32.bat'))]
|
||||
|
||||
is_host_arch_x64 = (
|
||||
os.environ.get('PROCESSOR_ARCHITECTURE') == 'AMD64' or
|
||||
os.environ.get('PROCESSOR_ARCHITEW6432') == 'AMD64'
|
||||
)
|
||||
|
||||
# For VS2017 (and newer) it's fairly easy
|
||||
if self.short_name >= '2017':
|
||||
script_path = JoinPath(self.path,
|
||||
'VC', 'Auxiliary', 'Build', 'vcvarsall.bat')
|
||||
|
||||
# Always use a native executable, cross-compiling if necessary.
|
||||
host_arch = 'amd64' if is_host_arch_x64 else 'x86'
|
||||
msvc_target_arch = 'amd64' if target_arch == 'x64' else 'x86'
|
||||
arg = host_arch
|
||||
if host_arch != msvc_target_arch:
|
||||
arg += '_' + msvc_target_arch
|
||||
|
||||
return [script_path, arg]
|
||||
|
||||
# We try to find the best version of the env setup batch.
|
||||
vcvarsall = JoinPath(self.path, 'VC', 'vcvarsall.bat')
|
||||
if target_arch == 'x86':
|
||||
if self.short_name >= '2013' and self.short_name[-1] != 'e' and \
|
||||
is_host_arch_x64:
|
||||
# VS2013 and later, non-Express have a x64-x86 cross that we want
|
||||
# to prefer.
|
||||
return [vcvarsall, 'amd64_x86']
|
||||
else:
|
||||
assert target_arch == 'x64'
|
||||
arg = 'x86_amd64'
|
||||
# Use the 64-on-64 compiler if we're not using an express
|
||||
# edition and we're running on a 64bit OS.
|
||||
if self.short_name[-1] != 'e' and (
|
||||
os.environ.get('PROCESSOR_ARCHITECTURE') == 'AMD64' or
|
||||
os.environ.get('PROCESSOR_ARCHITEW6432') == 'AMD64'):
|
||||
arg = 'amd64'
|
||||
return [os.path.normpath(
|
||||
os.path.join(self.path, 'VC/vcvarsall.bat')), arg]
|
||||
# Otherwise, the standard x86 compiler. We don't use VC/vcvarsall.bat
|
||||
# for x86 because vcvarsall calls vcvars32, which it can only find if
|
||||
# VS??COMNTOOLS is set, which isn't guaranteed.
|
||||
return [JoinPath(self.path, 'Common7', 'Tools', 'vsvars32.bat')]
|
||||
elif target_arch == 'x64':
|
||||
arg = 'x86_amd64'
|
||||
# Use the 64-on-64 compiler if we're not using an express edition and
|
||||
# we're running on a 64bit OS.
|
||||
if self.short_name[-1] != 'e' and is_host_arch_x64:
|
||||
arg = 'amd64'
|
||||
return [vcvarsall, arg]
|
||||
|
||||
def SetupScript(self, target_arch):
|
||||
script_data = self._SetupScriptInternal(target_arch)
|
||||
@@ -236,6 +257,16 @@ def _CreateVersion(name, path, sdk_based=False):
|
||||
if path:
|
||||
path = os.path.normpath(path)
|
||||
versions = {
|
||||
'2017': VisualStudioVersion('2017',
|
||||
'Visual Studio 2017',
|
||||
solution_version='12.00',
|
||||
project_version='15.0',
|
||||
flat_sln=False,
|
||||
uses_vcxproj=True,
|
||||
path=path,
|
||||
sdk_based=sdk_based,
|
||||
default_toolset='v141',
|
||||
compatible_sdks=['v8.1', 'v10.0']),
|
||||
'2015': VisualStudioVersion('2015',
|
||||
'Visual Studio 2015',
|
||||
solution_version='12.00',
|
||||
@@ -348,7 +379,6 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
|
||||
A list of visual studio versions installed in descending order of
|
||||
usage preference.
|
||||
Base this on the registry and a quick check if devenv.exe exists.
|
||||
Only versions 8-10 are considered.
|
||||
Possibilities are:
|
||||
2005(e) - Visual Studio 2005 (8)
|
||||
2008(e) - Visual Studio 2008 (9)
|
||||
@@ -356,6 +386,7 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
|
||||
2012(e) - Visual Studio 2012 (11)
|
||||
2013(e) - Visual Studio 2013 (12)
|
||||
2015 - Visual Studio 2015 (14)
|
||||
2017 - Visual Studio 2017 (15)
|
||||
Where (e) is e for express editions of MSVS and blank otherwise.
|
||||
"""
|
||||
version_to_year = {
|
||||
@@ -365,6 +396,7 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
|
||||
'11.0': '2012',
|
||||
'12.0': '2013',
|
||||
'14.0': '2015',
|
||||
'15.0': '2017'
|
||||
}
|
||||
versions = []
|
||||
for version in versions_to_check:
|
||||
@@ -395,13 +427,18 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
|
||||
|
||||
# The old method above does not work when only SDK is installed.
|
||||
keys = [r'HKLM\Software\Microsoft\VisualStudio\SxS\VC7',
|
||||
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7']
|
||||
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7',
|
||||
r'HKLM\Software\Microsoft\VisualStudio\SxS\VS7',
|
||||
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VS7']
|
||||
for index in range(len(keys)):
|
||||
path = _RegistryGetValue(keys[index], version)
|
||||
if not path:
|
||||
continue
|
||||
path = _ConvertToCygpath(path)
|
||||
if version != '14.0': # There is no Express edition for 2015.
|
||||
if version == '15.0':
|
||||
if os.path.exists(path):
|
||||
versions.append(_CreateVersion('2017', path))
|
||||
elif version != '14.0': # There is no Express edition for 2015.
|
||||
versions.append(_CreateVersion(version_to_year[version] + 'e',
|
||||
os.path.join(path, '..'), sdk_based=True))
|
||||
|
||||
@@ -420,7 +457,7 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
|
||||
if version == 'auto':
|
||||
version = os.environ.get('GYP_MSVS_VERSION', 'auto')
|
||||
version_map = {
|
||||
'auto': ('14.0', '12.0', '10.0', '9.0', '8.0', '11.0'),
|
||||
'auto': ('15.0', '14.0', '12.0', '10.0', '9.0', '8.0', '11.0'),
|
||||
'2005': ('8.0',),
|
||||
'2005e': ('8.0',),
|
||||
'2008': ('9.0',),
|
||||
@@ -432,6 +469,7 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
|
||||
'2013': ('12.0',),
|
||||
'2013e': ('12.0',),
|
||||
'2015': ('14.0',),
|
||||
'2017': ('15.0',),
|
||||
}
|
||||
override_path = os.environ.get('GYP_MSVS_OVERRIDE_PATH')
|
||||
if override_path:
|
||||
|
||||
66
third_party/gyp/generator/msvs.py
vendored
66
third_party/gyp/generator/msvs.py
vendored
@@ -294,19 +294,21 @@ def _ConfigFullName(config_name, config_data):
|
||||
return '%s|%s' % (_ConfigBaseName(config_name, platform_name), platform_name)
|
||||
|
||||
|
||||
def _ConfigWindowsTargetPlatformVersion(config_data):
|
||||
ver = config_data.get('msvs_windows_sdk_version')
|
||||
|
||||
for key in [r'HKLM\Software\Microsoft\Microsoft SDKs\Windows\%s',
|
||||
r'HKLM\Software\Wow6432Node\Microsoft\Microsoft SDKs\Windows\%s']:
|
||||
sdk_dir = MSVSVersion._RegistryGetValue(key % ver, 'InstallationFolder')
|
||||
if not sdk_dir:
|
||||
continue
|
||||
version = MSVSVersion._RegistryGetValue(key % ver, 'ProductVersion') or ''
|
||||
# Find a matching entry in sdk_dir\include.
|
||||
names = sorted([x for x in os.listdir(r'%s\include' % sdk_dir)
|
||||
if x.startswith(version)], reverse=True)
|
||||
return names[0]
|
||||
def _ConfigWindowsTargetPlatformVersion(config_data, version):
|
||||
config_ver = config_data.get('msvs_windows_sdk_version')
|
||||
vers = [config_ver] if config_ver else version.compatible_sdks
|
||||
for ver in vers:
|
||||
for key in [
|
||||
r'HKLM\Software\Microsoft\Microsoft SDKs\Windows\%s',
|
||||
r'HKLM\Software\Wow6432Node\Microsoft\Microsoft SDKs\Windows\%s']:
|
||||
sdk_dir = MSVSVersion._RegistryGetValue(key % ver, 'InstallationFolder')
|
||||
if not sdk_dir:
|
||||
continue
|
||||
version = MSVSVersion._RegistryGetValue(key % ver, 'ProductVersion') or ''
|
||||
# Find a matching entry in sdk_dir\include.
|
||||
names = sorted([x for x in os.listdir(r'%s\include' % sdk_dir)
|
||||
if x.startswith(version)], reverse=True)
|
||||
return names[0]
|
||||
|
||||
|
||||
def _BuildCommandLineForRuleRaw(spec, cmd, cygwin_shell, has_input_path,
|
||||
@@ -1715,14 +1717,17 @@ def _GetCopies(spec):
|
||||
src_bare = src[:-1]
|
||||
base_dir = posixpath.split(src_bare)[0]
|
||||
outer_dir = posixpath.split(src_bare)[1]
|
||||
cmd = 'cd "%s" && xcopy /e /f /y "%s" "%s\\%s\\"' % (
|
||||
_FixPath(base_dir), outer_dir, _FixPath(dst), outer_dir)
|
||||
fixed_dst = _FixPath(dst)
|
||||
full_dst = '"%s\\%s\\"' % (fixed_dst, outer_dir)
|
||||
cmd = 'mkdir %s 2>nul & cd "%s" && xcopy /e /f /y "%s" %s' % (
|
||||
full_dst, _FixPath(base_dir), outer_dir, full_dst)
|
||||
copies.append(([src], ['dummy_copies', dst], cmd,
|
||||
'Copying %s to %s' % (src, dst)))
|
||||
'Copying %s to %s' % (src, fixed_dst)))
|
||||
else:
|
||||
fix_dst = _FixPath(cpy['destination'])
|
||||
cmd = 'mkdir "%s" 2>nul & set ERRORLEVEL=0 & copy /Y "%s" "%s"' % (
|
||||
_FixPath(cpy['destination']), _FixPath(src), _FixPath(dst))
|
||||
copies.append(([src], [dst], cmd, 'Copying %s to %s' % (src, dst)))
|
||||
fix_dst, _FixPath(src), _FixPath(dst))
|
||||
copies.append(([src], [dst], cmd, 'Copying %s to %s' % (src, fix_dst)))
|
||||
return copies
|
||||
|
||||
|
||||
@@ -2664,7 +2669,7 @@ def _GetMSBuildProjectConfigurations(configurations):
|
||||
return [group]
|
||||
|
||||
|
||||
def _GetMSBuildGlobalProperties(spec, guid, gyp_file_name):
|
||||
def _GetMSBuildGlobalProperties(spec, version, guid, gyp_file_name):
|
||||
namespace = os.path.splitext(gyp_file_name)[0]
|
||||
properties = [
|
||||
['PropertyGroup', {'Label': 'Globals'},
|
||||
@@ -2709,15 +2714,18 @@ def _GetMSBuildGlobalProperties(spec, guid, gyp_file_name):
|
||||
for configuration in spec['configurations'].itervalues():
|
||||
platform_name = platform_name or _ConfigPlatform(configuration)
|
||||
msvs_windows_sdk_version = (msvs_windows_sdk_version or
|
||||
_ConfigWindowsTargetPlatformVersion(configuration))
|
||||
_ConfigWindowsTargetPlatformVersion(configuration, version))
|
||||
if platform_name and msvs_windows_sdk_version:
|
||||
break
|
||||
|
||||
if platform_name == 'ARM':
|
||||
properties[0].append(['WindowsSDKDesktopARMSupport', 'true'])
|
||||
if msvs_windows_sdk_version:
|
||||
properties[0].append(['WindowsTargetPlatformVersion',
|
||||
str(msvs_windows_sdk_version)])
|
||||
elif version.compatible_sdks:
|
||||
raise GypError('%s requires any SDK of %o version, but non were found' %
|
||||
(version.description, version.compatible_sdks))
|
||||
|
||||
if platform_name == 'ARM':
|
||||
properties[0].append(['WindowsSDKDesktopARMSupport', 'true'])
|
||||
|
||||
return properties
|
||||
|
||||
@@ -2862,6 +2870,9 @@ def _GetMSBuildAttributes(spec, config, build_file):
|
||||
product_name = spec.get('product_name', '$(ProjectName)')
|
||||
target_name = prefix + product_name
|
||||
msbuild_attributes['TargetName'] = target_name
|
||||
if 'TargetExt' not in msbuild_attributes and 'product_extension' in spec:
|
||||
ext = spec.get('product_extension')
|
||||
msbuild_attributes['TargetExt'] = '.' + ext
|
||||
|
||||
if spec.get('msvs_external_builder'):
|
||||
external_out_dir = spec.get('msvs_external_builder_out_dir', '.')
|
||||
@@ -2916,6 +2927,9 @@ def _GetMSBuildConfigurationGlobalProperties(spec, configurations, build_file):
|
||||
attributes['OutputDirectory'])
|
||||
_AddConditionalProperty(properties, condition, 'TargetName',
|
||||
attributes['TargetName'])
|
||||
if 'TargetExt' in attributes:
|
||||
_AddConditionalProperty(properties, condition, 'TargetExt',
|
||||
attributes['TargetExt'])
|
||||
|
||||
if attributes.get('TargetPath'):
|
||||
_AddConditionalProperty(properties, condition, 'TargetPath',
|
||||
@@ -3268,6 +3282,9 @@ def _GetMSBuildProjectReferences(project):
|
||||
['ReferenceOutputAssembly', 'false']
|
||||
]
|
||||
for config in dependency.spec.get('configurations', {}).itervalues():
|
||||
if config.get('msvs_use_library_dependency_inputs', 0):
|
||||
project_ref.append(['UseLibraryDependencyInputs', 'true'])
|
||||
break
|
||||
# If it's disabled in any config, turn it off in the reference.
|
||||
if config.get('msvs_2010_disable_uldi_when_referenced', 0):
|
||||
project_ref.append(['UseLibraryDependencyInputs', 'false'])
|
||||
@@ -3360,7 +3377,8 @@ def _GenerateMSBuildProject(project, options, version, generator_flags):
|
||||
}]
|
||||
|
||||
content += _GetMSBuildProjectConfigurations(configurations)
|
||||
content += _GetMSBuildGlobalProperties(spec, project.guid, project_file_name)
|
||||
content += _GetMSBuildGlobalProperties(spec, version, project.guid,
|
||||
project_file_name)
|
||||
content += import_default_section
|
||||
content += _GetMSBuildConfigurationDetails(spec, project.build_file)
|
||||
if spec.get('msvs_enable_winphone'):
|
||||
|
||||
21
third_party/gyp/msvs_emulation.py
vendored
21
third_party/gyp/msvs_emulation.py
vendored
@@ -30,6 +30,10 @@ def QuoteForRspFile(arg):
|
||||
# works more or less because most programs (including the compiler, etc.)
|
||||
# use that function to handle command line arguments.
|
||||
|
||||
# Use a heuristic to try to find args that are paths, and normalize them
|
||||
if arg.find('/') > 0 or arg.count('/') > 1:
|
||||
arg = os.path.normpath(arg)
|
||||
|
||||
# For a literal quote, CommandLineToArgvW requires 2n+1 backslashes
|
||||
# preceding it, and results in n backslashes + the quote. So we substitute
|
||||
# in 2* what we match, +1 more, plus the quote.
|
||||
@@ -269,7 +273,8 @@ class MsvsSettings(object):
|
||||
def AdjustLibraries(self, libraries):
|
||||
"""Strip -l from library if it's specified with that."""
|
||||
libs = [lib[2:] if lib.startswith('-l') else lib for lib in libraries]
|
||||
return [lib + '.lib' if not lib.endswith('.lib') else lib for lib in libs]
|
||||
return [lib + '.lib' if not lib.lower().endswith('.lib') else lib
|
||||
for lib in libs]
|
||||
|
||||
def _GetAndMunge(self, field, path, default, prefix, append, map):
|
||||
"""Retrieve a value from |field| at |path| or return |default|. If
|
||||
@@ -306,7 +311,10 @@ class MsvsSettings(object):
|
||||
# There's two levels of architecture/platform specification in VS. The
|
||||
# first level is globally for the configuration (this is what we consider
|
||||
# "the" config at the gyp level, which will be something like 'Debug' or
|
||||
# 'Release_x64'), and a second target-specific configuration, which is an
|
||||
# 'Release'), VS2015 and later only use this level
|
||||
if self.vs_version.short_name >= 2015:
|
||||
return config
|
||||
# and a second target-specific configuration, which is an
|
||||
# override for the global one. |config| is remapped here to take into
|
||||
# account the local target-specific overrides to the global configuration.
|
||||
arch = self.GetArch(config)
|
||||
@@ -468,8 +476,10 @@ class MsvsSettings(object):
|
||||
prefix='/arch:')
|
||||
cflags.extend(['/FI' + f for f in self._Setting(
|
||||
('VCCLCompilerTool', 'ForcedIncludeFiles'), config, default=[])])
|
||||
if self.vs_version.short_name in ('2013', '2013e', '2015'):
|
||||
# New flag required in 2013 to maintain previous PDB behavior.
|
||||
if self.vs_version.project_version >= 12.0:
|
||||
# New flag introduced in VS2013 (project version 12.0) Forces writes to
|
||||
# the program database (PDB) to be serialized through MSPDBSRV.EXE.
|
||||
# https://msdn.microsoft.com/en-us/library/dn502518.aspx
|
||||
cflags.append('/FS')
|
||||
# ninja handles parallelism by itself, don't have the compiler do it too.
|
||||
cflags = filter(lambda x: not x.startswith('/MP'), cflags)
|
||||
@@ -529,7 +539,8 @@ class MsvsSettings(object):
|
||||
"""Returns the .def file from sources, if any. Otherwise returns None."""
|
||||
spec = self.spec
|
||||
if spec['type'] in ('shared_library', 'loadable_module', 'executable'):
|
||||
def_files = [s for s in spec.get('sources', []) if s.endswith('.def')]
|
||||
def_files = [s for s in spec.get('sources', [])
|
||||
if s.lower().endswith('.def')]
|
||||
if len(def_files) == 1:
|
||||
return gyp_to_build_path(def_files[0])
|
||||
elif len(def_files) > 1:
|
||||
|
||||
Reference in New Issue
Block a user