diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-07-29 12:35:12 +0100 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-07-29 12:35:12 +0100 |
commit | d66eb16816395eb834689b833ede585f1f63fa22 (patch) | |
tree | 80594e1e1ad6919d5275d3092f803270881fb976 /buildstream/element.py | |
parent | 0a656e9500654c247d79bfe3293a2fe16dda9d2e (diff) | |
download | buildstream-d66eb16816395eb834689b833ede585f1f63fa22.tar.gz |
element.py: Added strict_rebuild class attribute
This allows plugin types to declare that their instances
must be rebuilt when their dependencies change in non-strict
build mode.
This is specifically for non-strict builds and allows appropriate
reassembly of composition elements, which take their dependencies
as verbatim input to create output.
Diffstat (limited to 'buildstream/element.py')
-rw-r--r-- | buildstream/element.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/buildstream/element.py b/buildstream/element.py index e43e705d6..d0bbb79c8 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -87,6 +87,11 @@ class Element(Plugin): __defaults = {} # The defaults from the yaml file and project __defaults_set = False # Flag, in case there are no defaults at all + strict_rebuild = False + """Whether to rebuild this element in non strict mode if + any of the dependencies have changed. + """ + def __init__(self, context, project, artifacts, meta): super().__init__(meta.name, context, project, meta.provenance, "element") @@ -894,9 +899,16 @@ class Element(Plugin): # Calculate weak cache key # Weak cache key includes names of direct build dependencies # but does not include keys of dependencies. - dependencies = [ - e.name for e in self.dependencies(Scope.BUILD, recurse=False) - ] + if self.strict_rebuild: + dependencies = [ + e._get_cache_key(strength=_KeyStrength.WEAK) + for e in self.dependencies(Scope.BUILD, recurse=False) + ] + else: + dependencies = [ + e.name for e in self.dependencies(Scope.BUILD, recurse=False) + ] + self.__weak_cache_key = self.__calculate_cache_key(dependencies) if strength == _KeyStrength.STRONG: |