Search code examples
scons

How to make a dependency on a command line parameter


I have a command line variable (text string) which I inject into a file (the target file) using a builder. The question is, how to I trigger the building of the target file when the value of the the command line string changes?

One option might be to write the string to a text file, but I'd need to write that text file every time I build. Is there a cleaner way?


Solution

  • Not sure whether this really qualifies as "cleaner" way, but you can create a Value node:

    mynode = env.Value(my_var_string)
    

    and then use the Depends() method to let your target depend on this Value node:

    env.Depends(final_target, mynode)
    

    Please check the MAN page ( http://www.scons.org/doc/production/HTML/scons-man.html ) for a complete description of the Value method.