[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 09/39] ninjatool: use constant names for stamp files
From: |
Paolo Bonzini |
Subject: |
[PATCH 09/39] ninjatool: use constant names for stamp files |
Date: |
Wed, 2 Sep 2020 08:58:47 -0400 |
Numbering files according to rules causes confusion, because
CUSTOM_COMMAND3.stamp from a previous build might represent
completely different targets after Makefile.ninja is regenerated.
As a result, the new targets are not rebuilt and compilation
fails.
Use the targets to build a SHA1 hash; the chances for collision
are one in 2^24 even with a 12-character prefix of the hash.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
scripts/ninjatool.py | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/scripts/ninjatool.py b/scripts/ninjatool.py
index ba6bd9a2a6..627a1cab45 100755
--- a/scripts/ninjatool.py
+++ b/scripts/ninjatool.py
@@ -34,6 +34,7 @@ import os
import re
import json
import argparse
+import hashlib
import shutil
@@ -51,6 +52,9 @@ else:
normpath = os.path.normpath
+def sha1_text(text):
+ return hashlib.sha1(text.encode()).hexdigest()
+
# ---- lexer and parser ----
PATH_RE = r"[^$\s:|]+|\$[$ :]|\$[a-zA-Z0-9_-]+|\$\{[a-zA-Z0-9_.-]+\}"
@@ -767,7 +771,6 @@ class Ninja2Make(NinjaParserEventsWithVars):
self.build_vars = defaultdict(lambda: dict())
self.rule_targets = defaultdict(lambda: list())
self.stamp_targets = defaultdict(lambda: list())
- self.num_stamp = defaultdict(lambda: 0)
self.all_outs = set()
self.all_ins = set()
self.all_phony = set()
@@ -903,8 +906,7 @@ class Ninja2Make(NinjaParserEventsWithVars):
if len(out) == 1:
stamp = out[0] + '.stamp'
else:
- stamp = '%s%d.stamp' %(rule, self.num_stamp[rule])
- self.num_stamp[rule] += 1
+ stamp = '%s@%s.stamp' % (rule, sha1_text(targets)[0:11])
self.print('%s: %s; @:' % (targets, stamp))
self.print('%s: %s | %s; ${ninja-command-restat}' % (stamp,
inputs, orderonly))
self.rule_targets[rule].append(stamp)
--
2.26.2
- [PATCH 05/39] mtest2make: unify tests that appear in multiple suites, (continued)
- [PATCH 05/39] mtest2make: unify tests that appear in multiple suites, Paolo Bonzini, 2020/09/02
- [PATCH 15/39] tests: qga has virtio-serial by default when host has it, Paolo Bonzini, 2020/09/02
- [PATCH 12/39] meson: declare tasn1 dependency, Paolo Bonzini, 2020/09/02
- [PATCH 10/39] meson: fix libqos linking, Paolo Bonzini, 2020/09/02
- [PATCH 21/39] tests: do not print benchmark output to stdout, Paolo Bonzini, 2020/09/02
- [PATCH 23/39] tests/migration/stress: remove unused exit_success, Paolo Bonzini, 2020/09/02
- [PATCH 24/39] meson: fix migration/stress compilation with glibc>=2.30, Paolo Bonzini, 2020/09/02
- [PATCH 19/39] meson: convert vhost-user-bridge, Paolo Bonzini, 2020/09/02
- [PATCH 20/39] meson: convert atomic*-bench, Paolo Bonzini, 2020/09/02
- [PATCH 13/39] meson: declare keyutils dependency, Paolo Bonzini, 2020/09/02
- [PATCH 09/39] ninjatool: use constant names for stamp files,
Paolo Bonzini <=
- [PATCH 18/39] meson: remove old socket_scm_helper rule, Paolo Bonzini, 2020/09/02
- [PATCH 17/39] meson: move keyutils dependency check, Paolo Bonzini, 2020/09/02
- [PATCH 04/39] mtest2make: hide output of successful tests, Paolo Bonzini, 2020/09/02
- [PATCH 29/39] Makefile: inline the relevant parts of rules.mak, Paolo Bonzini, 2020/09/02
- [PATCH 26/39] configure: remove dead code for in-tree builds, Paolo Bonzini, 2020/09/02
- [PATCH 31/39] configure: move C++ compiler handling to meson, Paolo Bonzini, 2020/09/02
- [PATCH 22/39] meson: convert the speed tests, Paolo Bonzini, 2020/09/02
- [PATCH 25/39] meson: convert migration/initrd-stress, Paolo Bonzini, 2020/09/02
- [PATCH 32/39] meson: keep all compiler flags detection together, Paolo Bonzini, 2020/09/02
- [PATCH 34/39] configure: remove unnecessary libm test, Paolo Bonzini, 2020/09/02