diff options
author | Sander Striker <s.striker@striker.nl> | 2020-07-10 23:55:56 +0200 |
---|---|---|
committer | Sander Striker <s.striker@striker.nl> | 2020-07-10 23:57:59 +0200 |
commit | ed54c7322009cfa197b69dd9e7a8a506235bf3d2 (patch) | |
tree | 1f2d85489760fb95192db7d892197c9b83285a1d | |
parent | 7ff7fb5cde1b491c2e2a321b705d695f48980cfe (diff) | |
download | buildstream-sstriker-never-cache-buildtrees.tar.gz |
Add mechanism for elements to opt-out of buildtrees.sstriker-never-cache-buildtrees
* src/buildstream/element.py
(Element.BST_NEVER_CACHE_BUILDTREES): New class variable to indicate whether
buildtrees are prohibited.
(Element._assemble, Element._cache_artifact): Take BST_NEVER_CACHE_BUILDTREES
into account
-rw-r--r-- | src/buildstream/element.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/buildstream/element.py b/src/buildstream/element.py index 6a0fa5fab..cdf3ae6f2 100644 --- a/src/buildstream/element.py +++ b/src/buildstream/element.py @@ -195,6 +195,10 @@ class Element(Plugin): """Whether the element produces an artifact when built. """ + BST_NEVER_CACHE_BUILDTREES = False + """Whether the element prohibits caching of buildtrees. + """ + def __init__(self, context: "Context", project: "Project", meta: "MetaElement", plugin_conf: Dict[str, Any]): self.__cache_key_dict = None # Dict for cache key calculation @@ -1576,7 +1580,10 @@ class Element(Plugin): # This allows the remote execution sandbox to skip buildtree # download when it's not needed. buildroot = self.get_variable("build-root") - cache_buildtrees = context.cache_buildtrees + if self.BST_NEVER_CACHE_BUILDTREES: + cache_buildtrees = _CacheBuildTrees.NEVER + else: + cache_buildtrees = context.cache_buildtrees if cache_buildtrees != _CacheBuildTrees.NEVER: always_cache_buildtrees = cache_buildtrees == _CacheBuildTrees.ALWAYS sandbox._set_build_directory(buildroot, always=always_cache_buildtrees) @@ -1634,7 +1641,10 @@ class Element(Plugin): sandbox_build_dir = None sourcesvdir = None - cache_buildtrees = context.cache_buildtrees + if self.BST_NEVER_CACHE_BUILDTREES: + cache_buildtrees = _CacheBuildTrees.NEVER + else: + cache_buildtrees = context.cache_buildtrees build_success = buildresult[0] # cache_buildtrees defaults to 'auto', only caching buildtrees |