Skip to content
William Deegan edited this page Sep 25, 2021 · 8 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: Getting info


SCons: Extending


Command-line arguments and help


Build configuration


Build logs


Increasing performance and large builds

  • 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

Build organization


Targets

General tips

Install & Uninstall Targets

Clean Targets


Tree Problems


Source 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

Building and Linking


Build Dirs


Environment


Testing

  • unit tests - running unit tests with an Alias or Command

Multiple Projects


Misc


Full-blown Examples

  • 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)
Clone this wiki locally