8.2. Merging Options While Creating Environment: the parse_flags Parameter

It is also possible to merge construction variable values from arguments given to the Environment call itself. If the parse_flags keyword argument is given, its value is distributed to construction variables in the new environment in the same way as described for the MergeFlags method. This also works when calling env.Clone, as well as in overrides to builder methods (see Section 7.2.14, “Overriding Construction Variable Settings”).

env = Environment(parse_flags="-I/opt/include -L/opt/lib -lfoo")
for k in ('CPPPATH', 'LIBPATH', 'LIBS'):
    print("%s:" % k, env.get(k))
env.Program("f1.c")
   
% scons -Q
CPPPATH: ['/opt/include']
LIBPATH: ['/opt/lib']
LIBS: ['foo']
cc -o f1.o -c -I/opt/include f1.c
cc -o f1 f1.o -L/opt/lib -lfoo