This is the place to share tips, examples, and short scripts. Put Builders and Tools here.
Contents
General Tips
The SCons ManPage contains a number of quick examples. See the Examples section towards the bottom of the page.
ArgumentQuoting in actions
SconsVersion: how to retrieve the version of scons from your script
Build Options, Targets, etc.
UsingCommandLineArguments: Using ARGUMENTS
GetTargets: you want to look at the targets the user entered
WgetSourceCode: How to use sourcecode() methods to 'wget' files
UsingOrigin: using $ORIGIN to specify runtime search path for libraries
PhonyTargets: A close approximation of a target that is always built
CustomCleanActions: Having an Action run when scons is in clean mode
Useful tips for common tasks
ImportingEnvironmentSettings from your process environment.
UsingPkgConfig: many libraries these days come with .pc files, such as GTK+, but how do you use them?
InstallTargets: writing an install target
BuildLog: How to write SCons output to a file as well as the screen.
DependsAndAliases: How to ensure Alias() work correctly with Depends()
WrapperFunctions: you want to wrap up a bit of SCons and python as a new Environment method without modifying scons itself
UsingCvs: how to download source files from a CVS server
Using ExternalTools from within SCons frequently requires certain types of environment variable inheritance.
BuildDirGlob lets you glob for source files from a build directory.
ExternalFiles: how to use other source files not recognized by scons (e.g. linker scripts)
SharedLibrarySignatureOverride: avoid relinking every program when a shared library is rebuilt.
AutomaticHelpFromAliases: technique for injecting helper functions into environment and wrapping Alias() to get Help() automatically
UnitTests: Running unit tests with an Alias or Command
ValgrindMemChecker: Automatic running of valgrind on executables
StripExecutable: Strip the resulting executable
ColorGcc: using the colorgcc wrapper to colorize the output of compilers with warning / error messages matching the gcc output format.
DynamicSourceGenerator: how to use a source generator that puts out many source files, by having scons add targets dynamically.
Qt4Tool: David García Garzón has been working on a Qt4 tool with much success
HidingCommandLinesInOutput: how to hide all or part of the printed command lines for prettier build logs.
EmbedManifestIntoTarget: how to embed the manifest file into your target file using the Microsoft Manifest Tool
BuildTimeCallback: How to have a function called at build time
EnvValue: A value node which substitutes variables from the environment
CheckBoostVersion: Boost does not provide pkg-config file so we need to check its version by other means
FindTargetSources: Find sources and headers for a target when generating MSVSProject.
Increasing performance and large builds
The GoFastButton: options you can use to make SCons faster by sacrificing build accuracy
AdvancedBuildExample: This document describes how the Bombyx project is doing its builds. This configuration is interesting in that it builds for each target platform in a different directory, and has a very structured build.
SimultaneousVariantBuilds: How to make build different variants (e.g. debug/release, target/host) at the same time.
ConfiguringEnvironments: How to set up your Environments if you have complex cross-platform builds.
PreventBuildingOfEverything: you have a big hierarchical tree of projects...
ProxyDependencies: A simple way to avoid inefficiencies when you have commands that consume lots of input files and produce lots of output files.
Specific Platforms and Tool-Chains
MacOSX: tips for using SCons with Mac OS X.
PalmApplications: how to build Palm applications on Linux and Windows(cygwin) with the Palm prc-tools
CrossCompilingMingw: Enable building on Unix for itself and for Win32 with mingw32 cross compiler
SconstructShortest: The shortest SConstruct period.
SconstructShortMingwWin32: The shortest SConstruct using Mingw under Win32.
SconstructShortMsvcWin32: The shortest SConstruct using MSVC under Win32.
SconstructShortMsvcWin32BuildDir: MSVC under Win32, with build dir.
SconstructShortMsvcWin32CompileParms: MSVC under Win32, with build dir, compile parms
SconstructShortMsvcWin32DebugRelease: MSVC under Win32, with build dir, debug/release
SconstructMultiple: multiple projects, build dir, debug/release
SconstructMultipleAll: build all, multiple projects, build dir, debug/release
SconstructMultipleRefactored: clean up redundancy in SconstructMultiple
SconsDotNet - using SCons to build CoctaThorpe and VbDotNet
PocketPc: Building a Pocket PC application with the Pocket PC 2002 SDK
LongCmdLinesOnWin32 helps with the severe problem of having very long shell commands not working with Windows. You typically encounter this when dealing with linking large projects with MingW.
JavaNativeInterface: how to build java native interface (JNI) libraries
FromQmakeToScons: how to make the switch
MultipleDirectoryFortranBuild: how to setup a multiple-directory Fortran 90 project
MsvsMultipleVersions: how to select MSVS version when multiple versions are installed
StaticallyLink: Statically link g++ libraries
MsTest - running MS VS unittests (mstest) and generating coverage reports as html
Useful Builders
ReplacementBuilder: for when you need to take a *.in file and replace some variables in it, such as pkg-config .pc files or DBus .service files
UsingCodeGenerators: how to build an application and then use that application to generate other files
PythonExtensions: how to build python extension modules using SCons Swig & Boost
BuildNumberProcessing: you have a build number or version number that needs to be included in the link
UsingCompilerBuilt asks about building a compiler/tool which is then used to build the application.
NasmBuilder: how to compile nasm source files
RpcBuilder: how to compile RPC protocol sources
CorbaBuilder: Builder for orbix corba idl generated C++ files.
CorbaTaoBuilder: Builder for tao corba idl generated C++ files.
AntlrBuilder: Builder for antlr to create targets that Scons can use
RunningConfigureAndMake: how to use SCons to run configure and make, as part of migrating from Makefiles
AccumulateBuilder: builder which "collects" files and/or directories for easy tarring/zipping for distribution
UicImageEmbedder: builder which generates an image collection by embedding image files into a c++ sourcefile
SubstInFileBuilder: provides TOOL_SUBST, which substitutes values from a dictionary into a file. Can be used for autotools-like configure substitution or other purposes.
DistTarBuilder: builds a tar file with an internal directory structure
DoxygenBuilder: generates doxygen docs automatically scanning for dependencies
CsharpBuilder: a builder to support C# using Mono, mcs, etc.
SwigBuilder: extra stuff about building SWIG beyond what's currently built-in.
NsisBuilder: see NsisSconsTool
EiffelStudio56Tool: Builder tool for the Eiffel programming language (EiffelStudio 5.6).
GchBuilder: Builder for gcc's precompiled headers
EnvValue: A value node which substitutes variables from the environment
CombineBuilder: Small Builder to include several c/c++ source files into one file
ArchiveBuilder: Builder to make archive (tar.gz, tar.bz2 or zip) in a simple way
GhcBuilder: Builder for the Haskell programming language.
CxxTestBuilder: Integrate CxxTest unit testing framework into scons, together with a 'scons check' target. (make check clone from autotools)
Configuration
AddFilesDynamically to every build per-environment
SconsAutoconf: How to add autoconf functionality to your scons builds.
Autoconf recipes: a few autoconf macro implementations.
GenerateConfig: generating a config.h file
Full-blown Examples
ExtendedExample A log of John Arrizza's quest to convert an Ant-based build system to SCons.
AllInSConstruct Bill Baxter's attempt at a SCons-based build system.
RpmHonchoTemp: JeffPitman's adventure in coercing SCons to manage an RPM repository.
BasicSimpleProject: Andrew Lentvorski's venture to build Gambit with SCons on his way to cross-compiling
SimpleProject_1: A simple project with libraries and profile information
MavenIdeasWithSCons: An approach of using some maven ideas and best practices with SCons.
Tips and ideas for debugging scons, SConstruct and SConscript files
DumpEnv: Dump the contents of the construction environment
