26.3. Explicitly Terminating SCons While Reading SConscript Files: the Exit Function

SCons supports an Exit function which can be used to terminate SCons while reading the SConscript files, usually because you've detected a condition under which it doesn't make sense to proceed:

    print("The FUTURE option is not supported yet!")
env = Environment()
% scons -Q FUTURE=1
The FUTURE option is not supported yet!
% scons -Q
cc -o hello.o -c hello.c
cc -o hello hello.o

The Exit function takes as an argument the (numeric) exit status that you want SCons to exit with. If you don't specify a value, the default is to exit with 0, which indicates successful execution.

Note that the Exit function is equivalent to calling the Python sys.exit function (which the it actually calls), but because Exit is a SCons function, you don't have to import the Python sys module to use it.