diff options
author | Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> | 2012-04-18 16:49:24 +0100 |
---|---|---|
committer | Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> | 2012-04-18 16:49:24 +0100 |
commit | 105c0dbbd14626a832ebc036c02bc0c9c60e43bc (patch) | |
tree | 9e9398e9e4d4bc8da54a63094142f941b881419e /morphlib/cachekeycomputer.py | |
parent | 605e21914f8c9536ff42ca31043b26200dab85e2 (diff) | |
download | morph-105c0dbbd14626a832ebc036c02bc0c9c60e43bc.tar.gz |
Remove BuildGraph, compute cache keys based on Artifacts.
With this commit, the ArtifactResolver no longer computes the cache keys
when creating Artifact objects. This will have to happen as a
post-resolving step (e.g. prior to building or checking whether a local
or remote artifact cache has any of the resolved artifacts).
The CacheKeyComputer now takes an Artifact object and computes the cache
keys using its dependencies.
BuildGraph is no longer needed for the CacheKeyComputer unit tests.
Diffstat (limited to 'morphlib/cachekeycomputer.py')
-rw-r--r-- | morphlib/cachekeycomputer.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/morphlib/cachekeycomputer.py b/morphlib/cachekeycomputer.py index 0a782185..28406b55 100644 --- a/morphlib/cachekeycomputer.py +++ b/morphlib/cachekeycomputer.py @@ -18,7 +18,8 @@ import hashlib import morphlib -class CacheKeyComputer(): + +class CacheKeyComputer(object): def __init__(self, build_env): self._build_env = build_env @@ -29,8 +30,8 @@ class CacheKeyComputer(): "TOOLCHAIN_TARGET", "PREFIX", "BOOTSTRAP", "CFLAGS")]) - def compute_key(self, source): - return self._hash_id(self.get_cache_id(source)) + def compute_key(self, artifact): + return self._hash_id(self.get_cache_id(artifact)) def _hash_id(self, cache_id): sha = hashlib.sha256() @@ -59,20 +60,19 @@ class CacheKeyComputer(): for item in tup: self._hash_thing(sha, item) - def get_cache_id(self, source): + def get_cache_id(self, artifact): try: - return self._calculated[source] + return self._calculated[artifact] except KeyError: - cacheid = self._calculate(source) - self._calculated[source] = cacheid + cacheid = self._calculate(artifact) + self._calculated[artifact] = cacheid return cacheid - def _calculate(self, source): + def _calculate(self, artifact): return { 'arch': self._build_env.arch, 'env': self._filterenv(self._build_env.env), - 'ref': source.sha1, - 'filename': source.filename, - 'kids': [self.get_cache_id(dependency) - for dependency in source.dependencies], + 'ref': artifact.source.sha1, + 'filename': artifact.source.filename, + 'kids': [self.get_cache_id(x) for x in artifact.dependencies] } |