I've added the option -fdiagnostics-color
for GCC in my build.
It only changes colors in error commands so I don't want the targets to rebuild when this option is the only thing that has changed.
For example with this SConstruct
:
env = Environment()
if 'color' in ARGUMENTS:
env.Append(CPPFLAGS=f'-fdiagnostics-color={ARGUMENTS["color"]}')
env.Program('main.cc')
Calling scons color=never
and then scons color=always
will cause the target file to be built 2 times.
Can I somehow tell SCons to not rebuild the target if only this option has changed?
SCons indeed has a pair of markers $(
and $)
.
Everything that you'll put between them will be ignored while evaluating if a target needs to be rebuilt.
(It works only if the string with the markers is passed to the function subst
but this happens to almost every string, including ones passed to Action
s, Command
s and construction variables.)
env = Environment()
if 'color' in ARGUMENTS:
env.Append(CPPFLAGS=f'$( -fdiagnostics-color={ARGUMENTS["color"]} $)')
env.Program('main.cc')