-
-
Notifications
You must be signed in to change notification settings - Fork 318
SconsRecipes
Keith edited this page Sep 5, 2024
·
9 revisions
This is the place to share tips, examples, and short scripts. Do not hesitate to contribute!
Additional resources:
- The official SCons User Guide contains a lot of examples.
- The SCons Cookbook quick examples (these are now maintained separately from the manual page, which they once were part of)
- SCons Version - retrieve the version of SCons from your script
- SCons Dump Environment - dump the contents of the construction environment
- wrapper for python functions - wrap up a bit of SCons and python as a new Environment method without modifying scons itself
- avoid Import()/Export() statements - hack to avoid using Import() in SConscripts
- arguments quoting - a tip on arguments quoting in SCons actions
- customize SCons command-line - the different way of interacting with your scripts from the command-line
- automatic help for Aliases - technique for injecting helper functions into environment and wrapping Alias() to get Help() automatically
- SCons Autoconf - add autoconf functionality to your scons builds
- Autoconf recipes - some additional autoconf macro implementations
- config source file - generating a config.h file to use along with the sources
- saving variables to a file - saving the value of some variables to a file and loading them back
- update only some variables - update some variables in an environment without overwriting changes to others
- log SCons output to a file - write SCons output to a file as well as the screen
- colorize build messages - replace the raw build commands printed to the screen with colored messages
- using colorgcc - using the colorgcc wrapper to colorize the output of compilers with warning/error messages matching the gcc output format
- customize command-lines printed by SCons - how to hide all or part of the printed command lines for prettier build logs
- faster builds - options you can use to make SCons faster by sacrificing build accuracy
- prevent building everything - you have a big hierarchical tree of projects...
- proxy dependencies - a simple way to avoid inefficiencies when you have commands that consume lots of input files and produce lots of output files
- target driven builder creation - avoid scanning large source trees on startup by only queuing up dependencies on demand for things SCons actually needs to build
- limit cache size - prevent the cache directory to grow indefinitely
- modular example - a modular way to support multiple systems and build multiple setups at a time
- simultaneous variant builds - build different variants (e.g. debug/release, target/host) at the same time
- serialise for shared resources - tell scons to run particular tasks in series, while letting others run in parallel
- multiple directory Fortran build - setup a multiple-directory Fortran 90 project
- get SCons targets - look at the targets the user entered
- using phony targets - defining a target that is always built
- using Alias() with Depends() - ensure Alias() work correctly with Depends() statements
- install targets - adding 'install' and 'uninstall' targets
- installation prefix - adding a prefix path for install
- platform independent installation tool - a tool to ease multiplatform installation
- custom clean actions - add additional actions for when scons is in clean mode
- non deterministic dependencies - incorporate builders producing an unknown number of results
- dynamic source generator - dynamically add sources generated by a source generator that puts out many files
- dir glob - glob for source files from a build directory
- external files - use other source files not recognized by scons (e.g. linker scripts)
- find target sources - find sources and headers for a target (e.g. when generating MSVSProject)
- add files dynamically - add files to every build per-environment
- MFObject - compile multiple source files with a single invocation of the compiler
- explicitly call CppScanner - explicitly call the C/CPP scanner on a source file in your SConstruct/SConscript
- using Origin - using $ORIGIN to specify runtime search path for libraries
- using pkg-config - many libraries these days come with .pc files, such as GTK+, but how do you use them?
- override shared library signature - avoid relinking every program when a shared library is rebuilt
- build-time callback - add a function called at build time
- RightNow - build one or more targets during the SConscript reading phase, then continue reading SConscripts
- Shared Library -Wl,--whole-archive - Handling position dependent options relative to input files.
- importing system environment settings - importing settings from your process environment
- EnvValue - a value node which substitutes variables from the environment
- using external tools - using external tools from within SCons frequently requires certain types of environment variable inheritance
- unit tests - running unit tests with an Alias or Command
- SconstructMultipleRefactored - clean up redundancy in SconstructMultiple
- SconstructMultipleAll - build all, multiple projects, build dir, debug/release
- SconstructMultiple - multiple projects, build dir, debug/release
- java native interface - build java native interface (JNI) libraries
- SconsLatexThesisSkeleton: A more elaborate way to build LaTeX documents with SCons, including automatic file format conversion
- StaticallyLink: Statically link g++ libraries
- CudaTool - tool for NVidia's CUDA
- Building Debian packages
- Quite a bunch of SCons techniques, including the use of SConf, can be seen in the https://madman.sf.net madman build scripts
- Cluster Integration: Example of using slurm to distribute build steps to a cluster
- advanced build example - 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
- extended example - alog of John Arrizza's quest to convert an Ant-based build system to SCons
- all in SConstruct - Bill Baxter's attempt at a SCons-based build system
- RpmHonchoTemp - JeffPitman's adventure in coercing SCons to manage an RPM repository
- basic simple project - 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
- Maven ideas with SCons - an approach of using some maven ideas and best practices with SCons
- SDLWindowsApp - a typical SDL application on Windows (including icon and no annoying dialog pop-up)