Commits

Eric Anderson committed a46cd64 Draft

Snapshot: Works as expected, except for the need to mess with the
default environment.

Comments (0)

Files changed (6)

+env = Environment()
+import SCons
+
+def myDecider(dependency, target, prev_ni):
+    
+    # We always have to init the .ext_sig value...
+    dep_ext_sig = dependency.get_ext_sig()
+    if prev_ni is None:
+        print dependency.get_ninfo().__dict__, target, None
+        return True
+    else:
+        print dependency.get_ninfo().__dict__, target, prev_ni.__dict__
+
+    try:
+        prev_ext_sig = prev_ni.ext_sig
+    except AttributeError:
+        print "shit"
+        return True
+    return dep_ext_sig != prev_ext_sig
+
+env.Decider(myDecider)
+
+def sigMaker(f):
+    ninfo = f.get_ninfo()
+    
+    print "bar"
+    ext_sig = "pants"
+    ninfo.ext_sig = ext_sig
+    return ext_sig
+
+SCons.Defaults.DefaultEnvironment().ExtSignature(sigMaker)
+env.ExtSignature(sigMaker)
+print "Just set it for env %s" % repr(env)
+print "default env is %s" % repr(SCons.Defaults.DefaultEnvironment())
+
+b=Builder(action="bash myscript.sh $SOURCE $TARGET")
+env.Append(BUILDERS={'B' : b})
+env.Export()
+
+i=File('myinput.txt')
+x=env.B(['myoutput.txt'],[i])
+print repr(i.rfile().get_ninfo().__dict__)

mydev/myinput.txt

+A line I care about
+#A line I don't care about -- 2012-07-27 16:46:27.551844784-04:00
+Another line I do care about

mydev/myoutput.txt

+Last changed: 2012-07-27 16:46:27.551844784-04:00

mydev/myscript.sh

+#!/bin/bash
+
+NOW=`date --rfc-3339=ns`
+awk "/^[^#]/{print}; /^#/{print \"#A line I don't care about -- $NOW\"}" $1 > tmp.txt
+mv tmp.txt $1
+echo "Last changed: $NOW" > $2

src/engine/SCons/Environment.py

     f = SCons.Defaults.DefaultEnvironment().copy_from_cache
     return f(src, dst)
 
+def default_ext_signature(target):
+    """ Create no extended signature """
+    return None
+
 class Base(SubstitutionEnvironment):
     """Base class for "real" construction Environments.  These are the
     primary objects used to communicate dependency and construction
         # OverrideEnvironment or what have you.
         self.decide_target = default_decide_target
         self.decide_source = default_decide_source
+        self.ext_signature = default_ext_signature
 
         self.copy_from_cache = default_copy_from_cache
 
     def _copy2_from_cache(self, src, dst):
         return self.fs.copy2(src, dst)
 
+    def ExtSignature(self, function):
+        if callable(function):
+            self.ext_signature=function
+        else:
+            raise UserError("ExtSignature parameter must be a function.  Don't know what to do with %s" % repr(function))
+
     def Decider(self, function):
         copy_function = self._copy2_from_cache
         if function in ('MD5', 'content'):

src/engine/SCons/Node/FS.py

 class FileNodeInfo(SCons.Node.NodeInfoBase):
     current_version_id = 1
 
-    field_list = ['csig', 'timestamp', 'size']
+    field_list = ['csig', 'ext_sig', 'timestamp', 'size']
 
     # This should get reset by the FS initialization.
     fs = None
         if csig:
             ninfo.csig = csig
 
+        ext_sig = self.get_ext_sig()
+        ninfo.ext_sig = ext_sig
+
         ninfo.timestamp = self.get_timestamp()
         ninfo.size      = self.get_size()
 
 
         return csig
 
+
+    def get_ext_sig(self):
+        e = self.get_env()
+        f = e.ext_signature
+        v = f(self)
+        print "in env %s %s(self)=%s" % (repr(e), repr(f),repr(v))
+        self.get_ninfo().ext_sig = v
+        return v
+
+
     #
     # DECISION SUBSYSTEM
     #