scons: derived but source files

My build process consists of several steps. One of the intermediate files is actually intended to be edited by the user. But I noticed that when user changes the file, SCons doesn’t re-generate the rest of the build chain.

After diving into the problem, I found what’s wrong. My expectations were wrong. The signature of an intermediate file is derived from the signatures of the source files and build steps. Content of intermediate files doesn’t affect the signature.

Therefore, the problem was reformulated. My task was to force SCons to respect the content of the specific file. I haven’t found easy solution. Finally, I produced the following code:

import SCons.Node.FS
class DerivedButSourceFile(SCons.Node.FS.File):
  def calc_signature(self, calc=None):
    s = self.calc_bsig(calc)
    if self.rexists():
      s = s + '_' + self.calc_csig(calc)
    return s


# env is an environment object
some_file_node = env.fs.Entry('some_file', klass=DerivedButSourceFile)

One Response to “scons: derived but source files”

  1. 123xraz Says:

    Thank you! :)
    I have had a similar problem and altough i already read about
    that type of signatures i did not realize exactly what my problem
    was. My case was solved then with snv.TargetSignatures(‘content’)
    but that may not be applicable in all cases.

Leave a Reply