Commits

William Deegan committed ea9b3b6

Fix for bug 2405
Also refactored some logic from Defaults._defines() into Defaults.processDefines() which is then used by msvs.py

Comments (0)

Files changed (4)

QMTest/TestSConsMSVS.py

 \t\t\t\tReBuildCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;"
 \t\t\t\tCleanCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct -c &quot;Test.exe&quot;"
 \t\t\t\tOutput="Test.exe"
-\t\t\t\tPreprocessorDefinitions="DEF1;DEF2"
+\t\t\t\tPreprocessorDefinitions="DEF1;DEF2;DEF3=1234"
 \t\t\t\tIncludeSearchPath="inc1;inc2"
 \t\t\t\tForcedIncludes=""
 \t\t\t\tAssemblySearchPath=""
 
 SConscript_contents_8_0 = """\
 env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='8.0',
-                CPPDEFINES=['DEF1', 'DEF2'],
+                CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')],
                 CPPPATH=['inc1', 'inc2'])
 
 testsrc = ['test1.cpp', 'test2.cpp']

src/engine/SCons/Defaults.py

 
     return c(prefix, stripped, suffix, env)
 
-def _defines(prefix, defs, suffix, env, c=_concat_ixes):
-    """A wrapper around _concat_ixes that turns a list or string
-    into a list of C preprocessor command-line definitions.
+def processDefines(defs):
+    """process defines, resolving strings, lists, dictionaries, into a list of
+    strings
     """
     if SCons.Util.is_List(defs):
         l = []
                 l.append(str(k) + '=' + str(v))
     else:
         l = [str(defs)]
-    return c(prefix, env.subst_path(l), suffix, env)
+    return l
+
+def _defines(prefix, defs, suffix, env, c=_concat_ixes):
+    """A wrapper around _concat_ixes that turns a list or string
+    into a list of C preprocessor command-line definitions.
+    """
+
+    return c(prefix, env.subst_path(processDefines(defs)), suffix, env)
     
 class NullCmdGenerator:
     """This is a callable class that can be used in place of other

src/engine/SCons/Tool/msvs.py

 import SCons.Warnings
 
 from MSCommon import msvs_exists, merge_default_version
+from SCons.Defaults import processDefines
 
 ##############################################################################
 # Below here are the classes and functions for generation of
             # TODO(1.5)
             #preprocdefs = xmlify(';'.join(self.env.get('CPPDEFINES', [])))
             #includepath = xmlify(';'.join(self.env.get('CPPPATH', [])))
-            preprocdefs = xmlify(string.join(self.env.get('CPPDEFINES', []), ';'))
+            preprocdefs = xmlify(string.join(processDefines(self.env.get('CPPDEFINES', [])), ';'))
             includepath = xmlify(string.join(self.env.get('CPPPATH', []), ';'))
 
             if not env_has_buildtarget:

test/MSVS/vs-8.0-clean.py

 
 test.write('SConstruct', """\
 env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='8.0',
-                CPPDEFINES=['DEF1', 'DEF2'],
+                CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')],
                 CPPPATH=['inc1', 'inc2'])
 
 testsrc = ['test1.cpp', 'test2.cpp']