Does scons customized decider function require to be class member?
<p>I searched from internet on how to write our own decider function in scons, as to how/when a source file should be rebuilt, like this:</p>

<pre><code>Program('hello.c')
def decide_if_changed(dependency,target,prev_ni):
 if self.get_timestamp()!=prev_ni.timestamp:
  dep=str(dependency)
  tgt=str(target)
  if specific_part_of_file_has_changed(dep,tgt):
   return true;
 return false;
Decider(decide_if_changed)
</code></pre>

<p>I've got a hello.c, no problem, but when running scons it prompts a python error:</p>

<pre><code>$ scons -Q
scons: *** [o.o] NameError : global name 'self' is not defined
</code></pre>

<p>self is the python keyword to mention a class member function. Here in SContruct file, there's a class but just a decide_if_changed function. Question:</p>

<blockquote>
  <p>Do I have to add a class here? Why it prompts python error saying 'self' is not defined?</p>
  
  <p>This example script a function call of specific_part_of_file_has_changed, is it a scons's own file that can be called by any pythong statement?</p>
</blockquote>

<p>The name <code>self</code> is not defined because there is a typo in the documentation. The second line of the decider should read:</p>

<pre><code>if dependency.get_timestamp()!=prev_ni.timestamp:
</code></pre>

<p>Implementing the <code>specific_part_of_file_has_changed()</code> method (or any similar series of steps to determine whether the file has changed) is completely up to you...the "customer". After all you do want a "custom decider", right? ;)</p>

python class member scons self