summaryrefslogtreecommitdiff
path: root/SCons
diff options
context:
space:
mode:
authorAdam Gross <grossag@vmware.com>2020-11-12 08:47:47 -0500
committerAdam Gross <grossag@vmware.com>2020-11-12 08:47:47 -0500
commita28a7fed0cd8006756e0984478709aea5f9653a9 (patch)
tree0fe9f7da19d375c90494b66c77831876811048af /SCons
parente90c3fc562412a8ee18e14458c2322874aafee6c (diff)
downloadscons-git-a28a7fed0cd8006756e0984478709aea5f9653a9.tar.gz
Change the default sconsign DB file name if the hash is overridden
This was requested in the code review. The sconsign database file name is still .sconsign.dblite if the hash format is not overridden, but if it is, the name will be something like .sconsign_sha256.dblite.
Diffstat (limited to 'SCons')
-rw-r--r--SCons/SConsign.py10
-rw-r--r--SCons/Util.py18
2 files changed, 24 insertions, 4 deletions
diff --git a/SCons/SConsign.py b/SCons/SConsign.py
index 8e3ebf4d7..78ff88890 100644
--- a/SCons/SConsign.py
+++ b/SCons/SConsign.py
@@ -52,12 +52,20 @@ sig_files = []
# extension the underlying DB module will add).
DataBase = {}
DB_Module = SCons.dblite
-DB_Name = ".sconsign"
+DB_Name = None
DB_sync_list = []
def Get_DataBase(dir):
global DataBase, DB_Module, DB_Name
+
+ if DB_Name is None:
+ hash_format = SCons.Util.get_hash_format()
+ if hash_format is None:
+ DB_Name = ".sconsign"
+ else:
+ DB_Name = ".sconsign_%s" % hash_format
+
top = dir.fs.Top
if not os.path.isabs(DB_Name) and top.repositories:
mode = "c"
diff --git a/SCons/Util.py b/SCons/Util.py
index 053c5de37..0422e6024 100644
--- a/SCons/Util.py
+++ b/SCons/Util.py
@@ -1468,8 +1468,19 @@ def AddMethod(obj, function, name=None):
setattr(obj, name, method)
-# Default hash function. SCons-internal.
+# Default hash function and format. SCons-internal.
_hash_function = None
+_hash_format = None
+
+
+def get_hash_format():
+ """
+ Retrieves the hash format or None if not overridden. A return value of None
+ does not guarantee that MD5 is being used; instead, it means that the
+ default precedence order documented in SCons.Util.set_hash_format is
+ respected.
+ """
+ return _hash_format
def set_hash_format(hash_format):
@@ -1480,8 +1491,9 @@ def set_hash_format(hash_format):
Currently the default behavior is to use the first available format of
the following options: MD5, SHA1, SHA256.
"""
- global _hash_function
+ global _hash_format, _hash_function
+ _hash_format = hash_format
if hash_format:
hash_format_lower = hash_format.lower()
_hash_function = getattr(hashlib, hash_format_lower, None)
@@ -1513,7 +1525,7 @@ def set_hash_format(hash_format):
# TODO: Should this go somewhere else? Is this unnecessary? Case #1 could be
# handled in the TestCmd module, but I was worried about breaking people
# who mischievously calls get_csig() during startup.
-set_hash_format('md5')
+set_hash_format(None)
def _get_hash_object(hash_format):