[edit] Using the SCons build systemStarting right after build-9half, th Linux-developers of Widelands has switched from the well-known Makefiles to a build system based on SCons.
[edit] Why SCons?SCons basically does the same job as make, so why the switch?
OK, so we switched. But how do we use it and are there any differences to using make?
[edit] Using SConsUsing SCons is very similar to make. It's just the additional things that make it a joy to work with The commands you will use most often are:
Not a big difference, right? But there's more:
[edit] Build optionsSimilar to autotools' configure, SCons allows you to add configuration options to your build. It work's like you'd expect: scons BUILD_OPTION=VALUE To look up the available options, use scons -h SCons will remember your choice and use it for future compiles! So if you need an additional include path, specifiy it once: scons extra_include_path=/home/me/include and from then on just use "scons". No Makefile editing, no shell aliasing, nothing.
[edit] Build typesIn Makefile/Makefile.local you could specify a build type like profile. With SCons, build type is a normal command line option: scons build_type=profile The available build types are:
Note that, unlike before, intermediate build files will not be stored in, e.g., src/native-debug but rather in build/native-debug. SCons does not touch source directories in any way.
[edit] Build IDsBasically everybody uses some kind of versioning in their releases. For Widelands, those are numbered builds (such as build-10, build-11, etc.). Setting this build ID is essential when creating releases, but once you have it it's also easy to create e.g. weekly snapshots. By default, the build ID is automatically determined based on the current SVN revision number. Repositories using svk or git-svn are also supported by this mechanism. If you want something different, use the parameter build_id: scons build_id=build10 dist (for "dist", see below) will create widelands-build10.tar.gz Distributing files is great, but wouldn't it be cool to use this ID in the program too? You can==
Just #include "build_id.h". This file gets created on every compiler run and contains:
Keep in mind that SCons will remember this setting, so after a release make sure you go back to build_id="" to reenable the automatic mechanism. [edit] config.hOn each run, SCons will create the file src/config.h. It contains information that has been autodetected - if you need to know about the environment, just ask the config system (that's what it's there for ;) ). If there are changes from the last run, files #include-ing config.h will be recompiled accordingly. config.h contents are created 'manually', so if you need more information in config.h, you have to modify the SConstruct file.
[edit] Other targetsOf course, SCons lets you do anything you could do with the old build system. Additionaly targets include:
[edit] CaveatsSCons ignores all environment variables, including PATH, CPPPATH and LIBPATH! This is done on purpose: SCons will detect your build environment and will adapt to it in a predictable manner. Environment variables can screw up this autodetection big time, which makes repeatable builds impossible and can cause very difficult bugs. So if you need external information, use SCons to detect it (best), create a command line option (good enough) or rather forget about it. That's not to say it can't be done. It's just not a very good idea. |
![[Main Page]](/modules/mediawiki/images/mediawiki.png)
Using the SCons build system
From Widelands.org
Main Page | Recent changes | Edit this page | Page history | Switch to MediaWiki modePrintable version | Disclaimers | Privacy policy
