Index: mojo/tools/mopy/transitive_hash.py |
diff --git a/mojo/tools/mopy/transitive_hash.py b/mojo/tools/mopy/transitive_hash.py |
index 6864ae394dcd14e866c80b590037459b7af993aa..48b6a60b21898fafd36a8c5a7bd41ef18168a3fb 100644 |
--- a/mojo/tools/mopy/transitive_hash.py |
+++ b/mojo/tools/mopy/transitive_hash.py |
@@ -2,7 +2,9 @@ |
# Use of this source code is governed by a BSD-style license that can be |
# found in the LICENSE file. |
+import hashlib |
import logging |
+import platform |
import subprocess |
import sys |
@@ -27,16 +29,26 @@ 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) |
- rv = subprocess.check_output(['sha256sum', '-b', filename]).split(None, 1)[0] |
- _logging.debug(" => %s", rv) |
- return rv |
+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 |
def _get_dependencies(filename): |
"""Returns a list of filenames for files that the given file depends on.""" |
+ if platform.system() == 'Windows': |
+ # There's no ldd on Windows. We can try to bundle or require depends, but |
+ # given that we're not supporting component build this seems low priority. |
+ return [] |
_logging.debug("Getting dependencies for %s ...", filename) |
lines = subprocess.check_output(['ldd', filename]).splitlines() |
rv = [] |