"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "SCons/Tool/MSCommon/sdk.py" between
SCons-4.3.0.tar.gz and SCons-4.4.0.tar.gz

About: SCons is a software construction tool (a Python script and a set of modules as a superior alternative to the classic "Make" build tool).

sdk.py  (SCons-4.3.0):sdk.py  (SCons-4.4.0)
# MIT License
# #
# __COPYRIGHT__ # Copyright The SCons Foundation
# #
# Permission is hereby granted, free of charge, to any person obtaining # Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the # a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including # "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish, # without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to # distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to # permit persons to whom the Software is furnished to do so, subject to
# the following conditions: # the following conditions:
# #
# The above copyright notice and this permission notice shall be included # The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software. # in all copies or substantial portions of the Software.
# #
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """
MS Compilers: detect the Platform/Windows SDK
__doc__ = """Module to detect the Platform/Windows SDK
PSDK 2003 R1 is the earliest version detected. PSDK 2003 R1 is the earliest version detected.
""" """
import os import os
import SCons.Errors import SCons.Errors
import SCons.Util import SCons.Util
from .common import debug, read_reg from .common import debug, read_reg
skipping to change at line 75 skipping to change at line 75
def find_sdk_dir(self): def find_sdk_dir(self):
"""Try to find the MS SDK from the registry. """Try to find the MS SDK from the registry.
Return None if failed or the directory does not exist. Return None if failed or the directory does not exist.
""" """
if not SCons.Util.can_read_reg: if not SCons.Util.can_read_reg:
debug('find_sdk_dir(): can not read registry') debug('find_sdk_dir(): can not read registry')
return None return None
hkey = self.HKEY_FMT % self.hkey_data hkey = self.HKEY_FMT % self.hkey_data
debug('find_sdk_dir(): checking registry:{}'.format(hkey)) debug('find_sdk_dir(): checking registry: %s', hkey)
try: try:
sdk_dir = read_reg(hkey) sdk_dir = read_reg(hkey)
except OSError: except OSError:
debug('find_sdk_dir(): no SDK registry key {}'.format(repr(hkey))) debug('find_sdk_dir(): no SDK registry key %s', hkey)
return None return None
debug('find_sdk_dir(): Trying SDK Dir: {}'.format(sdk_dir)) debug('find_sdk_dir(): Trying SDK Dir: %s', sdk_dir)
if not os.path.exists(sdk_dir): if not os.path.exists(sdk_dir):
debug('find_sdk_dir(): {} not on file system'.format(sdk_dir)) debug('find_sdk_dir(): %s not on file system', sdk_dir)
return None return None
ftc = os.path.join(sdk_dir, self.sanity_check_file) ftc = os.path.join(sdk_dir, self.sanity_check_file)
if not os.path.exists(ftc): if not os.path.exists(ftc):
debug("find_sdk_dir(): sanity check {} not found".format(ftc)) debug("find_sdk_dir(): sanity check %s not found", ftc)
return None return None
return sdk_dir return sdk_dir
def get_sdk_dir(self): def get_sdk_dir(self):
"""Return the MSSSDK given the version string.""" """Return the MSSSDK given the version string."""
try: try:
return self._sdk_dir return self._sdk_dir
except AttributeError: except AttributeError:
sdk_dir = self.find_sdk_dir() sdk_dir = self.find_sdk_dir()
skipping to change at line 117 skipping to change at line 117
""" """
if host_arch == 'amd64' and target_arch == 'x86': if host_arch == 'amd64' and target_arch == 'x86':
# No cross tools needed compiling 32 bits on 64 bit machine # No cross tools needed compiling 32 bits on 64 bit machine
host_arch=target_arch host_arch=target_arch
arch_string=target_arch arch_string=target_arch
if host_arch != target_arch: if host_arch != target_arch:
arch_string='%s_%s'%(host_arch,target_arch) arch_string='%s_%s'%(host_arch,target_arch)
debug("get_sdk_vc_script():arch_string:%s host_arch:%s target_arch:%s"%( debug(
arch_string, "get_sdk_vc_script():arch_string:%s host_arch:%s target_arch:%s",
host_arch, arch_string,
target_arch)) host_arch,
file=self.vc_setup_scripts.get(arch_string,None) target_arch,
debug("get_sdk_vc_script():file:%s"%file) )
file = self.vc_setup_scripts.get(arch_string, None)
debug("get_sdk_vc_script():file:%s", file)
return file return file
class WindowsSDK(SDKDefinition): class WindowsSDK(SDKDefinition):
""" """
A subclass for trying to find installed Windows SDK directories. A subclass for trying to find installed Windows SDK directories.
""" """
HKEY_FMT = r'Software\Microsoft\Microsoft SDKs\Windows\v%s\InstallationFolde r' HKEY_FMT = r'Software\Microsoft\Microsoft SDKs\Windows\v%s\InstallationFolde r'
def __init__(self, *args, **kw): def __init__(self, *args, **kw):
SDKDefinition.__init__(self, *args, **kw) super().__init__(*args, **kw)
self.hkey_data = self.version self.hkey_data = self.version
class PlatformSDK(SDKDefinition): class PlatformSDK(SDKDefinition):
""" """
A subclass for trying to find installed Platform SDK directories. A subclass for trying to find installed Platform SDK directories.
""" """
HKEY_FMT = r'Software\Microsoft\MicrosoftSDK\InstalledSDKS\%s\Install Dir' HKEY_FMT = r'Software\Microsoft\MicrosoftSDK\InstalledSDKS\%s\Install Dir'
def __init__(self, *args, **kw): def __init__(self, *args, **kw):
SDKDefinition.__init__(self, *args, **kw) super().__init__(*args, **kw)
self.hkey_data = self.uuid self.hkey_data = self.uuid
# #
# The list of VC initialization scripts installed by the SDK # The list of VC initialization scripts installed by the SDK
# These should be tried if the vcvarsall.bat TARGET_ARCH fails # These should be tried if the vcvarsall.bat TARGET_ARCH fails
preSDK61VCSetupScripts = { 'x86' : r'bin\vcvars32.bat', preSDK61VCSetupScripts = { 'x86' : r'bin\vcvars32.bat',
'amd64' : r'bin\vcvarsamd64.bat', 'amd64' : r'bin\vcvarsamd64.bat',
'x86_amd64': r'bin\vcvarsx86_amd64.bat', 'x86_amd64': r'bin\vcvarsx86_amd64.bat',
'x86_ia64' : r'bin\vcvarsx86_ia64.bat', 'x86_ia64' : r'bin\vcvarsx86_ia64.bat',
'ia64' : r'bin\vcvarsia64.bat'} 'ia64' : r'bin\vcvarsia64.bat'}
skipping to change at line 288 skipping to change at line 291
InstalledSDKMap = None InstalledSDKMap = None
def get_installed_sdks(): def get_installed_sdks():
global InstalledSDKList global InstalledSDKList
global InstalledSDKMap global InstalledSDKMap
debug('get_installed_sdks()') debug('get_installed_sdks()')
if InstalledSDKList is None: if InstalledSDKList is None:
InstalledSDKList = [] InstalledSDKList = []
InstalledSDKMap = {} InstalledSDKMap = {}
for sdk in SupportedSDKList: for sdk in SupportedSDKList:
debug('trying to find SDK %s' % sdk.version) debug('trying to find SDK %s', sdk.version)
if sdk.get_sdk_dir(): if sdk.get_sdk_dir():
debug('found SDK %s' % sdk.version) debug('found SDK %s', sdk.version)
InstalledSDKList.append(sdk) InstalledSDKList.append(sdk)
InstalledSDKMap[sdk.version] = sdk InstalledSDKMap[sdk.version] = sdk
return InstalledSDKList return InstalledSDKList
# We may be asked to update multiple construction environments with # We may be asked to update multiple construction environments with
# SDK information. When doing this, we check on-disk for whether # SDK information. When doing this, we check on-disk for whether
# the SDK has 'mfc' and 'atl' subdirectories. Since going to disk # the SDK has 'mfc' and 'atl' subdirectories. Since going to disk
# is expensive, cache results by directory. # is expensive, cache results by directory.
SDKEnvironmentUpdates = {} SDKEnvironmentUpdates = {}
def set_sdk_by_directory(env, sdk_dir): def set_sdk_by_directory(env, sdk_dir):
global SDKEnvironmentUpdates global SDKEnvironmentUpdates
debug('set_sdk_by_directory: Using dir:%s'%sdk_dir) debug('set_sdk_by_directory: Using dir:%s', sdk_dir)
try: try:
env_tuple_list = SDKEnvironmentUpdates[sdk_dir] env_tuple_list = SDKEnvironmentUpdates[sdk_dir]
except KeyError: except KeyError:
env_tuple_list = [] env_tuple_list = []
SDKEnvironmentUpdates[sdk_dir] = env_tuple_list SDKEnvironmentUpdates[sdk_dir] = env_tuple_list
include_path = os.path.join(sdk_dir, 'include') include_path = os.path.join(sdk_dir, 'include')
mfc_path = os.path.join(include_path, 'mfc') mfc_path = os.path.join(include_path, 'mfc')
atl_path = os.path.join(include_path, 'atl') atl_path = os.path.join(include_path, 'atl')
skipping to change at line 348 skipping to change at line 351
return None return None
return InstalledSDKList[0] return InstalledSDKList[0]
def mssdk_setup_env(env): def mssdk_setup_env(env):
debug('mssdk_setup_env()') debug('mssdk_setup_env()')
if 'MSSDK_DIR' in env: if 'MSSDK_DIR' in env:
sdk_dir = env['MSSDK_DIR'] sdk_dir = env['MSSDK_DIR']
if sdk_dir is None: if sdk_dir is None:
return return
sdk_dir = env.subst(sdk_dir) sdk_dir = env.subst(sdk_dir)
debug('mssdk_setup_env: Using MSSDK_DIR:{}'.format(sdk_dir)) debug('mssdk_setup_env: Using MSSDK_DIR:%s', sdk_dir)
elif 'MSSDK_VERSION' in env: elif 'MSSDK_VERSION' in env:
sdk_version = env['MSSDK_VERSION'] sdk_version = env['MSSDK_VERSION']
if sdk_version is None: if sdk_version is None:
msg = "SDK version is specified as None" msg = "SDK version is specified as None"
raise SCons.Errors.UserError(msg) raise SCons.Errors.UserError(msg)
sdk_version = env.subst(sdk_version) sdk_version = env.subst(sdk_version)
mssdk = get_sdk_by_version(sdk_version) mssdk = get_sdk_by_version(sdk_version)
if mssdk is None: if mssdk is None:
msg = "SDK version %s is not installed" % sdk_version msg = "SDK version %s is not installed" % sdk_version
raise SCons.Errors.UserError(msg) raise SCons.Errors.UserError(msg)
sdk_dir = mssdk.get_sdk_dir() sdk_dir = mssdk.get_sdk_dir()
debug('mssdk_setup_env: Using MSSDK_VERSION:%s'%sdk_dir) debug('mssdk_setup_env: Using MSSDK_VERSION:%s', sdk_dir)
elif 'MSVS_VERSION' in env: elif 'MSVS_VERSION' in env:
msvs_version = env['MSVS_VERSION'] msvs_version = env['MSVS_VERSION']
debug('mssdk_setup_env:Getting MSVS_VERSION from env:%s'%msvs_version) debug('mssdk_setup_env:Getting MSVS_VERSION from env:%s', msvs_version)
if msvs_version is None: if msvs_version is None:
debug('mssdk_setup_env thinks msvs_version is None') debug('mssdk_setup_env thinks msvs_version is None')
return return
msvs_version = env.subst(msvs_version) msvs_version = env.subst(msvs_version)
from . import vs from . import vs
msvs = vs.get_vs_by_version(msvs_version) msvs = vs.get_vs_by_version(msvs_version)
debug('mssdk_setup_env:msvs is :%s'%msvs) debug('mssdk_setup_env:msvs is :%s', msvs)
if not msvs: if not msvs:
debug('mssdk_setup_env: no VS version detected, bailingout:%s'%msvs) debug('mssdk_setup_env: no VS version detected, bailingout:%s', msvs )
return return
sdk_version = msvs.sdk_version sdk_version = msvs.sdk_version
debug('msvs.sdk_version is %s'%sdk_version) debug('msvs.sdk_version is %s', sdk_version)
if not sdk_version: if not sdk_version:
return return
mssdk = get_sdk_by_version(sdk_version) mssdk = get_sdk_by_version(sdk_version)
if not mssdk: if not mssdk:
mssdk = get_default_sdk() mssdk = get_default_sdk()
if not mssdk: if not mssdk:
return return
sdk_dir = mssdk.get_sdk_dir() sdk_dir = mssdk.get_sdk_dir()
debug('mssdk_setup_env: Using MSVS_VERSION:%s'%sdk_dir) debug('mssdk_setup_env: Using MSVS_VERSION:%s', sdk_dir)
else: else:
mssdk = get_default_sdk() mssdk = get_default_sdk()
if not mssdk: if not mssdk:
return return
sdk_dir = mssdk.get_sdk_dir() sdk_dir = mssdk.get_sdk_dir()
debug('mssdk_setup_env: not using any env values. sdk_dir:%s'%sdk_dir) debug('mssdk_setup_env: not using any env values. sdk_dir:%s', sdk_dir)
set_sdk_by_directory(env, sdk_dir) set_sdk_by_directory(env, sdk_dir)
#print "No MSVS_VERSION: this is likely to be a bug" #print "No MSVS_VERSION: this is likely to be a bug"
def mssdk_exists(version=None): def mssdk_exists(version=None):
sdks = get_installed_sdks() sdks = get_installed_sdks()
if version is None: if version is None:
return len(sdks) > 0 return len(sdks) > 0
return version in sdks return version in sdks
 End of changes. 22 change blocks. 
28 lines changed or deleted 30 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)