You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by tv...@apache.org on 2021/02/04 07:15:27 UTC

[buildstream] 01/01: Add mechanism for elements to opt-out of buildtrees.

This is an automated email from the ASF dual-hosted git repository.

tvb pushed a commit to branch sstriker-never-cache-buildtrees
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit ed54c7322009cfa197b69dd9e7a8a506235bf3d2
Author: Sander Striker <s....@striker.nl>
AuthorDate: Fri Jul 10 23:55:56 2020 +0200

    Add mechanism for elements to opt-out of 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
---
 src/buildstream/element.py | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/buildstream/element.py b/src/buildstream/element.py
index 6a0fa5f..cdf3ae6 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