Commits

Gary Oberbrunner committed 7065630

Fix issue #2702, MSVS generation fails when CPPPATH contains Dir nodes. Also make MSVS project depend on values of CPPDEFINES and CPPPATH so it gets properly regenerated when they change.

Comments (0)

Files changed (3)

       embed manifests in Windows EXEs and DLLs.
 
   From Gary Oberbrunner:
+    - Fix Visual Studio project generation when CPPPATH contains Dir nodes
+    - Ensure Visual Studio project is regenerated when CPPPATH or CPPDEFINES change
     - Fix unicode error when using non-ASCII filenames with Copy or Install
     - Put RPATH in LINKCOM rather than LINKFLAGS so resetting
       LINKFLAGS doesn't kill RPATH
 
   FIXES
 
+    - Visual Studio project generation now works when CPPPATH contains Dir nodes
+    - Visual Studio projects are regenerated when CPPPATH or CPPDEFINES change
+      NOTE: this will cause all MSVS projects to be regenerated with this version.
     - Passing MSVC_BATCH=False works now (treated same as 0)
     - Long compile lines no longer break MSVC_BATCH mode
     - RPATH is now in LINKCOM rather than LINKFLAGS, so resetting

src/engine/SCons/Tool/msvs.py

 import SCons.Node.FS
 import SCons.Platform.win32
 import SCons.Script.SConscript
+import SCons.PathList
 import SCons.Util
 import SCons.Warnings
 
     s = s.replace('"', """)
     return s
 
+# Process a CPPPATH list in includes, given the env, target and source.
+# Returns a tuple of nodes.
+def processIncludes(includes, env, target, source):
+    return SCons.PathList.PathList(includes).subst_path(env, target, source)
+    
+
 external_makefile_guid = '{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}'
 
 def _generateGUID(slnfile, name):
             rebuildcmd  = xmlify(starting + self.env.subst('$MSVSREBUILDCOM', 1) + cmdargs)
             cleancmd    = xmlify(starting + self.env.subst('$MSVSCLEANCOM', 1) + cmdargs)
 
+            # This isn't perfect; CPPDEFINES and CPPPATH can contain $TARGET and $SOURCE,
+            # so they could vary depending on the command being generated.  This code
+            # assumes they don't.
             preprocdefs = xmlify(';'.join(processDefines(self.env.get('CPPDEFINES', []))))
-            includepath = xmlify(';'.join(self.env.get('CPPPATH', [])))
-
+            includepath_Dirs = processIncludes(self.env.get('CPPPATH', []), self.env, None, None)
+            includepath = xmlify(';'.join([str(x) for x in includepath_Dirs]))
+            
             if not env_has_buildtarget:
                 del self.env['MSVSBUILDTARGET']
 
         source = source + env.subst('$MSVSSCONSCOM', 1)
         source = source + env.subst('$MSVSENCODING', 1)
 
+        # Project file depends on CPPDEFINES and CPPPATH
+        preprocdefs = xmlify(';'.join(processDefines(env.get('CPPDEFINES', []))))
+        includepath_Dirs = processIncludes(env.get('CPPPATH', []), env, None, None)
+        includepath = xmlify(';'.join([str(x) for x in includepath_Dirs]))
+        source = source + "; ppdefs:%s incpath:%s"%(preprocdefs, includepath)
+
         if 'buildtarget' in env and env['buildtarget'] != None:
             if SCons.Util.is_String(env['buildtarget']):
                 source = source + ' "%s"' % env['buildtarget']