Archive

Posts Tagged ‘development’

Converting Visual Studio solutions to SCons

May 23rd, 2008 fvicente 4 comments

A python script to convert Microsoft Visual Studio 2005 solution files (*.sln) and the associated project files (*.vcproj) into a set of SCons files (SConstruct and SConscript).

Read more…

Converting Visual Studio solutions to Makefiles

May 23rd, 2008 fvicente 9 comments

A python script to convert Microsoft Visual Studio 2005 solution files (*.sln) and the associated project files (*.vcproj) into a set of Makefile’s.

The class Sln2Make does all the work, parses the sln and vcproj files and generates a main Makefile and one Makefile.ag for every project in the solution. The Makefiles.ag generated will have two targets, ‘all’ and ‘clean’, the script also includes the dependent libraries if they are properly defined in the solution. To use it, just instantiate the class with the following parameters:

Sln2Make(slnpath, exlist, dirrepl, librepl)

where:

  • slnpath is the path to the solution file
  • exlist an optional list of files to exclude, optionally you can pass the content of an alternative make file using this syntax: [[dest, make_all_replacement, make_clean_replacement], …]
  • dirrepl a list of directory replacement rules
  • librepl library name replacement rules (when win library name doesn’t match OS’s library name)

example:

exlist = [('../extsrc/zlib/projects/visualc6/Makefile.ag',
'	$(MAKE) -C $(dir_root)extsrc/zlib -f Makefile libz.a\n',
'	$(MAKE) -C $(dir_root)extsrc/zlib -f Makefile clean\n')]
dirrepl = [['winnt', 'linux']]
librepl = [['zlib', 'z'], ['nspr', 'nspr4 -lplc4 -lplds4']]
#
Sln2Make("../winnt/test.sln", exlist, dirrepl, librepl)

To correct the path case, I’ve used a script published by Moshe Zadka here.
Download sln2make here. Use this code at your own risk, it is released under BSD license.