SCons build system

A place for Ogre users to discuss non-Ogre subjects with friends from the community.
Post Reply
User avatar
SpaceDude
Bronze Sponsor
Bronze Sponsor
Posts: 822
Joined: Thu Feb 02, 2006 1:49 pm
Location: Nottingham, UK
x 3
Contact:

SCons build system

Post by SpaceDude »

Has anybody used SCons as a build system for C++ projects? I've been reading through the documentation and it seems quite easy to use. Basically I find the whole auto-tools under linux are a pain in the ass, too many commands to remember. On windows I'm quite happy with using MSVC++ but it's not cross-platform.

I like the fact that all the scripts you need to write are in Python and that it is able to generate visual studio project files. I've used CMake in the past which also generates visual studio files, although CMake does the job there are a few things it doesn't handle very well. For example pre-compiled headers are poorly supported, although recently they have added some support for it. And I find the CMakeLists.txt format quite cryptic and poorly documented.

I was wondering if anybody has used SCons and what they thought about it? I'm interested in using it for building my applications under linux and if possible to generate MSVC projects for me on windows. My main development environment is windows, but I need an easy way to compile under linux too with minimal maintenance/hassle.
User avatar
SunSailor
Gnoll
Posts: 699
Joined: Sun Jan 02, 2005 5:45 pm
Location: Velbert, Germany
x 2
Contact:

Post by SunSailor »

We're using Scons currently for all unix based components, namely our servers. We are very pleased with this system, as it is very easy to start with - you only need one or two lines and can start coding cpp directly - but grows very good with the project. As it is a simple python script, manual extensions are created in a very short time - e.g. you have full access on all python bindings installed, like the subversion ones. Simply do revision related stuff within the script or do asset conversions/modifications with available libraries.
On the other hand I heard from people, that it tends to be slow on very big projects, but I haven't experienced this myself, but our servers aren't too big so I really can't judge that (Even if I can't imagine, how the speed of the build system can be of importance, as most of the time is always consumed by the compiler...).
User avatar
SpaceDude
Bronze Sponsor
Bronze Sponsor
Posts: 822
Joined: Thu Feb 02, 2006 1:49 pm
Location: Nottingham, UK
x 3
Contact:

Post by SpaceDude »

Thanks SunSailor, I appreciate your comments. Speed is not a major concern for me as I develop with MSVC++ anyway, I only need to compile under Linux once in a while so I'd rather trade performance for easy of use and flexibility.
mirlix
Goblin
Posts: 225
Joined: Mon May 01, 2006 12:03 am
Location: Germany
x 5

Post by mirlix »

Take a look at premake, is is very powerfull as it scons :).
btmorex
Gremlin
Posts: 156
Joined: Thu May 17, 2007 10:56 pm

Post by btmorex »

I used scons for a while on a couple different projects. I probably won't use it again because:

1.) It's really, really slow. This isn't such a big problem if you only have a few sources files, but when the difference becomes 5 minute vs. 10 minutes for a build or even longer, it's really annoying.
2.) I get the feeling large projects either haven't tried using it or haven't been successful. Even though my project wasn't very complicated (a few binaries, a couple libraries), I ended having to write a lot of python code to get it working the way I wanted. It's sort of a doubled edged sword. On the one hand, I can write python code to do just about anything. On the other hand, most other build systems do *so* much more automatically.

For what it's worth, I'm going to try out cmake for my next project.
User avatar
triton
Greenskin
Posts: 138
Joined: Thu Mar 13, 2008 10:25 pm
Location: Portugal

Post by triton »

Also take a look at waf (a SCons fork).
User avatar
SpaceDude
Bronze Sponsor
Bronze Sponsor
Posts: 822
Joined: Thu Feb 02, 2006 1:49 pm
Location: Nottingham, UK
x 3
Contact:

Post by SpaceDude »

btmorex wrote:Even though my project wasn't very complicated (a few binaries, a couple libraries), I ended having to write a lot of python code to get it working the way I wanted. It's sort of a doubled edged sword. On the one hand, I can write python code to do just about anything. On the other hand, most other build systems do *so* much more automatically.
Hmm yes you might be right there. It seems SCons doesn't have the concept of a release or debug build (correct me if I'm wrong). With CMake it will create a Release and Debug configuration for you with sensible defaults, which seems natural to me being primarily a MSVC user. So it seems it's up to the user to code that stuff up. Also I like the fact that CMake's primary way of building is to generate MSVC project files. I know SCons supports generating project files too but it seems like that was kind of added as an after thought (maybe to compete with CMake).

I may go back to using CMake, now that they've added PCH support I don't think there is anything more that I need from it. They recently revamped the website and looks like they structured the documentation a bit better for the upcoming version 2.6. If only it used a nicer scripting language like Python to create the input files.
User avatar
Game_Ender
Ogre Magi
Posts: 1269
Joined: Wed May 25, 2005 2:31 am
Location: Rockville, MD, USA

Post by Game_Ender »

I work with both a SCons and CMake based build systems. In CMake I often end up fighting with the language in order to get it to do what I want. In SCons I find myself righting some extra code.

In defense of SCons the only thing it is missing that CMake has by default is debug/release variants. In large part that stuff is balanced out by the fact that SCons has better online documentation. For example there wiki has this very simple (2 lines) example of how to get debug and release builds.

Something that is important to note is that the slow part of SCons is only the dependency checking. Once that is done, its actually faster than recursive Makefiles or MSVS solutions because its truly parallel up the number of jobs you desire. Now the CMake generation phase is not super fast either. Its just that the dependency checking is faster because the build systems it generates are less through when compared to SCons.

In the end I really just want CMake with python files on the front. That would let me use IDE based build systems when I want (Xcode, MSVS, Eclipse CDT), while at same time not hamper my attempts at creating some helper modules for large projects.
User avatar
SpaceDude
Bronze Sponsor
Bronze Sponsor
Posts: 822
Joined: Thu Feb 02, 2006 1:49 pm
Location: Nottingham, UK
x 3
Contact:

Post by SpaceDude »

I agree with what you said Game_Ender, just one other thing about CMake that I don't think SCons has (again, correct me if I'm wrong):

I quite like the way CMake lets you manually select the paths when they cannot be found automatically (as is often the case on windows). Especially if you put your code on a source control system, you don't want to store a bunch of directories which are specific to your machine. I may have installed Ogre in "d:\OpenSource\C++\ogre" but I don't want that to be hardcoded into my build script because its unlikely anybody else is using the same directory structure. CMake lets you configure the paths with a GUI and saves them to a cache which does not live in the source controlled repository.

Reading through the SCons documentation it's not clear to me how this should be handled in an efficient manner.
User avatar
Game_Ender
Ogre Magi
Posts: 1269
Joined: Wed May 25, 2005 2:31 am
Location: Rockville, MD, USA

Post by Game_Ender »

CMake and SCons are pretty equal here. SCons wouldn't be used by ID and VMware if you had to hard code paths. Both let you set variables in your build environments through command line options and/or load them from a file on disk. CMake just has a nice GUI program which lets you set them as well.

In SCons its like this:

Code: Select all

# Options either come from command line of config file
opts = Options('options.py')

opts.AddOptions(
     PathOption('build_dir', 'Path to place build products in', 'build',
                           PathOption.PathIsDirCreate)
     )

env = Environment(ENV = os.environ,
                                    options = opts)
"options.py" is just the name of the python file that is loaded. It can set all the paths and settings you want. See here to learn more about the different options.
Post Reply