summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/SCons/Platform/win32.py15
-rw-r--r--src/engine/SCons/Tool/mslib.py26
-rw-r--r--src/engine/SCons/Tool/mslink.py32
-rw-r--r--src/engine/SCons/Tool/msvc.py32
-rw-r--r--src/engine/SCons/Tool/msvs.py29
-rw-r--r--src/engine/SCons/Tool/msvsTests.py18
-rw-r--r--src/engine/SCons/Util.py56
7 files changed, 138 insertions, 70 deletions
diff --git a/src/engine/SCons/Platform/win32.py b/src/engine/SCons/Platform/win32.py
index 0803004..6aafa95 100644
--- a/src/engine/SCons/Platform/win32.py
+++ b/src/engine/SCons/Platform/win32.py
@@ -156,18 +156,9 @@ def spawn(sh, escape, cmd, args, env):
sys.stderr.write("scons: %s: %s\n" % (cmd, e[1]))
return ret
-# We just quote the arg here, but since the escape for a double
-# quote in the command processor (I hesitate to call it a shell :-) is
-# to double it (i.e. '""' => '"' in the command processor), we have to
-# make sure not to double any double quotes on the ends.
-def escape(x):
- first = '"'
- last = '"'
- if x and x[0] == '"':
- first = '" '
- if x and x[-1] == '"':
- last = ' "'
- return first + x + last
+# Windows does not allow special characters in file names anyway, so
+# no need for a complex escape function, we will just quote the arg.
+escape = lambda x: '"' + x + '"'
# Get the windows system directory name
def get_system_root():
diff --git a/src/engine/SCons/Tool/mslib.py b/src/engine/SCons/Tool/mslib.py
index 93a36cc..fd2484a 100644
--- a/src/engine/SCons/Tool/mslib.py
+++ b/src/engine/SCons/Tool/mslib.py
@@ -42,23 +42,31 @@ def generate(env):
env['BUILDERS']['Library'] = SCons.Defaults.StaticLibrary
env['BUILDERS']['StaticLibrary'] = SCons.Defaults.StaticLibrary
- version = SCons.Tool.msvs.get_default_visualstudio_version(env)
+ try:
+ version = SCons.Tool.msvs.get_default_visualstudio_version(env)
- if env.has_key('MSVS_IGNORE_IDE_PATHS') and env['MSVS_IGNORE_IDE_PATHS']:
- include_path, lib_path, exe_path = SCons.Tool.msvc.get_msvc_default_paths(version)
- else:
- include_path, lib_path, exe_path = SCons.Tool.msvc.get_msvc_paths(version)
+ if env.has_key('MSVS_IGNORE_IDE_PATHS') and env['MSVS_IGNORE_IDE_PATHS']:
+ include_path, lib_path, exe_path = SCons.Tool.msvc.get_msvc_default_paths(version)
+ else:
+ include_path, lib_path, exe_path = SCons.Tool.msvc.get_msvc_paths(version)
- # since other tools can set this, we just make sure that the
- # relevant stuff from MSVS is in there somewhere.
- env.PrependENVPath('PATH', exe_path)
+ # since other tools can set this, we just make sure that the
+ # relevant stuff from MSVS is in there somewhere.
+ env.PrependENVPath('PATH', exe_path)
+ except (SCons.Util.RegError, SCons.Errors.InternalError):
+ pass
env['AR'] = 'lib'
env['ARFLAGS'] = '/nologo'
env['ARCOM'] = "${TEMPFILE('$AR $ARFLAGS /OUT:$TARGET $SOURCES')}"
def exists(env):
- if not SCons.Util.can_read_reg or not SCons.Tool.msvs.get_visualstudio_versions():
+ try:
+ v = SCons.Tool.msvs.get_visualstudio_versions()
+ except (SCons.Util.RegError, SCons.Errors.InternalError):
+ pass
+
+ if not v:
return env.Detect('lib')
else:
# there's at least one version of MSVS installed.
diff --git a/src/engine/SCons/Tool/mslink.py b/src/engine/SCons/Tool/mslink.py
index 5a8a729..9881286 100644
--- a/src/engine/SCons/Tool/mslink.py
+++ b/src/engine/SCons/Tool/mslink.py
@@ -163,21 +163,29 @@ def generate(env):
env['REGSVRFLAGS'] = '/s '
env['REGSVRCOM'] = '$REGSVR $REGSVRFLAGS $TARGET'
- version = SCons.Tool.msvs.get_default_visualstudio_version(env)
-
- if env.has_key('MSVS_IGNORE_IDE_PATHS') and env['MSVS_IGNORE_IDE_PATHS']:
- include_path, lib_path, exe_path = SCons.Tool.msvc.get_msvc_default_paths(version)
- else:
- include_path, lib_path, exe_path = SCons.Tool.msvc.get_msvc_paths(version)
+ try:
+ version = SCons.Tool.msvs.get_default_visualstudio_version(env)
- # since other tools can set these, we just make sure that the
- # relevant stuff from MSVS is in there somewhere.
- env.PrependENVPath('INCLUDE', include_path)
- env.PrependENVPath('LIB', lib_path)
- env.PrependENVPath('PATH', exe_path)
+ if env.has_key('MSVS_IGNORE_IDE_PATHS') and env['MSVS_IGNORE_IDE_PATHS']:
+ include_path, lib_path, exe_path = SCons.Tool.msvc.get_msvc_default_paths(version)
+ else:
+ include_path, lib_path, exe_path = SCons.Tool.msvc.get_msvc_paths(version)
+
+ # since other tools can set these, we just make sure that the
+ # relevant stuff from MSVS is in there somewhere.
+ env.PrependENVPath('INCLUDE', include_path)
+ env.PrependENVPath('LIB', lib_path)
+ env.PrependENVPath('PATH', exe_path)
+ except (SCons.Util.RegError, SCons.Errors.InternalError):
+ pass
def exists(env):
- if not SCons.Util.can_read_reg or not SCons.Tool.msvs.get_visualstudio_versions():
+ try:
+ v = SCons.Tool.msvs.get_visualstudio_versions()
+ except (SCons.Util.RegError, SCons.Errors.InternalError):
+ pass
+
+ if not v:
return env.Detect('link')
else:
# there's at least one version of MSVS installed.
diff --git a/src/engine/SCons/Tool/msvc.py b/src/engine/SCons/Tool/msvc.py
index f936535..94d0c3e 100644
--- a/src/engine/SCons/Tool/msvc.py
+++ b/src/engine/SCons/Tool/msvc.py
@@ -203,7 +203,7 @@ def _get_msvc6_default_paths(version):
try:
paths = SCons.Tool.msvs.get_msvs_install_dirs(version)
MVSdir = paths['VSINSTALLDIR']
- except (SCons.Util.RegError, SCons.Errors.InternalError):
+ except (SCons.Util.RegError, SCons.Errors.InternalError, KeyError):
if os.environ.has_key('MSDEVDIR'):
MVSdir = os.path.normpath(os.path.join(os.environ['MSDEVDIR'],'..','..'))
else:
@@ -400,18 +400,21 @@ def generate(env):
CScan.add_skey('.rc')
env['BUILDERS']['RES'] = res_builder
- version = SCons.Tool.msvs.get_default_visualstudio_version(env)
+ try:
+ version = SCons.Tool.msvs.get_default_visualstudio_version(env)
- if env.has_key('MSVS_IGNORE_IDE_PATHS') and env['MSVS_IGNORE_IDE_PATHS']:
- include_path, lib_path, exe_path = get_msvc_default_paths(version)
- else:
- include_path, lib_path, exe_path = get_msvc_paths(version)
+ if env.has_key('MSVS_IGNORE_IDE_PATHS') and env['MSVS_IGNORE_IDE_PATHS']:
+ include_path, lib_path, exe_path = get_msvc_default_paths(version)
+ else:
+ include_path, lib_path, exe_path = get_msvc_paths(version)
- # since other tools can set these, we just make sure that the
- # relevant stuff from MSVS is in there somewhere.
- env.PrependENVPath('INCLUDE', include_path)
- env.PrependENVPath('LIB', lib_path)
- env.PrependENVPath('PATH', exe_path)
+ # since other tools can set these, we just make sure that the
+ # relevant stuff from MSVS is in there somewhere.
+ env.PrependENVPath('INCLUDE', include_path)
+ env.PrependENVPath('LIB', lib_path)
+ env.PrependENVPath('PATH', exe_path)
+ except (SCons.Util.RegError, SCons.Errors.InternalError):
+ pass
env['CFILESUFFIX'] = '.c'
env['CXXFILESUFFIX'] = '.cc'
@@ -420,7 +423,12 @@ def generate(env):
env['BUILDERS']['PCH'] = pch_builder
def exists(env):
- if not SCons.Util.can_read_reg or not SCons.Tool.msvs.get_visualstudio_versions():
+ try:
+ v = SCons.Tool.msvs.get_visualstudio_versions()
+ except (SCons.Util.RegError, SCons.Errors.InternalError):
+ pass
+
+ if not v:
return env.Detect('cl')
else:
# there's at least one version of MSVS installed.
diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py
index 9b8eb41..1a9a7bb 100644
--- a/src/engine/SCons/Tool/msvs.py
+++ b/src/engine/SCons/Tool/msvs.py
@@ -701,7 +701,8 @@ def get_default_visualstudio_version(env):
else:
if SCons.Util.can_read_reg:
versions = get_visualstudio_versions()
- version = versions[0] #use highest version by default
+ if versions:
+ version = versions[0] #use highest version by default
env['MSVS_VERSION'] = version
env['MSVS']['VERSIONS'] = versions
@@ -719,7 +720,7 @@ def get_visualstudio_versions():
"""
if not SCons.Util.can_read_reg:
- raise SCons.Errors.InternalError, "No Windows registry module was found"
+ return []
HLM = SCons.Util.HKEY_LOCAL_MACHINE
K = r'Software\Microsoft\VisualStudio'
@@ -774,7 +775,7 @@ def get_visualstudio_versions():
pass
if not L:
- raise SCons.Errors.InternalError, "Microsoft Visual Studio was not found."
+ return []
L.sort()
L.reverse()
@@ -788,10 +789,14 @@ def get_msvs_install_dirs(version = None):
"""
if not SCons.Util.can_read_reg:
- raise SCons.Errors.InternalError, "No Windows registry module was found"
+ return {}
if not version:
- version = get_visualstudio_versions()[0] #use highest version by default
+ versions = get_visualstudio_versions()
+ if versions:
+ version = versions[0] #use highest version by default
+ else:
+ return {}
K = 'Software\\Microsoft\\VisualStudio\\' + version
@@ -996,12 +1001,11 @@ def generate(env):
except KeyError:
env['BUILDERS']['MSVSProject'] = projectBuilder
- env['MSVSPROJECTCOM'] = projectGeneratorAction
-
- version = get_default_visualstudio_version(env)
+ env['MSVSPROJECTCOM'] = projectGeneratorAction
- # keep a record of some of the MSVS info so the user can use it.
try:
+ version = get_default_visualstudio_version(env)
+ # keep a record of some of the MSVS info so the user can use it.
dirs = get_msvs_install_dirs(version)
env['MSVS'].update(dirs)
except (SCons.Util.RegError, SCons.Errors.InternalError):
@@ -1019,7 +1023,12 @@ def generate(env):
env['MSVSSOLUTIONSUFFIX'] = '.sln'
def exists(env):
- if not SCons.Util.can_read_reg or not get_visualstudio_versions():
+ try:
+ v = SCons.Tool.msvs.get_visualstudio_versions()
+ except (SCons.Util.RegError, SCons.Errors.InternalError):
+ pass
+
+ if not v:
if env.has_key('MSVS_VERSION') and float(env['MSVS_VERSION']) >= 7.0:
return env.Detect('devenv')
else:
diff --git a/src/engine/SCons/Tool/msvsTests.py b/src/engine/SCons/Tool/msvsTests.py
index 731cc2d..bd22177 100644
--- a/src/engine/SCons/Tool/msvsTests.py
+++ b/src/engine/SCons/Tool/msvsTests.py
@@ -228,6 +228,7 @@ regdata_67 = string.split(r'''
"MediaPath"="C:\WINDOWS\Media"
''','\n')
+regdata_none = []
class DummyEnv:
def __init__(self, dict=None):
@@ -411,7 +412,7 @@ class msvsTestCase(unittest.TestCase):
def test_get_visual_studio_versions(self):
"""Test retrieval of the list of visual studio versions"""
v1 = get_visualstudio_versions()
- assert v1[0] == highest_version
+ assert not v1 or v1[0] == highest_version
assert len(v1) == number_of_versions
def test_get_msvs_install_dirs(self):
@@ -441,6 +442,7 @@ if __name__ == "__main__":
number_of_versions = 1
install_location1 = {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio', 'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio\\VC98'}
install_location2 = {}
+ print "Test MSVS 6 Registry"
# print str(registry.root)
if not unittest.TextTestRunner().run(suite).wasSuccessful():
sys.exit(1)
@@ -451,6 +453,7 @@ if __name__ == "__main__":
number_of_versions = 1
install_location1 = {'VSINSTALLDIR': 'C:\\VS6', 'VCINSTALLDIR': 'C:\\VS6\\VC98'}
install_location2 = {}
+ print "Test Other MSVS 6 Registry"
# print str(registry.root)
if not unittest.TextTestRunner().run(suite).wasSuccessful():
sys.exit(1)
@@ -462,6 +465,7 @@ if __name__ == "__main__":
install_location1 = {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET\\', 'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET\\Vc7\\'}
install_location2 = {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET\\', 'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET\\Vc7\\'}
# print str(registry.root)
+ print "Test MSVS 6 & 7 Registry"
if not unittest.TextTestRunner().run(suite).wasSuccessful():
sys.exit(1)
@@ -472,5 +476,17 @@ if __name__ == "__main__":
install_location1 = {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET\\', 'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET\\Vc7\\'}
install_location2 = {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET\\', 'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET\\Vc7\\'}
# print str(registry.root)
+ print "Test MSVS 7 Registry"
+ if not unittest.TextTestRunner().run(suite).wasSuccessful():
+ sys.exit(1)
+
+ registry = DummyRegistry(regdata_none)
+ default_version = '6.0'
+ highest_version = None
+ number_of_versions = 0
+ install_location1 = {}
+ install_location2 = {}
+ # print str(registry.root)
+ print "Test Empty Registry"
if not unittest.TextTestRunner().run(suite).wasSuccessful():
sys.exit(1)
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py
index 06a3dac..2a96d25 100644
--- a/src/engine/SCons/Util.py
+++ b/src/engine/SCons/Util.py
@@ -738,8 +738,24 @@ if can_read_reg:
HKEY_USERS = hkey_mod.HKEY_USERS
def RegGetValue(root, key):
- """Returns a value in the registry without
- having to open the key first."""
+ """This utility function returns a value in the registry
+ without having to open the key first. Only available on
+ Windows platforms with a version of Python that can read the
+ registry. Returns the same thing as
+ SCons.Util.RegQueryValueEx, except you just specify the entire
+ path to the value, and don't have to bother opening the key
+ first. So:
+
+ Instead of:
+ k = SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE,
+ r'SOFTWARE\Microsoft\Windows\CurrentVersion')
+ out = SCons.Util.RegQueryValueEx(k,
+ 'ProgramFilesDir')
+
+ You can write:
+ out = SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE,
+ r'SOFTWARE\Microsoft\Windows\CurrentVersion\ProgramFilesDir')
+ """
# I would use os.path.split here, but it's not a filesystem
# path...
p = key.rfind('\\') + 1
@@ -814,12 +830,18 @@ else:
return None
def PrependPath(oldpath, newpath, sep = os.pathsep):
- """Prepend newpath elements to the given oldpath. Will only add
- any particular path once (leaving the first one it encounters and
- ignoring the rest, to preserve path order), and will normpath and
- normcase all paths to help assure this. This can also handle the
- case where the given oldpath variable is a list instead of a
- string, in which case a list will be returned instead of a string.
+ """This prepends newpath elements to the given oldpath. Will only
+ add any particular path once (leaving the first one it encounters
+ and ignoring the rest, to preserve path order), and will
+ os.path.normpath and os.path.normcase all paths to help assure
+ this. This can also handle the case where the given old path
+ variable is a list instead of a string, in which case a list will
+ be returned instead of a string.
+
+ Example:
+ Old Path: "/foo/bar:/foo"
+ New Path: "/biz/boom:/foo"
+ Result: "/biz/boom:/foo:/foo/bar"
"""
orig = oldpath
@@ -851,12 +873,18 @@ def PrependPath(oldpath, newpath, sep = os.pathsep):
return string.join(paths, sep)
def AppendPath(oldpath, newpath, sep = os.pathsep):
- """Append newpath elements to the given oldpath. Will only add
- any particular path once (leaving the first one it encounters and
- ignoring the rest, to preserve path order), and will normpath and
- normcase all paths to help assure this. This can also handle the
- case where the given oldpath variable is a list instead of a
- string, in which case a list will be returned instead of a string.
+ """This appends new path elements to the given old path. Will
+ only add any particular path once (leaving the last one it
+ encounters and ignoring the rest, to preserve path order), and
+ will os.path.normpath and os.path.normcase all paths to help
+ assure this. This can also handle the case where the given old
+ path variable is a list instead of a string, in which case a list
+ will be returned instead of a string.
+
+ Example:
+ Old Path: "/foo/bar:/foo"
+ New Path: "/biz/boom:/foo"
+ Result: "/foo/bar:/biz/boom:/foo"
"""
orig = oldpath