Commit 321b27c9 authored by JGoutin's avatar JGoutin

* Continue do add support for MSVC14 (Still work in progress).

* Add support for MSVC11 and 12 (Only few changes with actual code needed for them).
* Python 2 compatibility for winreg.
parent 72db3cf5
...@@ -4,23 +4,22 @@ This module improve support for Microsoft Visual C++ compilers. (Windows Only) ...@@ -4,23 +4,22 @@ This module improve support for Microsoft Visual C++ compilers. (Windows Only)
import os import os
import itertools import itertools
import distutils.errors import distutils.errors
import winreg import six
import six.moves.winreg as winreg
try: try:
# Distutil file for MSVC++ 9.0 and upper # Distutil file for MSVC++ 9.0 and upper (Python 2.7 to 3.4)
import distutils.msvc9compiler as msvc9compiler import distutils.msvc9compiler as msvc9compiler
except ImportError: except ImportError:
pass pass
try: try:
# Distutil file for MSVC++ 14.0 and upper # Distutil file for MSVC++ 14.0 and upper (Python 3.5)
import distutils._msvccompiler as msvc14compiler import distutils._msvccompiler as msvc14compiler
except ImportError: except ImportError:
pass pass
import six
unpatched = dict() unpatched = dict()
...@@ -73,6 +72,8 @@ def msvc9_find_vcvarsall(version): ...@@ -73,6 +72,8 @@ def msvc9_find_vcvarsall(version):
compiler build for Python (VCForPython). Fall back to original behavior compiler build for Python (VCForPython). Fall back to original behavior
when the standalone compiler is not available. when the standalone compiler is not available.
Redirect the path of "vcvarsall.bat".
Known supported compilers Known supported compilers
------------------------- -------------------------
Microsoft Visual C++ 9.0: Microsoft Visual C++ 9.0:
...@@ -114,6 +115,8 @@ def msvc9_query_vcvarsall(ver, arch='x86', *args, **kwargs): ...@@ -114,6 +115,8 @@ def msvc9_query_vcvarsall(ver, arch='x86', *args, **kwargs):
Patched "distutils.msvc9compiler.query_vcvarsall" for support standalones Patched "distutils.msvc9compiler.query_vcvarsall" for support standalones
compilers. compilers.
Set environment without use of "vcvarsall.bat".
Known supported compilers Known supported compilers
------------------------- -------------------------
Microsoft Visual C++ 9.0: Microsoft Visual C++ 9.0:
...@@ -158,6 +161,8 @@ def msvc14_get_vc_env(plat_spec): ...@@ -158,6 +161,8 @@ def msvc14_get_vc_env(plat_spec):
Patched "distutils._msvccompiler._get_vc_env" for support standalones Patched "distutils._msvccompiler._get_vc_env" for support standalones
compilers. compilers.
Set environment without use of "vcvarsall.bat".
Known supported compilers Known supported compilers
------------------------- -------------------------
Microsoft Visual C++ 14.0: Microsoft Visual C++ 14.0:
...@@ -338,24 +343,31 @@ class RegistryInfo: ...@@ -338,24 +343,31 @@ class RegistryInfo:
'Microsoft', 'Microsoft',
) )
@property
def visualstudio(self):
"""
Microsoft Visual Studio root registry key.
"""
return os.path.join(self.microsoft, r'VisualStudio')
@property @property
def sxs(self): def sxs(self):
""" """
Microsoft Visual Studio SxS registry key. Microsoft Visual Studio SxS registry key.
""" """
return os.path.join(self.microsoft, r'VisualStudio\SxS') return os.path.join(self.visualstudio, 'SxS')
@property @property
def vc(self): def vc(self):
""" """
Microsoft Visual C++ registry key. Microsoft Visual C++ VC7 registry key.
""" """
return os.path.join(self.sxs, 'VC7') return os.path.join(self.sxs, 'VC7')
@property @property
def vs(self): def vs(self):
""" """
Microsoft Visual Studio registry key. Microsoft Visual Studio VS7 registry key.
""" """
return os.path.join(self.sxs, 'VS7') return os.path.join(self.sxs, 'VS7')
...@@ -496,14 +508,16 @@ class SystemInfo: ...@@ -496,14 +508,16 @@ class SystemInfo:
Microsoft Windows SDK directory. Microsoft Windows SDK directory.
""" """
sdkdir = '' sdkdir = ''
if self.vcver == 9.0: if self.vcver <= 9.0:
sdkver = ('7.0', '6.1', '6.0a') sdkver = ('7.0', '6.1', '6.0a')
elif self.vcver == 10.0: elif self.vcver == 10.0:
sdkver = ('7.1', '7.0a') sdkver = ('7.1', '7.0a')
elif self.vcver == 14.0: elif self.vcver == 11.0:
sdkver = ('10.0', '8.1', '8.1a') sdkver = ('8.0', '8.0a')
else: elif self.vcver == 12.0:
sdkver = () sdkver = ('8.1', '8.1a')
elif self.vcver >= 14.0:
sdkver = ('10.0', '8.1')
for ver in sdkver: for ver in sdkver:
# Try to get it from registry # Try to get it from registry
loc = os.path.join(self.ri.windows_sdk, 'v%s' % ver) loc = os.path.join(self.ri.windows_sdk, 'v%s' % ver)
...@@ -536,6 +550,15 @@ class SystemInfo: ...@@ -536,6 +550,15 @@ class SystemInfo:
sdkdir = os.path.join(self.VCInstallDir, 'PlatformSDK') sdkdir = os.path.join(self.VCInstallDir, 'PlatformSDK')
return sdkdir return sdkdir
@property
def FSharpInstallDir(self):
"""
Microsoft Visual F# directory.
"""
path = r'%0.1f\Setup\F#' % self.vcver
path = os.path.join(self.ri.visualstudio, path)
return self.ri.lookup(path, 'productdir') or ''
@property @property
def FrameworkDir32(self): def FrameworkDir32(self):
""" """
...@@ -585,16 +608,16 @@ class SystemInfo: ...@@ -585,16 +608,16 @@ class SystemInfo:
ver = self.ri.lookup(self.ri.vc, 'frameworkver%d' % bits) or '' ver = self.ri.lookup(self.ri.vc, 'frameworkver%d' % bits) or ''
# Set .NET versions for specified MSVC++ version # Set .NET versions for specified MSVC++ version
if self.vcver >= 14.0: if self.vcver >= 12.0:
frameworkver = (ver, 'v4.0') frameworkver = (ver, 'v4.0')
elif self.vcver == 10.0: elif self.vcver >= 10.0:
if ver.lower()[:2] != 'v4': if ver.lower()[:2] != 'v4':
ver = '' ver = ''
ver = ver or 'v4.0.30319' ver = ver or 'v4.0.30319'
frameworkver = (ver, 'v3.5') frameworkver = (ver, 'v3.5')
elif self.vcver == 9.0: elif self.vcver == 9.0:
frameworkver = ('v3.5', 'v2.0.50727') frameworkver = ('v3.5', 'v2.0.50727')
elif self.vcver == 8.0: if self.vcver == 8.0:
frameworkver = ('v3.0', 'v2.0.50727') frameworkver = ('v3.0', 'v2.0.50727')
return frameworkver return frameworkver
...@@ -606,6 +629,9 @@ class EnvironmentInfo: ...@@ -606,6 +629,9 @@ class EnvironmentInfo:
This function is compatible with Microsoft Visual C++ 9.0 to 14.0. This function is compatible with Microsoft Visual C++ 9.0 to 14.0.
Script created by analysing Microsoft environment configuration files like
"vcvars[...].bat", "SetEnv.Cmd", "vcbuildtools.bat", ...
Parameters Parameters
---------- ----------
arch: str arch: str
...@@ -669,8 +695,9 @@ class EnvironmentInfo: ...@@ -669,8 +695,9 @@ class EnvironmentInfo:
""" """
Microsoft Visual C++ store references Libraries Microsoft Visual C++ store references Libraries
""" """
path = os.path.join(self.si.VCInstallDir, r'Lib\store\references') if self.vcver < 14.0:
return [path] if self.vcver >= 14.0 else [] return []
return os.path.join(self.si.VCInstallDir, r'Lib\store\references')
@property @property
def VCTools(self): def VCTools(self):
...@@ -703,9 +730,16 @@ class EnvironmentInfo: ...@@ -703,9 +730,16 @@ class EnvironmentInfo:
""" """
Microsoft Windows SDK Include Microsoft Windows SDK Include
""" """
if self.vcver <= 10.0:
return [ return [
os.path.join(self.si.WindowsSdkDir, 'Include'), os.path.join(self.si.WindowsSdkDir, 'Include'),
os.path.join(self.si.WindowsSdkDir, r'Include\gl'), os.path.join(self.si.WindowsSdkDir, r'Include\gl')
]
elif self.vcver <= 12.0:
return [
os.path.join(self.si.WindowsSdkDir, r'include\shared'),
os.path.join(self.si.WindowsSdkDir, r'include\um'),
os.path.join(self.si.WindowsSdkDir, r'include\winrt')
] ]
@property @property
...@@ -713,15 +747,19 @@ class EnvironmentInfo: ...@@ -713,15 +747,19 @@ class EnvironmentInfo:
""" """
Microsoft Windows SDK Tools Microsoft Windows SDK Tools
""" """
if self.vcver <= 10: if self.vcver <= 11.0:
arch_subdir = self.pi.target_dir(hidex86=True, x64=True)
else:
arch_subdir = self.pi.target_dir(x64=True)
tools = [os.path.join(self.si.WindowsSdkDir, 'Bin')] tools = [os.path.join(self.si.WindowsSdkDir, 'Bin')]
if not self.pi.target_is_x86(): else:
tools = [os.path.join(self.si.WindowsSdkDir, r'Bin\x86')]
if not self.pi.current_is_x86():
arch_subdir = self.pi.current_dir(x64=True)
path = 'Bin%s' % arch_subdir path = 'Bin%s' % arch_subdir
tools += [os.path.join(self.si.WindowsSdkDir, path)] tools += [os.path.join(self.si.WindowsSdkDir, path)]
if self.vcver == 10.0: if self.vcver == 10.0 or self.vcver == 11.0:
if self.pi.target_is_x86():
arch_subdir = ''
else:
arch_subdir = self.pi.current_dir(hidex86=True, x64=True)
path = r'Bin\NETFX 4.0 Tools%s' % arch_subdir path = r'Bin\NETFX 4.0 Tools%s' % arch_subdir
tools += [os.path.join(self.si.WindowsSdkDir, path)] tools += [os.path.join(self.si.WindowsSdkDir, path)]
return tools return tools
...@@ -759,6 +797,22 @@ class EnvironmentInfo: ...@@ -759,6 +797,22 @@ class EnvironmentInfo:
] ]
return tools return tools
@property
def NetFxSDKLibraries(self):
"""
Microsoft .Net Framework SDK Libraries
"""
if self.vcver < 14.0:
return []
@property
def NetFxSDKIncludes(self):
"""
Microsoft .Net Framework SDK Includes
"""
if self.vcver < 14.0:
return []
@property @property
def VsTDb(self): def VsTDb(self):
""" """
...@@ -771,6 +825,8 @@ class EnvironmentInfo: ...@@ -771,6 +825,8 @@ class EnvironmentInfo:
""" """
Microsoft Build Engine Microsoft Build Engine
""" """
if self.vcver < 12.0:
return []
arch_subdir = self.pi.current_dir(hidex86=True) arch_subdir = self.pi.current_dir(hidex86=True)
path = r'\MSBuild\%0.1f\bin%s' % (self.vcver, arch_subdir) path = r'\MSBuild\%0.1f\bin%s' % (self.vcver, arch_subdir)
return [ return [
...@@ -783,11 +839,38 @@ class EnvironmentInfo: ...@@ -783,11 +839,38 @@ class EnvironmentInfo:
""" """
Microsoft HTML Help Workshop Microsoft HTML Help Workshop
""" """
if self.vcver < 11.0:
return []
return [ return [
os.path.join(self.si.ProgramFilesx86, 'HTML Help Workshop'), os.path.join(self.si.ProgramFilesx86, 'HTML Help Workshop'),
os.path.join(self.si.ProgramFiles, 'HTML Help Workshop') os.path.join(self.si.ProgramFiles, 'HTML Help Workshop')
] ]
@property
def UCRTLibraries(self):
"""
Microsoft Universal CRT Libraries
"""
if self.vcver < 14.0:
return []
@property
def UCRTIncludes(self):
"""
Microsoft Universal CRT Include
"""
if self.vcver < 14.0:
return []
@property
def FSharp(self):
"""
Microsoft Visual F#
"""
if self.vcver < 11.0 and self.vcver > 12.0:
return []
return self.si.FSharpInstallDir
@property @property
def VCRuntimeRedist(self): def VCRuntimeRedist(self):
""" """
...@@ -805,11 +888,15 @@ class EnvironmentInfo: ...@@ -805,11 +888,15 @@ class EnvironmentInfo:
env = dict( env = dict(
include=self._build_paths('include', include=self._build_paths('include',
[self.VCIncludes, [self.VCIncludes,
self.OSIncludes]), self.OSIncludes,
self.UCRTIncludes,
self.NetFxSDKIncludes]),
lib=self._build_paths('lib', lib=self._build_paths('lib',
[self.VCLibraries, [self.VCLibraries,
self.OSLibraries, self.OSLibraries,
self.FxTools]), self.FxTools,
self.UCRTLibraries,
self.NetFxSDKLibraries]),
libpath=self._build_paths('libpath', libpath=self._build_paths('libpath',
[self.VCLibraries, [self.VCLibraries,
self.FxTools, self.FxTools,
...@@ -822,7 +909,8 @@ class EnvironmentInfo: ...@@ -822,7 +909,8 @@ class EnvironmentInfo:
self.SdkSetup, self.SdkSetup,
self.FxTools, self.FxTools,
self.MSBuild, self.MSBuild,
self.HTMLWs]), self.HTMLWs,
self.FSharp]),
) )
if self.vcver >= 14 and os.path.isfile(self.VCRuntimeRedist): if self.vcver >= 14 and os.path.isfile(self.VCRuntimeRedist):
env['py_vcruntime_redist'] = self.VCRuntimeRedist env['py_vcruntime_redist'] = self.VCRuntimeRedist
......
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