You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by gi...@apache.org on 2020/12/29 13:09:28 UTC
[buildstream] 01/01: source.py,
plugin.py: Allow elements to have a cache directory
This is an automated email from the ASF dual-hosted git repository.
github-bot pushed a commit to branch chandan/element-cache
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 72bf5f5c590b14528a9bf4c1a7f8f3ce573edb3a
Author: Chandan Singh <cs...@bloomberg.net>
AuthorDate: Thu Aug 23 23:51:12 2018 +0100
source.py,plugin.py: Allow elements to have a cache directory
At present, only source plugins are allowed to have cache directories
but not elements. Move `get_mirror_directory()` method from Source()
to Plugin() so that elements could also benefit from having a cache, if
needed.
---
buildstream/plugin.py | 13 +++++++++++++
buildstream/source.py | 13 -------------
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/buildstream/plugin.py b/buildstream/plugin.py
index a65db4d..6b4dbb1 100644
--- a/buildstream/plugin.py
+++ b/buildstream/plugin.py
@@ -287,6 +287,19 @@ class Plugin():
"""
return self.__kind
+ def get_mirror_directory(self):
+ """Fetches the directory where this plugin should store things
+
+ Returns:
+ (str): The directory belonging to this plugin
+ """
+
+ # Create the directory if it doesnt exist
+ context = self._get_context()
+ directory = os.path.join(context.sourcedir, self.get_kind())
+ os.makedirs(directory, exist_ok=True)
+ return directory
+
def node_items(self, node):
"""Iterate over a dictionary loaded from YAML
diff --git a/buildstream/source.py b/buildstream/source.py
index 6d56405..2ef9fb1 100644
--- a/buildstream/source.py
+++ b/buildstream/source.py
@@ -481,19 +481,6 @@ class Source(Plugin):
#############################################################
# Public Methods #
#############################################################
- def get_mirror_directory(self):
- """Fetches the directory where this source should store things
-
- Returns:
- (str): The directory belonging to this source
- """
-
- # Create the directory if it doesnt exist
- context = self._get_context()
- directory = os.path.join(context.sourcedir, self.get_kind())
- os.makedirs(directory, exist_ok=True)
- return directory
-
def translate_url(self, url, *, alias_override=None):
"""Translates the given url which may be specified with an alias
into a fully qualified url.