From 70545358cf838a2142ec39c925bcde00ebff72f6 Mon Sep 17 00:00:00 2001 From: hhsprings Date: Fri, 13 Mar 2015 23:02:05 +0900 Subject: =?UTF-8?q?This=20patch=20is=20not=20for=20Python=202.7,=20but=20f?= =?UTF-8?q?or=20`Microsoft=20Visual=20C++=20Compiler=20for=20Python=202.7'?= =?UTF-8?q?.=20Althouh=20maintainers=20claims=20`This=20will=20be=20the=20?= =?UTF-8?q?last=20release=20to=20support=20Python=20versions=20earlier=20t?= =?UTF-8?q?han=202.7,=20as=20we=20begin=20to=20move=20toward=20supporting?= =?UTF-8?q?=20Python=203.`,=20that=E2=80=99s=20not=20the=20same=20as=20sup?= =?UTF-8?q?porting=20compiler.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/engine/SCons/Tool/MSCommon/common.py | 4 +- src/engine/SCons/Tool/MSCommon/vc.py | 84 ++++++++++++++++++++------------ 2 files changed, 55 insertions(+), 33 deletions(-) diff --git a/src/engine/SCons/Tool/MSCommon/common.py b/src/engine/SCons/Tool/MSCommon/common.py index ccfe739..9549a66 100644 --- a/src/engine/SCons/Tool/MSCommon/common.py +++ b/src/engine/SCons/Tool/MSCommon/common.py @@ -84,8 +84,8 @@ def is_win64(): return _is_win64 -def read_reg(value): - return SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE, value)[0] +def read_reg(value, hkroot=SCons.Util.HKEY_LOCAL_MACHINE): + return SCons.Util.RegGetValue(hkroot, value)[0] def has_reg(value): """Return True if the given key exists in HKEY_LOCAL_MACHINE, False diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py index 97cb349..71117cd 100644 --- a/src/engine/SCons/Tool/MSCommon/vc.py +++ b/src/engine/SCons/Tool/MSCommon/vc.py @@ -35,6 +35,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" __doc__ = """Module for Visual C/C++ detection and configuration. """ import SCons.compat +import SCons.Util import os import platform @@ -137,32 +138,46 @@ def get_host_target(env): _VCVER = ["12.0", "12.0Exp", "11.0", "11.0Exp", "10.0", "10.0Exp", "9.0", "9.0Exp","8.0", "8.0Exp","7.1", "7.0", "6.0"] _VCVER_TO_PRODUCT_DIR = { - '12.0' : [ - r'Microsoft\VisualStudio\12.0\Setup\VC\ProductDir'], - '12.0Exp' : [ - r'Microsoft\VCExpress\12.0\Setup\VC\ProductDir'], - '11.0': [ - r'Microsoft\VisualStudio\11.0\Setup\VC\ProductDir'], - '11.0Exp' : [ - r'Microsoft\VCExpress\11.0\Setup\VC\ProductDir'], - '10.0': [ - r'Microsoft\VisualStudio\10.0\Setup\VC\ProductDir'], - '10.0Exp' : [ - r'Microsoft\VCExpress\10.0\Setup\VC\ProductDir'], - '9.0': [ - r'Microsoft\VisualStudio\9.0\Setup\VC\ProductDir'], - '9.0Exp' : [ - r'Microsoft\VCExpress\9.0\Setup\VC\ProductDir'], - '8.0': [ - r'Microsoft\VisualStudio\8.0\Setup\VC\ProductDir'], - '8.0Exp': [ - r'Microsoft\VCExpress\8.0\Setup\VC\ProductDir'], - '7.1': [ - r'Microsoft\VisualStudio\7.1\Setup\VC\ProductDir'], - '7.0': [ - r'Microsoft\VisualStudio\7.0\Setup\VC\ProductDir'], - '6.0': [ - r'Microsoft\VisualStudio\6.0\Setup\Microsoft Visual C++\ProductDir'] + '12.0' : [ + (SCons.Util.HKEY_LOCAL_MACHINE, r'Microsoft\VisualStudio\12.0\Setup\VC\ProductDir'), + ], + '12.0Exp' : [ + (SCons.Util.HKEY_LOCAL_MACHINE, r'Microsoft\VCExpress\12.0\Setup\VC\ProductDir'), + ], + '11.0': [ + (SCons.Util.HKEY_LOCAL_MACHINE, r'Microsoft\VisualStudio\11.0\Setup\VC\ProductDir'), + ], + '11.0Exp' : [ + (SCons.Util.HKEY_LOCAL_MACHINE, r'Microsoft\VCExpress\11.0\Setup\VC\ProductDir'), + ], + '10.0': [ + (SCons.Util.HKEY_LOCAL_MACHINE, r'Microsoft\VisualStudio\10.0\Setup\VC\ProductDir'), + ], + '10.0Exp' : [ + (SCons.Util.HKEY_LOCAL_MACHINE, r'Microsoft\VCExpress\10.0\Setup\VC\ProductDir'), + ], + '9.0': [ + (SCons.Util.HKEY_CURRENT_USER, r'Microsoft\DevDiv\VCForPython\9.0\installdir',), + (SCons.Util.HKEY_LOCAL_MACHINE, r'Microsoft\VisualStudio\9.0\Setup\VC\ProductDir',), + ], + '9.0Exp' : [ + (SCons.Util.HKEY_LOCAL_MACHINE, r'Microsoft\VCExpress\9.0\Setup\VC\ProductDir'), + ], + '8.0': [ + (SCons.Util.HKEY_LOCAL_MACHINE, r'Microsoft\VisualStudio\8.0\Setup\VC\ProductDir'), + ], + '8.0Exp': [ + (SCons.Util.HKEY_LOCAL_MACHINE, r'Microsoft\VCExpress\8.0\Setup\VC\ProductDir'), + ], + '7.1': [ + (SCons.Util.HKEY_LOCAL_MACHINE, r'Microsoft\VisualStudio\7.1\Setup\VC\ProductDir'), + ], + '7.0': [ + (SCons.Util.HKEY_LOCAL_MACHINE, r'Microsoft\VisualStudio\7.0\Setup\VC\ProductDir'), + ], + '6.0': [ + (SCons.Util.HKEY_LOCAL_MACHINE, r'Microsoft\VisualStudio\6.0\Setup\Microsoft Visual C++\ProductDir'), + ] } def msvc_version_to_maj_min(msvc_version): @@ -212,18 +227,25 @@ def find_vc_pdir(msvc_version): If for some reason the requested version could not be found, an exception which inherits from VisualCException will be raised.""" root = 'Software\\' - if common.is_win64(): - root = root + 'Wow6432Node\\' try: hkeys = _VCVER_TO_PRODUCT_DIR[msvc_version] except KeyError: debug("Unknown version of MSVC: %s" % msvc_version) raise UnsupportedVersion("Unknown version %s" % msvc_version) - for key in hkeys: - key = root + key + for hkroot, key in hkeys: try: - comps = common.read_reg(key) + comps = None + if common.is_win64(): + try: + # ordinally at win64, try Wow6432Node first. + comps = common.read_reg(root + 'Wow6432Node\\' + key, hkroot) + except WindowsError, e: + # at Microsoft Visual Studio for Python 2.7, value is not in Wow6432Node + pass + if not comps: + # not Win64, or Microsoft Visual Studio for Python 2.7 + comps = common.read_reg(root + key, hkroot) except WindowsError, e: debug('find_vc_dir(): no VC registry key %s' % repr(key)) else: -- cgit v0.12