Home > Software Development > Converting Visual Studio solutions to SCons

Converting Visual Studio solutions to SCons

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).

This script is similar to my previous post Sln2Make but instead of generating Makefiles it creates SCons scripts. The class Sln2SCons does all the work, parses the sln and vcproj files and generates a main SConstruct and one SConscript for every project in the solution. To use it, just instantiate the class with the following parameters:

Sln2SCons(slnpath, exlist, dirrepl, librepl, outdir)

where:

  • slnpath is the path to the solution file
  • exlist an optional list of files to exclude, optionally you can pass an alternative script name to be included from the main SConstruct: [[script_to_exclude, alt_script], …]
  • dirrepl a list of directory replacement rules
  • librepl library name replacement rules (when win library name doesn’t match OS’s library name)
  • outdir is the output directory for the SConstruct

example:


# custom scripts
exlist = [('../extsrc/apr/SConscript', 'extsrc/apr/SConscript.py')]
# special directory replacement rules
dirrepl = []
# special library name replacement rules (when win library name doesn't match OS's library name)
librepl = []
Sln2SCons("../winnt/test.sln", exlist, dirrepl, librepl, "../")

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

The source is in Google Code now, here is the link.

  1. fcrestois
    May 26th, 2008 at 14:43 | #1

    Nice work but
    PreprocessorDefinitions and $(ProjectDir) is not yet manage
    Do you think to put this project under SourceForge or Google Code to permit contribution ?
    Thanks

  2. fvicente
    May 26th, 2008 at 23:28 | #2

    Thanks for the comment fcrestois, following your suggestion I created a google project to allow contributions… here is the link http://code.google.com/p/sln2scons/

  3. Desmond
    November 26th, 2008 at 18:12 | #3

    Is it possible to go the other way? Give a set of sconstruct and sconscript files and produce visual studio solutions? I don’t know python or scons very well.

  4. fvicente
    November 26th, 2008 at 20:46 | #4

    Hi Desmond,
    To be honest I never tried that before, but in the (very extensive) SCons Man page, there is a “env.MSVSSolution()” which I believe is intended to do that.
    Take a look in http://www.scons.org/doc/HTML/scons-man.html

  1. No trackbacks yet.
 

Spam protection by WP Captcha-Free