[Scons-users] Can SCons do this?

Francis Bolduc fbolduc at gmail.com
Tue Jan 15 08:52:05 EST 2013



> I do prefer to develop on Windows, because Visual Studio (VS) has a nice

> MPI debugger. I wonder if I can use SCons to generate the project\solution

> files for VS, so I won't need to update both SCons script and VS project. My

> workfllow would be to add whatever I need to SCons, regenerate the VS

> project, continue to work with VS. At what extent is this supported? What

> about VS versions?

>

> Another example: I currently #define quite a lot of stuff for the build.

> Would it be possible to propagate these into the VS project as well?


This is my situation at work. Most of our developers would not feel
comfortable not having an IDE, therefore we generate projects for all
the different IDE (MSVS2005, MSVS2008, MSVS20010, QtCreator2, XCode,
CppCheck, etc.) using the same informations required to build the
binaries from the SConscript files.

There is some support in SCons to do project generation, but it wasn't
sufficient for my needs so I ended up doing project generation
manually myself. I use a two-pass technique that works very well.

In the first pass, I do a normal SCons run, but with a special command
line option that hijacks the Program, Library and SharedLibrary
builders. Instead of compiling binaries, they dump all the
informations they have (list of include directory, list of #define,
list of libraries to link with, list of source files, name of binary,
etc.) into a JSON file.

After that, I run a simply Python script that reads the JSON file and
generates the proper project files. I have one script per type of
projects. This allows me to have a maximum of control on what is
generated, especialy the build command, because I use a top-level
Makefile on top of SCons.




> On what extent is SCons aware of compiler flags and where they are in my

> VS project file? So for example I want to set the warning level flag in VS

> (which is different from g++ or xlC) — can I do it in SCons in a way that it

> is propagated into my VS project file?

>

> What would happen if SCons is not aware of the mapping of my particular

> option to a certain element of project file? For example, the next version

> of VS is going to introduce a /magic flag, that I can set in some nested

> dusty corner of configuration GUI. I suspect, that even if I manually tell

> SCons to use /magic, as a compilation flag, it won't be able to set it in

> the VS project file: when I generate the project file with SCons and open it

> in VS the /magic is not going to be turned on.


Through manual project generation you can achieve anything, but you
need to know everything about those project files. SCons will tell you
all the flags, but it's up to you to put it at the right place.

You can also try your luck with the default project generation
provided with SCons. Maybe it'll work for you.


More information about the Scons-users mailing list