Links
- Man Page always up to date
- User Guide latest stable - wip
- Documentation
Overview
- SConstruct
- Equivalent to Makefile, CMakefile, Rakefile, etc.
- Search order is SConstruct, Sconstruct, sconstruct
- Scons is chatty by default and prints lots of status
messages.
- Use
-Q
to suppress them.
- Use
-
scons does not automatically propagate the external environment used to execute scons to the commands used to build target files.
-
Whenever you create an scons construction environment, you can propagate specific environment variables like this
import os env = Environment(ENV = {'PATH' : os.environ['PATH'], 'HOME' : os.environ['HOME']})
or all environment variables like this
import os env = Environment(ENV = os.environ)
-
This comes at the expense of making your build dependent on the user's environment being set correctly, but it may be more convenient for many configurations.
-
Invoking builds
- Invoking scons as
scons
with no options will build all targets by default. If explicit default targets have been defined using theDefault()
rule, then these will be built instead. - You can always explicitly build all targets by eecuting
scons .
scons subdir1/subdir2
from top level builds everything in subdir2 and below.- And if you're in subdir2, you can use the
-u
flag to tell scons to follow parent directories until it finds and SConstruct file. The target names can then be specified relative to subdir2.
- And if you're in subdir2, you can use the
scons foo bar
builds targetsfoo
andbar
.
Cleaning
scons -c .
will clean in the current directory and below.-c, --clean
and--remove
are synonyms.
Passing variables from cmdline to the script
Specify them on the command line like this:
scons debug=1 .
These variables are available in SConscript
files through the ARGUMENTS
dictionary, and can be used in the SConscript
file(s) to modify the build in any way:
if ARGUMENTS.get('debug', 0): env = Environment(CCFLAGS = '-g') else: env = Environment()
Command line options
In general, scons supports the same command-line options as GNU make, and many of those supported by cons.
- -Q
- Quiet mode. Scons is normally chatty.
- --interactive
- The SConscript files are read once and a scons>>> prompt is printed. Targets may now be rebuilt by typing commands at interactive prompt without having to re-read the SConscript files and re-initialize the dependency graph from scratch.
-n, --just-print, --dry-run, --recon
- Dry run mode.`