[Scons-dev] Support for project dependencies in MSVS builder

Tomer Shalev shalev.tomer at gmail.com
Wed Jul 16 15:40:43 EDT 2014


Hello Bill,

Here is the patch :-)

I would like to hear developer's opinion on the subject, mainly the new API
change, before I prepare any pull request (+tests, as the guidelines
recommend).

Thanks,
Tomer


On Wed, Jul 16, 2014 at 10:32 PM, Bill Deegan <bill at baddogconsulting.com>
wrote:

> Tomer,
>
> I don't see an attached patch.
>
> If possible it would be great if you can submit a pull request via
> bitbucket with your proposed change.
>
> Thanks,
> Bill
>
>
> On Mon, Jul 14, 2014 at 8:20 PM, Tomer Shalev <shalev.tomer at gmail.com>
> wrote:
>
>> Hello,
>>
>> Current MSVS builder does not support project dependencies.
>> I implemented such support, but I would like to raise it for discussion
>> here before submitting patch request.
>>
>> My solution is to support specifying dict object in project list, with
>> 'name' and 'depends' fields:
>>
>> projects = [
>>     "Foo.vcproj",
>>     "Bar.vcproj",
>>     {
>>         'name':     "FooBar.vcproj",
>>         'depends':  [ 'Foo.vcproj', 'Bar.vcproj' ],
>>     },
>>     ]
>>
>> msvs_solution = env.MSVSSolution(
>>         target = "TestDeps.sln",
>>         projects = projects,
>>         )
>>
>>
>> Please review attached patch.
>>
>> Thanks,
>> Tomer
>>
>>>
>>
>> _______________________________________________
>> Scons-dev mailing list
>> Scons-dev at scons.org
>> http://two.pairlist.net/mailman/listinfo/scons-dev
>>
>>
>
> _______________________________________________
> Scons-dev mailing list
> Scons-dev at scons.org
> http://two.pairlist.net/mailman/listinfo/scons-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/scons-dev/attachments/20140716/33559669/attachment.html>
-------------- next part --------------
--- Z:/Tools/VPScripts/VPScripts-01.08.04/lib/python/SCons/Tool/msvs.py	Fri May 16 15:01:41 2014
+++ Y:/tshalev/VPScripts-01.08.04/lib/python/SCons/Tool/msvs.py	Tue Jul 01 05:41:32 2014
@@ -1182,6 +1182,14 @@
         projects = env['projects']
         if not SCons.Util.is_List(projects):
             raise SCons.Errors.InternalError("The 'projects' argument must be a list of nodes.")
+
+        self.dspfiles_deps = {}
+        for i, p in enumerate(projects):
+            if isinstance(p, dict):
+                assert('name' in p)
+                assert('depends' in p)
+                projects[i] = p['name']
+                self.dspfiles_deps[p['name']] = p['depends']
         projects = SCons.Util.flatten(projects)
         if len(projects) < 1:
             raise SCons.Errors.UserError("You must specify at least one project to create an MSVSSolution.")
@@ -1268,10 +1276,12 @@
                     dsp_relative_file_path = name
                 else:
                     dsp_relative_file_path = os.path.join(dsp_relative_folder_path, name)
+                dsp_dependencies = self.dspfiles_deps.get(dspfile)
                 dspfile_info = {'NAME': name,
                                 'GUID': _generateGUID(dspfile, ''),
                                 'FOLDER_PATH': dsp_folder_path,
                                 'FILE_PATH': dspfile,
+                                'DEPENDENCIES': dsp_dependencies,
                                 'SLN_RELATIVE_FOLDER_PATH': dsp_relative_folder_path,
                                 'SLN_RELATIVE_FILE_PATH': dsp_relative_file_path}
                 self.dspfiles_info.append(dspfile_info)
@@ -1319,7 +1329,7 @@
             self.file.write('# Visual Studio 2008\n')
         elif self.version_num >= 8.0:
             self.file.write('# Visual Studio 2005\n')
-            
+
         for dspinfo in self.dspfiles_info:
             name = dspinfo['NAME']
             base, suffix = SCons.Util.splitext(name)
@@ -1330,6 +1340,17 @@
             if self.version_num >= 7.1 and self.version_num < 8.0:
                 self.file.write('\tProjectSection(ProjectDependencies) = postProject\n'
                                 '\tEndProjectSection\n')
+
+            if dspinfo['DEPENDENCIES']:
+                self.file.write('\tProjectSection(ProjectDependencies) = postProject\n')
+                for dep in dspinfo['DEPENDENCIES']:
+                    matching = [d for d in self.dspfiles_info if d['NAME'] == dep]
+                    if not matching:
+                        raise RuntimeError("{name} dependency not found: {dependency}".format(name = name, dependency = dep))
+
+                    self.file.write('\t\t{guid} = {guid}\n'.format(guid = matching[0]['GUID']))
+                self.file.write('\tEndProjectSection\n')
+
             self.file.write('EndProject\n')
 
         self.file.write('Global\n')


More information about the Scons-dev mailing list