diff options
author | William Deegan <bill@baddogconsulting.com> | 2018-10-10 14:41:06 (GMT) |
---|---|---|
committer | William Deegan <bill@baddogconsulting.com> | 2018-10-10 14:41:06 (GMT) |
commit | d372089735e398a3dc88b4327d91dae32fdfff32 (patch) | |
tree | f53fe50236a65cc2740c30043fd74066ef653704 | |
parent | 063eea321e3e22003e86cbaf52ef5d1273b35758 (diff) | |
download | SCons-d372089735e398a3dc88b4327d91dae32fdfff32.zip SCons-d372089735e398a3dc88b4327d91dae32fdfff32.tar.gz SCons-d372089735e398a3dc88b4327d91dae32fdfff32.tar.bz2 |
Fix Bug #3212. Using CacheDir with Configure TryCompile with Python 3 was failing because it was yielding a mixture of bytes and strings when generating cachedir signature use to determine file and directory in cachedir to use
-rw-r--r-- | src/engine/SCons/CacheDir.py | 2 | ||||
-rw-r--r-- | src/engine/SCons/Executor.py | 2 | ||||
-rw-r--r-- | src/engine/SCons/Node/FS.py | 5 | ||||
-rw-r--r-- | src/engine/SCons/Node/Python.py | 13 | ||||
-rw-r--r-- | src/engine/SCons/Util.py | 11 |
5 files changed, 31 insertions, 2 deletions
diff --git a/src/engine/SCons/CacheDir.py b/src/engine/SCons/CacheDir.py index ab80808..ab23f31 100644 --- a/src/engine/SCons/CacheDir.py +++ b/src/engine/SCons/CacheDir.py @@ -221,7 +221,9 @@ class CacheDir(object): return None, None sig = node.get_cachedir_bsig() + subdir = sig[:self.config['prefix_len']].upper() + dir = os.path.join(self.path, subdir) return dir, os.path.join(dir, sig) diff --git a/src/engine/SCons/Executor.py b/src/engine/SCons/Executor.py index bce1549..01d01cd 100644 --- a/src/engine/SCons/Executor.py +++ b/src/engine/SCons/Executor.py @@ -450,6 +450,8 @@ class Executor(object, with_metaclass(NoSlotsPyPy)): """Fetch the signature contents. This is the main reason this class exists, so we can compute this once and cache it regardless of how many target or source Nodes there are. + + Returns bytes """ try: return self._memo['get_contents'] diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index bc15064..5dceaa0 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -3382,6 +3382,8 @@ class File(Base): because multiple targets built by the same action will all have the same build signature, and we have to differentiate them somehow. + + Signature should normally be string of hex digits. """ try: return self.cachesig @@ -3391,10 +3393,13 @@ class File(Base): # Collect signatures for all children children = self.children() sigs = [n.get_cachedir_csig() for n in children] + # Append this node's signature... sigs.append(self.get_contents_sig()) + # ...and it's path sigs.append(self.get_internal_path()) + # Merge this all into a single signature result = self.cachesig = SCons.Util.MD5collect(sigs) return result diff --git a/src/engine/SCons/Node/Python.py b/src/engine/SCons/Node/Python.py index 8c47c97..4a62f04 100644 --- a/src/engine/SCons/Node/Python.py +++ b/src/engine/SCons/Node/Python.py @@ -137,6 +137,10 @@ class Value(SCons.Node.Node): return contents def get_contents(self): + """ + Get contents for signature calculations. + :return: bytes + """ text_contents = self.get_text_contents() try: return text_contents.encode() @@ -155,12 +159,17 @@ class Value(SCons.Node.Node): def get_csig(self, calc=None): """Because we're a Python value node and don't have a real timestamp, we get to ignore the calculator and just use the - value contents.""" + value contents. + + Returns string. Ideally string of hex digits. (Not bytes) + """ try: return self.ninfo.csig except AttributeError: pass - contents = self.get_contents() + + contents = self.get_text_contents() + self.get_ninfo().csig = contents return contents diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 424c694..b568ce5 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -1459,6 +1459,11 @@ else: md5 = True def MD5signature(s): + """ + Generate a String of Hex digits representing the md5 signature of the string + :param s: either string or bytes. Normally should be bytes + :return: String of hex digits + """ m = hashlib.md5() try: @@ -1469,6 +1474,11 @@ else: return m.hexdigest() def MD5filesignature(fname, chunksize=65536): + """ + :param fname: + :param chunksize: + :return: String of Hex digits + """ m = hashlib.md5() f = open(fname, "rb") while True: @@ -1479,6 +1489,7 @@ else: f.close() return m.hexdigest() + def MD5collect(signatures): """ Collects a list of signatures into an aggregate signature. |