-# The list of supported Visual C/C++ versions we know how to detect.
-#
-# The first VC found in the list is the one used by default if there
-# are multiple VC installed. Barring good reasons to the contrary,
-# this means we should list VC with from most recent to oldest.
-#
-# If you update this list, update the documentation in Tool/vc.xml.
-SupportedVCList = [
- VisualC('9.0',
- hkeys=[
- r'Microsoft\VisualStudio\9.0\Setup\VC\ProductDir',
- r'Microsoft\VCExpress\9.0\Setup\VC\ProductDir',
- ],
- default_install=r'Microsoft Visual Studio 9.0\VC',
- common_tools_var='VS90COMNTOOLS',
- vc_subdir=r'\VC',
- batch_file_base='vcvars',
- supported_arch=['x86', 'x86_64', 'ia64'],
- atlmc_include_subdir = [r'ATLMFC\INCLUDE'],
- atlmfc_lib_subdir = {
- 'x86' : r'ATLMFC\LIB',
- 'x86_64' : r'ATLMFC\LIB\amd64',
- 'ia64' : r'ATLMFC\LIB\ia64',
- },
- crt_lib_subdir = {
- 'x86_64' : r'LIB\amd64',
- 'ia64' : r'LIB\ia64',
- },
- ),
- VisualC('8.0',
- hkeys=[
- r'Microsoft\VisualStudio\8.0\Setup\VC\ProductDir',
- r'Microsoft\VCExpress\8.0\Setup\VC\ProductDir',
- ],
- default_install=r'%s\Microsoft Visual Studio 8\VC',
- common_tools_var='VS80COMNTOOLS',
- vc_subdir=r'\VC',
- batch_file_base='vcvars',
- supported_arch=['x86', 'x86_64', 'ia64'],
- atlmc_include_subdir = [r'ATLMFC\INCLUDE'],
- atlmfc_lib_subdir = {
- 'x86' : r'ATLMFC\LIB',
- 'x86_64' : r'ATLMFC\LIB\amd64',
- 'ia64' : r'ATLMFC\LIB\ia64',
- },
- crt_lib_subdir = {
- 'x86_64' : r'LIB\amd64',
- 'ia64' : r'LIB\ia64',
- },
- ),
- VisualC('7.1',
- hkeys=[
- r'Microsoft\VisualStudio\7.1\Setup\VC\ProductDir',
- ],
- default_install=r'%s\Microsoft Visual Studio 7.1.NET 2003\VC7',
- common_tools_var='VS71COMNTOOLS',
- vc_subdir=r'\VC7',
- batch_file_base='vcvars',
- supported_arch=['x86'],
- atlmc_include_subdir = [r'ATLMFC\INCLUDE'],
- atlmfc_lib_subdir = {
- 'x86' : r'ATLMFC\LIB',
- },
- ),
- VisualC('7.0',
- hkeys=[
- r'Microsoft\VisualStudio\7.0\Setup\VC\ProductDir',
- ],
- default_install=r'%s\Microsoft Visual Studio .NET\VC7',
- common_tools_var='VS70COMNTOOLS',
- vc_subdir=r'\VC7',
- batch_file_base='vcvars',
- supported_arch=['x86'],
- atlmc_include_subdir = [r'ATLMFC\INCLUDE'],
- atlmfc_lib_subdir = {
- 'x86' : r'ATLMFC\LIB',
- },
- ),
- VisualC('6.0',
- hkeys=[
- r'Microsoft\VisualStudio\6.0\Setup\Microsoft Visual C++\ProductDir',
- ],
- default_install=r'%s\Microsoft Visual Studio\VC98',
- common_tools_var='VS60COMNTOOLS',
- vc_subdir=r'\VC98',
- batch_file_base='vcvars',
- supported_arch=['x86'],
- atlmc_include_subdir = [r'ATL\INCLUDE', r'MFC\INCLUDE'],
- atlmfc_lib_subdir = {
- 'x86' : r'MFC\LIB',
- },
- ),
-]
-
-SupportedVCMap = {}
-for vc in SupportedVCList:
- SupportedVCMap[vc.version] = vc
-
-
-# Finding installed versions of Visual C/C++ isn't cheap, because it goes
-# not only to the registry but also to the disk to sanity-check that there
-# is, in fact, something installed there and that the registry entry isn't
-# just stale. Find this information once, when requested, and cache it.
-
-InstalledVCList = None
-InstalledVCMap = None
+ # filter out e.g. "Exp" from the version name
+ msvc_ver_numeric = ''.join([x for x in msvc_version if x in string_digits + "."])
+ vernum = float(msvc_ver_numeric)
+ if 7 <= vernum < 8:
+ pdir = os.path.join(pdir, os.pardir, "Common7", "Tools")
+ batfilename = os.path.join(pdir, "vsvars32.bat")
+ elif vernum < 7:
+ pdir = os.path.join(pdir, "Bin")
+ batfilename = os.path.join(pdir, "vcvars32.bat")
+ else: # >= 8
+ batfilename = os.path.join(pdir, "vcvarsall.bat")
+
+ if not os.path.exists(batfilename):
+ debug("Not found: %s" % batfilename)
+ batfilename = None
+
+ installed_sdks=get_installed_sdks()
+ (host_arch,target_arch)=get_host_target(env)
+ for _sdk in installed_sdks:
+ sdk_bat_file=_sdk.get_sdk_vc_script(host_arch,target_arch)
+ sdk_bat_file_path=os.path.join(pdir,sdk_bat_file)
+ debug('vc.py:find_batch_file() sdk_bat_file_path:%s'%sdk_bat_file_path)
+ if os.path.exists(sdk_bat_file_path):
+ return (batfilename,sdk_bat_file_path)
+ else:
+ debug("vc.py:find_batch_file() not found:%s"%sdk_bat_file_path)
+ else:
+ return (batfilename,None)
+
+__INSTALLED_VCS_RUN = None
+
+def cached_get_installed_vcs():
+ global __INSTALLED_VCS_RUN
+
+ if __INSTALLED_VCS_RUN is None:
+ ret = get_installed_vcs()
+ __INSTALLED_VCS_RUN = ret
+
+ return __INSTALLED_VCS_RUN