diff options
-rw-r--r-- | buildstream/_context.py | 9 | ||||
-rw-r--r-- | buildstream/_frontend/app.py | 5 | ||||
-rw-r--r-- | buildstream/_platform/linux.py | 6 | ||||
-rw-r--r-- | buildstream/_platform/platform.py | 6 | ||||
-rw-r--r-- | buildstream/_platform/unix.py | 6 |
5 files changed, 16 insertions, 16 deletions
diff --git a/buildstream/_context.py b/buildstream/_context.py index 8b8b01b17..cb29968a4 100644 --- a/buildstream/_context.py +++ b/buildstream/_context.py @@ -30,6 +30,7 @@ from ._exceptions import LoadError, LoadErrorReason, BstError from ._message import Message, MessageType from ._profile import Topics, profile_start, profile_end from ._artifactcache import ArtifactCache +from ._artifactcache.cascache import CASCache from ._workspaces import Workspaces from .plugin import _plugin_lookup @@ -113,6 +114,7 @@ class Context(): self._cache_key = None self._message_handler = None self._message_depth = deque() + self._artifactcache = None self._projects = [] self._project_overrides = {} self._workspaces = None @@ -227,6 +229,13 @@ class Context(): "{}: on-error should be one of: {}".format( provenance, ", ".join(valid_actions))) + @property + def artifactcache(self): + if not self._artifactcache: + self._artifactcache = CASCache(self) + + return self._artifactcache + # add_project(): # # Add a project to the context. diff --git a/buildstream/_frontend/app.py b/buildstream/_frontend/app.py index ccdbb2d5d..caec7cfa3 100644 --- a/buildstream/_frontend/app.py +++ b/buildstream/_frontend/app.py @@ -202,6 +202,11 @@ class App(): except BstError as e: self._error_exit(e, "Error instantiating platform") + try: + self.context.artifactcache.preflight() + except BstError as e: + self._error_exit(e, "Error instantiating artifact cache") + # Create the logger right before setting the message handler self.logger = LogLine(self.context, self._content_profile, diff --git a/buildstream/_platform/linux.py b/buildstream/_platform/linux.py index 119f13605..2dfe72ac7 100644 --- a/buildstream/_platform/linux.py +++ b/buildstream/_platform/linux.py @@ -22,7 +22,6 @@ import subprocess from .. import _site from .. import utils -from .._artifactcache.cascache import CASCache from .._message import Message, MessageType from ..sandbox import SandboxBwrap @@ -40,11 +39,6 @@ class Linux(Platform): self._die_with_parent_available = _site.check_bwrap_version(0, 1, 8) self._user_ns_available = self._check_user_ns_available() - self._artifact_cache = CASCache(context) - - @property - def artifactcache(self): - return self._artifact_cache def create_sandbox(self, *args, **kwargs): # Inform the bubblewrap sandbox as to whether it can use user namespaces or not diff --git a/buildstream/_platform/platform.py b/buildstream/_platform/platform.py index 8dcfe95e5..153ff34c4 100644 --- a/buildstream/_platform/platform.py +++ b/buildstream/_platform/platform.py @@ -29,8 +29,7 @@ class Platform(): # Platform() # # A class to manage platform-specific details. Currently holds the - # sandbox factory, the artifact cache and staging operations, as - # well as platform helpers. + # sandbox factory as well as platform helpers. # # Args: # context (context): The project context @@ -71,8 +70,7 @@ class Platform(): ################################################################## @property def artifactcache(self): - raise ImplError("Platform {platform} does not implement an artifactcache" - .format(platform=type(self).__name__)) + return self.context.artifactcache ################################################################## # Sandbox functions # diff --git a/buildstream/_platform/unix.py b/buildstream/_platform/unix.py index e356fc89c..3bd86e0ac 100644 --- a/buildstream/_platform/unix.py +++ b/buildstream/_platform/unix.py @@ -19,7 +19,6 @@ import os -from .._artifactcache.cascache import CASCache from .._exceptions import PlatformError from ..sandbox import SandboxChroot @@ -31,7 +30,6 @@ class Unix(Platform): def __init__(self, context): super().__init__(context) - self._artifact_cache = CASCache(context) self._uid = os.geteuid() self._gid = os.getegid() @@ -40,10 +38,6 @@ class Unix(Platform): if self._uid != 0: raise PlatformError("Root privileges are required to run without bubblewrap.") - @property - def artifactcache(self): - return self._artifact_cache - def create_sandbox(self, *args, **kwargs): return SandboxChroot(*args, **kwargs) |