| Index: mojo/tools/mopy/transitive_hash.py
|
| diff --git a/mojo/tools/mopy/transitive_hash.py b/mojo/tools/mopy/transitive_hash.py
|
| index 48b6a60b21898fafd36a8c5a7bd41ef18168a3fb..c7c237528fcbe119cf0315fde72b8e203d125c53 100644
|
| --- a/mojo/tools/mopy/transitive_hash.py
|
| +++ b/mojo/tools/mopy/transitive_hash.py
|
| @@ -29,17 +29,17 @@ def _memoize(f):
|
| return Memoize().__getitem__
|
|
|
| @_memoize
|
| -def _file_hash(filename):
|
| - """Returns a string representing the hash of the given file."""
|
| - _logging.debug("Hashing %s ...", filename)
|
| - with open(filename, mode='rb') as f:
|
| - m = hashlib.sha256()
|
| - while True:
|
| - block = f.read(4096)
|
| - if not block:
|
| - break
|
| - m.update(block)
|
| - _logging.debug(" => %s", m.hexdigest())
|
| +def _file_hash(filename):
|
| + """Returns a string representing the hash of the given file."""
|
| + _logging.debug("Hashing %s ...", filename)
|
| + with open(filename, mode='rb') as f:
|
| + m = hashlib.sha256()
|
| + while True:
|
| + block = f.read(4096)
|
| + if not block:
|
| + break
|
| + m.update(block)
|
| + _logging.debug(" => %s", m.hexdigest())
|
| return m.hexdigest()
|
|
|
| @_memoize
|
| @@ -61,7 +61,7 @@ def _get_dependencies(filename):
|
| _logging.debug(" => %s", rv)
|
| return rv
|
|
|
| -def transitive_hash(filename):
|
| +def transitive_hash(filename, transitive=True):
|
| """Returns a string that represents the "transitive" hash of the given
|
| file. The transitive hash is a hash of the file and all the shared libraries
|
| on which it depends (done in an order-independent way)."""
|
| @@ -75,7 +75,8 @@ def transitive_hash(filename):
|
| continue
|
| _logging.debug("Haven't seen %s (%s) ...", current_filename, current_hash)
|
| hashes.add(current_hash)
|
| - to_hash.extend(_get_dependencies(current_filename))
|
| + if transitive:
|
| + to_hash.extend(_get_dependencies(current_filename))
|
| return sha256('|'.join(sorted(hashes))).hexdigest()
|
|
|
| def main(argv):
|
|
|