The Ignore Method
Sometimes it makes sense
to not rebuild a program,
even if a dependency file changes.
In this case,
you would tell SCons specifically
to ignore a dependency as follows:
hello = Program('hello.c')
Ignore(hello, 'hello.h')
|
% scons -Q hello
cc -c -o hello.o hello.c
cc -o hello hello.o
% scons -Q hello
scons: `hello' is up to date.
% edit hello.h
[CHANGE THE CONTENTS OF hello.h]
% scons -Q hello
scons: `hello' is up to date.
Now, the above example is a little contrived,
because it's hard to imagine a real-world situation
where you wouldn't to rebuild hello
if the hello.h file changed.
A more realistic example
might be if the hello
program is being built in a
directory that is shared between multiple systems
that have different copies of the
stdio.h include file.
In that case,
SCons would notice the differences between
the different systems' copies of stdio.h
and would rebuild hello
each time you change systems.
You could avoid these rebuilds as follows:
env = Environment()
hello = env.Program('hello.c')
env.Ignore(hello, '/usr/include/stdio.h')
|