summaryrefslogtreecommitdiff
path: root/engine/SCons/Tool/msvs.py
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2015-06-21 07:06:09 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2015-06-21 07:06:09 +0200
commit71c19b5c2d38022afb2a5767a3f8da11d0f06444 (patch)
tree1f2a79dfe0ebe98c6b95d5a0a4f5615d9e4afaab /engine/SCons/Tool/msvs.py
parent3f6052c28746cf9f29443a610ab60f5b02d3b658 (diff)
parentb0f56d74df2a6904ddceb963833d4ea357251853 (diff)
Merge tag 'upstream/2.3.5'
Upstream version 2.3.5
Diffstat (limited to 'engine/SCons/Tool/msvs.py')
-rw-r--r--engine/SCons/Tool/msvs.py244
1 files changed, 234 insertions, 10 deletions
diff --git a/engine/SCons/Tool/msvs.py b/engine/SCons/Tool/msvs.py
index ce4d834..c32254a 100644
--- a/engine/SCons/Tool/msvs.py
+++ b/engine/SCons/Tool/msvs.py
@@ -9,7 +9,7 @@ selection method.
"""
#
-# Copyright (c) 2001 - 2014 The SCons Foundation
+# Copyright (c) 2001 - 2015 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -30,7 +30,7 @@ selection method.
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Tool/msvs.py 2014/09/27 12:51:43 garyo"
+__revision__ = "src/engine/SCons/Tool/msvs.py pchdll:3325:cd517fae59a4 2015/06/18 06:53:27 bdbaddog"
import SCons.compat
@@ -63,6 +63,7 @@ def xmlify(s):
s = s.replace("&", "&amp;") # do this first
s = s.replace("'", "&apos;")
s = s.replace('"', "&quot;")
+ s = s.replace('\n', '&#x0A;')
return s
# Process a CPPPATH list in includes, given the env, target and source.
@@ -198,6 +199,209 @@ def makeHierarchy(sources):
# print 'Warning: failed to decompose path for '+str(file)
return hierarchy
+class _UserGenerator(object):
+ '''
+ Base class for .dsp.user file generator
+ '''
+ # Default instance values.
+ # Ok ... a bit defensive, but it does not seems reasonable to crash the
+ # build for a workspace user file. :-)
+ usrhead = None
+ usrdebg = None
+ usrconf = None
+ createfile = False
+ def __init__(self, dspfile, source, env):
+ # DebugSettings should be a list of debug dictionary sorted in the same order
+ # than the target list and variants
+ if 'variant' not in env:
+ raise SCons.Errors.InternalError("You must specify a 'variant' argument (i.e. 'Debug' or " +\
+ "'Release') to create an MSVSProject.")
+ elif SCons.Util.is_String(env['variant']):
+ variants = [env['variant']]
+ elif SCons.Util.is_List(env['variant']):
+ variants = env['variant']
+
+ if 'DebugSettings' not in env or env['DebugSettings'] == None:
+ dbg_settings = []
+ elif SCons.Util.is_Dict(env['DebugSettings']):
+ dbg_settings = [env['DebugSettings']]
+ elif SCons.Util.is_List(env['DebugSettings']):
+ if len(env['DebugSettings']) != len(variants):
+ raise SCons.Errors.InternalError("Sizes of 'DebugSettings' and 'variant' lists must be the same.")
+ dbg_settings = []
+ for ds in env['DebugSettings']:
+ if SCons.Util.is_Dict(ds):
+ dbg_settings.append(ds)
+ else:
+ dbg_settings.append({})
+ else:
+ dbg_settings = []
+
+ if len(dbg_settings) == 1:
+ dbg_settings = dbg_settings * len(variants)
+
+ self.createfile = self.usrhead and self.usrdebg and self.usrconf and \
+ dbg_settings and bool([ds for ds in dbg_settings if ds])
+
+ if self.createfile:
+ dbg_settings = dict(zip(variants, dbg_settings))
+ for var, src in dbg_settings.items():
+ # Update only expected keys
+ trg = {}
+ for key in [k for k in self.usrdebg.keys() if k in src]:
+ trg[key] = str(src[key])
+ self.configs[var].debug = trg
+
+ def UserHeader(self):
+ encoding = self.env.subst('$MSVSENCODING')
+ versionstr = self.versionstr
+ self.usrfile.write(self.usrhead % locals())
+
+ def UserProject(self):
+ pass
+
+ def Build(self):
+ if not self.createfile:
+ return
+ try:
+ filename = self.dspabs +'.user'
+ self.usrfile = open(filename, 'w')
+ except IOError, detail:
+ raise SCons.Errors.InternalError('Unable to open "' + filename + '" for writing:' + str(detail))
+ else:
+ self.UserHeader()
+ self.UserProject()
+ self.usrfile.close()
+
+V9UserHeader = """\
+<?xml version="1.0" encoding="%(encoding)s"?>
+<VisualStudioUserFile
+\tProjectType="Visual C++"
+\tVersion="%(versionstr)s"
+\tShowAllFiles="false"
+\t>
+\t<Configurations>
+"""
+
+V9UserConfiguration = """\
+\t\t<Configuration
+\t\t\tName="%(variant)s|%(platform)s"
+\t\t\t>
+\t\t\t<DebugSettings
+%(debug_settings)s
+\t\t\t/>
+\t\t</Configuration>
+"""
+
+V9DebugSettings = {
+'Command':'$(TargetPath)',
+'WorkingDirectory': None,
+'CommandArguments': None,
+'Attach':'false',
+'DebuggerType':'3',
+'Remote':'1',
+'RemoteMachine': None,
+'RemoteCommand': None,
+'HttpUrl': None,
+'PDBPath': None,
+'SQLDebugging': None,
+'Environment': None,
+'EnvironmentMerge':'true',
+'DebuggerFlavor': None,
+'MPIRunCommand': None,
+'MPIRunArguments': None,
+'MPIRunWorkingDirectory': None,
+'ApplicationCommand': None,
+'ApplicationArguments': None,
+'ShimCommand': None,
+'MPIAcceptMode': None,
+'MPIAcceptFilter': None,
+}
+
+class _GenerateV7User(_UserGenerator):
+ """Generates a Project file for MSVS .NET"""
+ def __init__(self, dspfile, source, env):
+ if self.version_num >= 9.0:
+ self.usrhead = V9UserHeader
+ self.usrconf = V9UserConfiguration
+ self.usrdebg = V9DebugSettings
+ _UserGenerator.__init__(self, dspfile, source, env)
+
+ def UserProject(self):
+ confkeys = sorted(self.configs.keys())
+ for kind in confkeys:
+ variant = self.configs[kind].variant
+ platform = self.configs[kind].platform
+ debug = self.configs[kind].debug
+ if debug:
+ debug_settings = '\n'.join(['\t\t\t\t%s="%s"' % (key, xmlify(value))
+ for key, value in debug.items()
+ if value is not None])
+ self.usrfile.write(self.usrconf % locals())
+ self.usrfile.write('\t</Configurations>\n</VisualStudioUserFile>')
+
+V10UserHeader = """\
+<?xml version="1.0" encoding="%(encoding)s"?>
+<Project ToolsVersion="%(versionstr)s" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+"""
+
+V10UserConfiguration = """\
+\t<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='%(variant)s|%(platform)s'">
+%(debug_settings)s
+\t</PropertyGroup>
+"""
+
+V10DebugSettings = {
+'LocalDebuggerCommand': None,
+'LocalDebuggerCommandArguments': None,
+'LocalDebuggerEnvironment': None,
+'DebuggerFlavor': 'WindowsLocalDebugger',
+'LocalDebuggerWorkingDirectory': None,
+'LocalDebuggerAttach': None,
+'LocalDebuggerDebuggerType': None,
+'LocalDebuggerMergeEnvironment': None,
+'LocalDebuggerSQLDebugging': None,
+'RemoteDebuggerCommand': None,
+'RemoteDebuggerCommandArguments': None,
+'RemoteDebuggerWorkingDirectory': None,
+'RemoteDebuggerServerName': None,
+'RemoteDebuggerConnection': None,
+'RemoteDebuggerDebuggerType': None,
+'RemoteDebuggerAttach': None,
+'RemoteDebuggerSQLDebugging': None,
+'DeploymentDirectory': None,
+'AdditionalFiles': None,
+'RemoteDebuggerDeployDebugCppRuntime': None,
+'WebBrowserDebuggerHttpUrl': None,
+'WebBrowserDebuggerDebuggerType': None,
+'WebServiceDebuggerHttpUrl': None,
+'WebServiceDebuggerDebuggerType': None,
+'WebServiceDebuggerSQLDebugging': None,
+}
+
+class _GenerateV10User(_UserGenerator):
+ """Generates a Project'user file for MSVS 2010"""
+
+ def __init__(self, dspfile, source, env):
+ self.versionstr = '4.0'
+ self.usrhead = V10UserHeader
+ self.usrconf = V10UserConfiguration
+ self.usrdebg = V10DebugSettings
+ _UserGenerator.__init__(self, dspfile, source, env)
+
+ def UserProject(self):
+ confkeys = sorted(self.configs.keys())
+ for kind in confkeys:
+ variant = self.configs[kind].variant
+ platform = self.configs[kind].platform
+ debug = self.configs[kind].debug
+ if debug:
+ debug_settings = '\n'.join(['\t\t<%s>%s</%s>' % (key, xmlify(value), key)
+ for key, value in debug.items()
+ if value is not None])
+ self.usrfile.write(self.usrconf % locals())
+ self.usrfile.write('</Project>')
+
class _DSPGenerator(object):
""" Base class for DSP generators """
@@ -289,9 +493,17 @@ class _DSPGenerator(object):
runfile.append(s)
self.sconscript = env['MSVSSCONSCRIPT']
-
- cmdargs = env.get('cmdargs', '')
-
+
+ if 'cmdargs' not in env or env['cmdargs'] == None:
+ cmdargs = [''] * len(variants)
+ elif SCons.Util.is_String(env['cmdargs']):
+ cmdargs = [env['cmdargs']] * len(variants)
+ elif SCons.Util.is_List(env['cmdargs']):
+ if len(env['cmdargs']) != len(variants):
+ raise SCons.Errors.InternalError("Sizes of 'cmdargs' and 'variant' lists must be the same.")
+ else:
+ cmdargs = env['cmdargs']
+
self.env = env
if 'name' in self.env:
@@ -354,7 +566,7 @@ class _DSPGenerator(object):
print "Adding '" + self.name + ' - ' + config.variant + '|' + config.platform + "' to '" + str(dspfile) + "'"
for i in range(len(variants)):
- AddConfig(self, variants[i], buildtarget[i], outdir[i], runfile[i], cmdargs)
+ AddConfig(self, variants[i], buildtarget[i], outdir[i], runfile[i], cmdargs[i])
self.platforms = []
for key in self.configs.keys():
@@ -620,7 +832,7 @@ V8DSPConfiguration = """\
\t\t\t/>
\t\t</Configuration>
"""
-class _GenerateV7DSP(_DSPGenerator):
+class _GenerateV7DSP(_DSPGenerator, _GenerateV7User):
"""Generates a Project file for MSVS .NET"""
def __init__(self, dspfile, source, env):
@@ -643,6 +855,8 @@ class _GenerateV7DSP(_DSPGenerator):
self.dspheader = V7DSPHeader
self.dspconfiguration = V7DSPConfiguration
self.file = None
+
+ _GenerateV7User.__init__(self, dspfile, source, env)
def PrintHeader(self):
env = self.env
@@ -867,7 +1081,9 @@ class _GenerateV7DSP(_DSPGenerator):
self.PrintHeader()
self.PrintProject()
self.file.close()
-
+
+ _GenerateV7User.Build(self)
+
V10DSPHeader = """\
<?xml version="1.0" encoding="%(encoding)s"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
@@ -892,6 +1108,7 @@ V10DSPPropertyGroupCondition = """\
\t<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='%(variant)s|%(platform)s'" Label="Configuration">
\t\t<ConfigurationType>Makefile</ConfigurationType>
\t\t<UseOfMfc>false</UseOfMfc>
+\t\t<PlatformToolset>%(toolset)s</PlatformToolset>
\t</PropertyGroup>
"""
@@ -913,15 +1130,16 @@ V10DSPCommandLine = """\
\t\t<NMakeForcedUsingAssemblies Condition="'$(Configuration)|$(Platform)'=='%(variant)s|%(platform)s'">$(NMakeForcedUsingAssemblies)</NMakeForcedUsingAssemblies>
"""
-class _GenerateV10DSP(_DSPGenerator):
+class _GenerateV10DSP(_DSPGenerator, _GenerateV10User):
"""Generates a Project file for MSVS 2010"""
def __init__(self, dspfile, source, env):
_DSPGenerator.__init__(self, dspfile, source, env)
-
self.dspheader = V10DSPHeader
self.dspconfiguration = V10DSPProjectConfiguration
self.dspglobals = V10DSPGlobals
+
+ _GenerateV10User.__init__(self, dspfile, source, env)
def PrintHeader(self):
env = self.env
@@ -972,6 +1190,10 @@ class _GenerateV10DSP(_DSPGenerator):
self.file.write('\t<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\n')
+ toolset = ''
+ if 'MSVC_VERSION' in self.env:
+ version_num, suite = msvs_parse_version(self.env['MSVC_VERSION'])
+ toolset = 'v%d' % (version_num * 10)
for kind in confkeys:
variant = self.configs[kind].variant
platform = self.configs[kind].platform
@@ -1169,6 +1391,8 @@ class _GenerateV10DSP(_DSPGenerator):
self.PrintHeader()
self.PrintProject()
self.file.close()
+
+ _GenerateV10User.Build(self)
class _DSWGenerator(object):
""" Base class for DSW generators """