Another way to get information from a construction environment. is to use the subst method on a string containing $-expansions of construction variable names. As a simple example, the example from the previous section that used env['CC'] to fetch the value of $CC could also be written as:
env = Environment() print "CC is:", env.subst('$CC')
The real advantage of using subst to expand strings is that construction variables in the result get re-expanded until there are no expansions left in the string. So a simple fetch of a value like $CCCOM:
env = Environment(CCFLAGS = '-DFOO') print "CCCOM is:", env['CCCOM']
Will print the unexpanded value of $CCCOM, showing us the construction variables that still need to be expanded:
% scons -Q CCCOM is: $CC $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES scons: `.' is up to date.
Calling the subst method on $CCOM, however:
env = Environment(CCFLAGS = '-DFOO') print "CCCOM is:", env.subst('$CCCOM')
Will recursively expand all of the $-prefixed construction variables, showing us the final output:
% scons -Q CCCOM is: gcc -DFOO -c -o scons: `.' is up to date.