[Scons-users] Use target srcnode path for cache signature

Mikael Arvids mikael.arvids at autoliv.com
Fri Dec 19 07:34:53 EST 2014


Hi,

Currently the target files cached by scons cannot be shared among builds with different variant directories. The reason is that the path to the target file is used for signature calculation, and this path includes the variant directory. I am currently monkey patching the File class in order to base the target path in the signature to the corresponding path in the source directory instead using srcnode(), and also changed the default compiler action to exclude the output file from the signature. Are there any case where this would pose a problem or would it be possible to include this change in scons? An alternative would be to include this behavior based on an option instead.

diff --git a/scons-local-2.3.4/SCons/Node/FS.py b/scons-local-2.3.4/SCons/Node/FS.py
index 4b95613..ab1ab9f 100644
--- a/scons-local-2.3.4/SCons/Node/FS.py
+++ b/scons-local-2.3.4/SCons/Node/FS.py
@@ -3229,7 +3229,7 @@ class File(Base):
         # Append this node's signature...
         sigs.append(self.get_contents_sig())
         # ...and it's path
-        sigs.append(self.path)
+        sigs.append(self.srcnode().path)
         # Merge this all into a single signature
         result = self.cachesig = SCons.Util.MD5collect(sigs)
         return result

diff --git a/scons-local-2.3.4/SCons/Tool/cc.py b/scons-local-2.3.4/SCons/Tool/cc.py
index 12838cb..b5f4751 100644
--- a/scons-local-2.3.4/SCons/Tool/cc.py
+++ b/scons-local-2.3.4/SCons/Tool/cc.py
@@ -81,10 +81,10 @@ def generate(env):
     if 'CC' not in env:
         env['CC']    = env.Detect(compilers) or compilers[0]
     env['CFLAGS']    = SCons.Util.CLVar('')
-    env['CCCOM']     = '$CC -o $TARGET -c $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES'
+    env['CCCOM']     = '$CC $( -o $TARGET $) -c $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES'
     env['SHCC']      = '$CC'
     env['SHCFLAGS'] = SCons.Util.CLVar('$CFLAGS')
-    env['SHCCCOM']   = '$SHCC -o $TARGET -c $SHCFLAGS $SHCCFLAGS $_CCCOMCOM $SOURCES'
+    env['SHCCCOM']   = '$SHCC $( -o $TARGET $) -c $SHCFLAGS $SHCCFLAGS $_CCCOMCOM $SOURCES'

     env['CPPDEFPREFIX']  = '-D'
     env['CPPDEFSUFFIX']  = ''

Best regards
Mikael Arvids

***************************************************************
Consider the environment before printing this message.

To read Autoliv's Information and Confidentiality Notice, follow this link:
http://www.autoliv.com/disclaimer.html
***************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20141219/a3f3c0aa/attachment.html>


More information about the Scons-users mailing list