summaryrefslogtreecommitdiffstats
path: root/SCons/Node
diff options
context:
space:
mode:
authorAdam Gross <grossag@vmware.com>2020-06-22 19:10:43 (GMT)
committerAdam Gross <grossag@vmware.com>2020-08-04 13:07:42 (GMT)
commit1fa19ef5eeb2b37c54d291a5aa5858b7b91bbb5d (patch)
tree34f1d076367301728471aa896e4a14e8082d5910 /SCons/Node
parent05e2dc91e95507b3c0f1bd42b93f41c0c8733371 (diff)
downloadSCons-1fa19ef5eeb2b37c54d291a5aa5858b7b91bbb5d.zip
SCons-1fa19ef5eeb2b37c54d291a5aa5858b7b91bbb5d.tar.gz
SCons-1fa19ef5eeb2b37c54d291a5aa5858b7b91bbb5d.tar.bz2
Add support for overriding the default hash format
This change adds support for a new --hash-format parameter that can be used to override the default hash format used by SCons. The default remains MD5, but this allows consumers to opt into SHA1, SHA256, or any other hash algorithm offered by their implementation of hashlib.
Diffstat (limited to 'SCons/Node')
-rw-r--r--SCons/Node/Alias.py4
-rw-r--r--SCons/Node/FS.py20
-rw-r--r--SCons/Node/__init__.py8
3 files changed, 16 insertions, 16 deletions
diff --git a/SCons/Node/Alias.py b/SCons/Node/Alias.py
index 55d94f9..00e3726 100644
--- a/SCons/Node/Alias.py
+++ b/SCons/Node/Alias.py
@@ -37,7 +37,7 @@ import collections
import SCons.Errors
import SCons.Node
import SCons.Util
-from SCons.Util import MD5signature
+from SCons.Util import hash_signature
class AliasNameSpace(collections.UserDict):
def Alias(self, name, **kw):
@@ -167,7 +167,7 @@ class Alias(SCons.Node.Node):
pass
contents = self.get_contents()
- csig = MD5signature(contents)
+ csig = hash_signature(contents)
self.get_ninfo().csig = csig
return csig
diff --git a/SCons/Node/FS.py b/SCons/Node/FS.py
index ad9dd6f..044b3b6 100644
--- a/SCons/Node/FS.py
+++ b/SCons/Node/FS.py
@@ -53,7 +53,7 @@ import SCons.Node
import SCons.Node.Alias
import SCons.Subst
import SCons.Util
-from SCons.Util import MD5signature, MD5filesignature, MD5collect
+from SCons.Util import hash_signature, hash_file_signature, hash_collect
import SCons.Warnings
from SCons.Debug import Trace
@@ -1870,7 +1870,7 @@ class Dir(Base):
node is called which has a child directory, the child
directory should return the hash of its contents."""
contents = self.get_contents()
- return MD5signature(contents)
+ return hash_signature(contents)
def do_duplicate(self, src):
pass
@@ -2635,7 +2635,7 @@ class File(Base):
BuildInfo = FileBuildInfo
# Although the command-line argument is in kilobytes, this is in bytes.
- md5_chunksize = 65536
+ hash_chunksize = 65536
def diskcheck_match(self):
diskcheck_match(self, self.isdir,
@@ -2734,10 +2734,10 @@ class File(Base):
Compute and return the MD5 hash for this file.
"""
if not self.rexists():
- return MD5signature('')
+ return hash_signature('')
fname = self.rfile().get_abspath()
try:
- cs = MD5filesignature(fname, chunksize=File.md5_chunksize)
+ cs = hash_file_signature(fname, chunksize=File.hash_chunksize)
except EnvironmentError as e:
if not e.filename:
e.filename = fname
@@ -3223,7 +3223,7 @@ class File(Base):
if csig is None:
try:
- if self.get_size() < File.md5_chunksize:
+ if self.get_size() < File.hash_chunksize:
contents = self.get_contents()
else:
csig = self.get_content_hash()
@@ -3235,7 +3235,7 @@ class File(Base):
csig = ''
else:
if not csig:
- csig = SCons.Util.MD5signature(contents)
+ csig = SCons.Util.hash_signature(contents)
ninfo.csig = csig
@@ -3624,7 +3624,7 @@ class File(Base):
cachedir, cachefile = self.get_build_env().get_CacheDir().cachepath(self)
if not self.exists() and cachefile and os.path.exists(cachefile):
- self.cachedir_csig = MD5filesignature(cachefile, File.md5_chunksize)
+ self.cachedir_csig = MD5filesignature(cachefile, File.hash_chunksize)
else:
self.cachedir_csig = self.get_csig()
return self.cachedir_csig
@@ -3644,7 +3644,7 @@ class File(Base):
executor = self.get_executor()
- result = self.contentsig = MD5signature(executor.get_contents())
+ result = self.contentsig = hash_signature(executor.get_contents())
return result
def get_cachedir_bsig(self):
@@ -3675,7 +3675,7 @@ class File(Base):
sigs.append(self.get_internal_path())
# Merge this all into a single signature
- result = self.cachesig = MD5collect(sigs)
+ result = self.cachesig = hash_collect(sigs)
return result
default_fs = None
diff --git a/SCons/Node/__init__.py b/SCons/Node/__init__.py
index f7d9289..d64a468 100644
--- a/SCons/Node/__init__.py
+++ b/SCons/Node/__init__.py
@@ -58,7 +58,7 @@ from SCons.Debug import logInstanceCreation
import SCons.Executor
import SCons.Memoize
import SCons.Util
-from SCons.Util import MD5signature
+from SCons.Util import hash_signature
from SCons.Debug import Trace
@@ -1181,7 +1181,7 @@ class Node(object, metaclass=NoSlotsPyPy):
if self.has_builder():
binfo.bact = str(executor)
- binfo.bactsig = MD5signature(executor.get_contents())
+ binfo.bactsig = hash_signature(executor.get_contents())
if self._specific_sources:
sources = [s for s in self.sources if s not in ignore_set]
@@ -1219,7 +1219,7 @@ class Node(object, metaclass=NoSlotsPyPy):
return self.ninfo.csig
except AttributeError:
ninfo = self.get_ninfo()
- ninfo.csig = MD5signature(self.get_contents())
+ ninfo.csig = hash_signature(self.get_contents())
return self.ninfo.csig
def get_cachedir_csig(self):
@@ -1510,7 +1510,7 @@ class Node(object, metaclass=NoSlotsPyPy):
if self.has_builder():
contents = self.get_executor().get_contents()
- newsig = MD5signature(contents)
+ newsig = hash_signature(contents)
if bi.bactsig != newsig:
if t: Trace(': bactsig %s != newsig %s' % (bi.bactsig, newsig))
result = True