ninjatool: use constant names for stamp files
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>
This commit is contained in:
parent
e817851479
commit
8d60f37740
|
@ -34,6 +34,7 @@ import os
|
||||||
import re
|
import re
|
||||||
import json
|
import json
|
||||||
import argparse
|
import argparse
|
||||||
|
import hashlib
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,6 +52,9 @@ else:
|
||||||
normpath = os.path.normpath
|
normpath = os.path.normpath
|
||||||
|
|
||||||
|
|
||||||
|
def sha1_text(text):
|
||||||
|
return hashlib.sha1(text.encode()).hexdigest()
|
||||||
|
|
||||||
# ---- lexer and parser ----
|
# ---- lexer and parser ----
|
||||||
|
|
||||||
PATH_RE = r"[^$\s:|]+|\$[$ :]|\$[a-zA-Z0-9_-]+|\$\{[a-zA-Z0-9_.-]+\}"
|
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.build_vars = defaultdict(lambda: dict())
|
||||||
self.rule_targets = defaultdict(lambda: list())
|
self.rule_targets = defaultdict(lambda: list())
|
||||||
self.stamp_targets = defaultdict(lambda: list())
|
self.stamp_targets = defaultdict(lambda: list())
|
||||||
self.num_stamp = defaultdict(lambda: 0)
|
|
||||||
self.all_outs = set()
|
self.all_outs = set()
|
||||||
self.all_ins = set()
|
self.all_ins = set()
|
||||||
self.all_phony = set()
|
self.all_phony = set()
|
||||||
|
@ -903,8 +906,7 @@ class Ninja2Make(NinjaParserEventsWithVars):
|
||||||
if len(out) == 1:
|
if len(out) == 1:
|
||||||
stamp = out[0] + '.stamp'
|
stamp = out[0] + '.stamp'
|
||||||
else:
|
else:
|
||||||
stamp = '%s%d.stamp' %(rule, self.num_stamp[rule])
|
stamp = '%s@%s.stamp' % (rule, sha1_text(targets)[0:11])
|
||||||
self.num_stamp[rule] += 1
|
|
||||||
self.print('%s: %s; @:' % (targets, stamp))
|
self.print('%s: %s; @:' % (targets, stamp))
|
||||||
self.print('%s: %s | %s; ${ninja-command-restat}' % (stamp, inputs, orderonly))
|
self.print('%s: %s | %s; ${ninja-command-restat}' % (stamp, inputs, orderonly))
|
||||||
self.rule_targets[rule].append(stamp)
|
self.rule_targets[rule].append(stamp)
|
||||||
|
|
Loading…
Reference in a new issue