summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2018-09-26 09:59:03 +0100
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-04-14 16:25:19 +0900
commita777e9a934583edc9182db2720cabcd7123d9b1b (patch)
tree207b3987cb1faf381f73b8dd7626e151803cfd79
parentec83ac8fc33c9147cdc6d1b59113ae40307478ac (diff)
downloadbuildstream-a777e9a934583edc9182db2720cabcd7123d9b1b.tar.gz
Move artifact cache creation to Context
The artifact cache is no longer platform-specific.
-rw-r--r--buildstream/_context.py9
-rw-r--r--buildstream/_frontend/app.py5
-rw-r--r--buildstream/_platform/linux.py6
-rw-r--r--buildstream/_platform/platform.py6
-rw-r--r--buildstream/_platform/unix.py6
5 files changed, 16 insertions, 16 deletions
diff --git a/buildstream/_context.py b/buildstream/_context.py
index 8dde091d3..b536161e4 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
@@ -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
@@ -228,6 +230,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 312f11d0c..553dae283 100644
--- a/buildstream/_frontend/app.py
+++ b/buildstream/_frontend/app.py
@@ -203,6 +203,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)