Sometimes a file depends on another file
that is not detected by an SCons scanner.
For this situation,
SCons allows you to specific explicitly that one file
depends on another file,
and must be rebuilt whenever that file changes.
This is specified using the Depends
method:
hello = Program('hello.c') Depends(hello, 'other_file')
%scons -Q hello
cc -c hello.c -o hello.o cc -o hello hello.o %scons -Q hello
scons: `hello' is up to date. %edit other_file
[CHANGE THE CONTENTS OF other_file] %scons -Q hello
cc -c hello.c -o hello.o cc -o hello hello.o
Note that the dependency
(the second argument to Depends
)
may also be a list of Node objects
(for example, as returned by a call to a Builder):
hello = Program('hello.c') goodbye = Program('goodbye.c') Depends(hello, goodbye)
in which case the dependency or dependencies will be built before the target(s):
% scons -Q hello
cc -c goodbye.c -o goodbye.o
cc -o goodbye goodbye.o
cc -c hello.c -o hello.o
cc -o hello hello.o