summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim MacArthur <jim.macarthur@codethink.co.uk>2018-05-02 18:24:33 +0100
committerJim MacArthur <jim.macarthur@codethink.co.uk>2018-07-23 15:20:02 +0100
commit480c018453b3a16ca8bb355f1530835ce3449468 (patch)
treeb8eb22094ec929c35a1a663c0462ede1a97d4ae5
parent335afb5b973a31595b6059c8c4e9add4b7cbbe9a (diff)
downloadbuildstream-480c018453b3a16ca8bb355f1530835ce3449468.tar.gz
Add BST_VIRTUAL_DIRECTORY flag for element plugins
-rw-r--r--buildstream/element.py10
-rw-r--r--buildstream/sandbox/sandbox.py13
2 files changed, 19 insertions, 4 deletions
diff --git a/buildstream/element.py b/buildstream/element.py
index e9cbdb63e..1f985aeb2 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -191,6 +191,13 @@ class Element(Plugin):
*Since: 1.2*
"""
+ BST_VIRTUAL_DIRECTORY = False
+ """Whether to raise exceptions if an element uses Sandbox.get_directory
+ instead of Sandbox.get_virtual_directory.
+
+ *Since: 1.2*
+ """
+
def __init__(self, context, project, artifacts, meta, plugin_conf):
self.__cache_key_dict = None # Dict for cache key calculation
@@ -2043,7 +2050,8 @@ class Element(Plugin):
directory,
stdout=stdout,
stderr=stderr,
- config=config)
+ config=config,
+ allow_real_directory=not self.BST_VIRTUAL_DIRECTORY)
yield sandbox
else:
diff --git a/buildstream/sandbox/sandbox.py b/buildstream/sandbox/sandbox.py
index 7e1e32b65..7e73e0d9a 100644
--- a/buildstream/sandbox/sandbox.py
+++ b/buildstream/sandbox/sandbox.py
@@ -29,7 +29,7 @@ See also: :ref:`sandboxing`.
"""
import os
-from .._exceptions import ImplError
+from .._exceptions import ImplError, BstError
class SandboxFlags():
@@ -90,6 +90,8 @@ class Sandbox():
self.__cwd = None
self.__env = None
self.__mount_sources = {}
+ self.__allow_real_directory = kwargs['allow_real_directory']
+
# Configuration from kwargs common to all subclasses
self.__config = kwargs['config']
self.__stdout = kwargs['stdout']
@@ -106,12 +108,17 @@ class Sandbox():
"""Fetches the sandbox root directory
The root directory is where artifacts for the base
- runtime environment should be staged.
+ runtime environment should be staged. Only works if
+ BST_VIRTUAL_DIRECTORY is not set.
Returns:
(str): The sandbox root directory
+
"""
- return self.__root
+ if self.__allow_real_directory:
+ return self.__root
+ else:
+ raise BstError("You can't use get_directory")
def set_environment(self, environment):
"""Sets the environment variables for the sandbox