aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/backend/backends.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2017-01-02 11:42:56 -0500
committerGitHub <noreply@github.com>2017-01-02 11:42:56 -0500
commit776b0d9a5f425d0363b8b71933f990183ca4a281 (patch)
tree9cf8d741e90ad1f11778b4d5e3d6aebeab0c8dcb /mesonbuild/backend/backends.py
parent2d2e3b943c6abda1880b4e59fc50e773725be18b (diff)
parent5060e2045bc7637d8364f1ba11323d4d5c4538fb (diff)
downloadmeson-776b0d9a5f425d0363b8b71933f990183ca4a281.zip
meson-776b0d9a5f425d0363b8b71933f990183ca4a281.tar.gz
meson-776b0d9a5f425d0363b8b71933f990183ca4a281.tar.bz2
Merge pull request #1263 from centricular/meson_exe_deterministic
serialise_executable: Name the data file deterministically
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 ac184f0..7e3f936 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -197,15 +197,20 @@ class Backend():
def serialise_executable(self, exe, cmd_args, workdir, env={},
capture=None):
- import uuid
+ import hashlib
# Can't just use exe.name here; it will likely be run more than once
if isinstance(exe, (dependencies.ExternalProgram,
build.BuildTarget, build.CustomTarget)):
basename = exe.name
else:
basename = os.path.basename(exe)
- scratch_file = 'meson_exe_{0}_{1}.dat'.format(basename,
- str(uuid.uuid4())[:8])
+ # Take a digest of the cmd args, env, workdir, and capture. This 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(sorted(env.items())) + str(cmd_args) + str(workdir) + str(capture),
+ encoding='utf-8')
+ digest = hashlib.sha1(data).hexdigest()
+ scratch_file = 'meson_exe_{0}_{1}.dat'.format(basename, digest)
exe_data = os.path.join(self.environment.get_scratch_dir(), scratch_file)
with open(exe_data, 'wb') as f:
if isinstance(exe, dependencies.ExternalProgram):