aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/backend/backends.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2021-10-29 18:25:22 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2021-10-29 18:25:22 +0300
commit0340dfaa54d84518c15d01e1544bae4c29715c4e (patch)
treec9b577311228e3df9beb6e64cde481976077b68c /mesonbuild/backend/backends.py
parent37ea997ca4e74360bfa31748c0e3b408b85591e3 (diff)
downloadmeson-deterministichash.zip
meson-deterministichash.tar.gz
meson-deterministichash.tar.bz2
Make environment objects hash deterministically.deterministichash
Diffstat (limited to 'mesonbuild/backend/backends.py')
-rw-r--r--mesonbuild/backend/backends.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index 3d8654e..1d04c91 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -648,9 +648,14 @@ class Backend:
# avoids collisions and also makes the name deterministic over
# regenerations which avoids a rebuild by Ninja because the cmdline
# stays the same.
- data = bytes(str(es.env) + str(es.cmd_args) + str(es.workdir) + str(capture) + str(feed),
- encoding='utf-8')
- digest = hashlib.sha1(data).hexdigest()
+ hasher = hashlib.sha1()
+ if es.env:
+ es.env.hash(hasher)
+ hasher.update(bytes(str(es.cmd_args), encoding='utf-8'))
+ hasher.update(bytes(str(es.workdir), encoding='utf-8'))
+ hasher.update(bytes(str(capture), encoding='utf-8'))
+ hasher.update(bytes(str(feed), encoding='utf-8'))
+ digest = hasher.hexdigest()
scratch_file = f'meson_exe_{basename}_{digest}.dat'
exe_data = os.path.join(self.environment.get_scratch_dir(), scratch_file)
with open(exe_data, 'wb') as f: