diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2016-12-30 18:57:02 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2016-12-31 21:59:02 +0530 |
commit | 5060e2045bc7637d8364f1ba11323d4d5c4538fb (patch) | |
tree | 5872046a399dc888fc5da8516af5d435abb0bb97 | |
parent | 3445beb00b0d779a73f0d541769f85a6a6b239aa (diff) | |
download | meson-5060e2045bc7637d8364f1ba11323d4d5c4538fb.zip meson-5060e2045bc7637d8364f1ba11323d4d5c4538fb.tar.gz meson-5060e2045bc7637d8364f1ba11323d4d5c4538fb.tar.bz2 |
serialise_executable: Name the data file deterministically
Closes #1062
-rw-r--r-- | mesonbuild/backend/backends.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index cde8d70..9cb44c9 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): |