[Scons-users] clarification on Depends()
Marc Branchaud
marcnarc at xiplink.com
Tue Jun 5 18:27:43 EDT 2018
On 2018-06-05 12:05 AM, Jason Kenny wrote:
> HI,
>
> I just want to clarify behavior of Depends() in SCons.
>
> I have a small sample:
>
> Depends(["hello.c")],["fake.txt"])
>
> Program("hello","hello.c")
>
> If I run this sample “hello” will build. If I change fake.txt, nothing
> will rebuild.
Right. This is because you have nothing that builds hello.c, so SCons
doesn't care that hello.c depends on anything.
But SCons does know how to build hello.o. That knowledge is implicit in
the Program builder. So SCons respects
Depends("hello.o", "fake.txt")
Put another way, SCons only performs actions to build hello.o (and,
ultimately, hello), so it only cares about dependencies for the actions
it undertakes.
You could also use the target returned by the Program builder:
hello_target = Program("hello", "hello.c")
Depends(hello_target, "fake.txt")
This achieves the same thing, and lets you avoid knowing the Program
builder's intermediate artifacts.
M.
> I have a tree like this:
>
> +-hello
>
> | +-hello.o
>
> | | +-hello.c
>
> | | +-fake.txt
>
> | | +-/usr/bin/gcc
>
> | +-/usr/bin/gcc
>
> If I change the sample to this ( depends() is not hello.o vs hello.c)
>
> Depends(["hello.c")],["fake.txt"])
>
> Program("hello","hello.c")
>
> Now when I change fake.txt hello.o will rebuild. The tree here looks like:
>
> +-hello
>
> | +-hello.o
>
> | | +-hello.c
>
> | | +-fake.txt
>
> | | +-/usr/bin/gcc
>
> | +-/usr/bin/gcc
>
> Is this right… I have to know the target of a builder to use? I cannot
> use the source of a builder?
>
> Jason
>
>
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
More information about the Scons-users
mailing list