diff options
author | Chandan Singh <csingh43@bloomberg.net> | 2018-08-23 23:51:12 +0100 |
---|---|---|
committer | Chandan Singh <csingh43@bloomberg.net> | 2018-08-23 23:54:45 +0100 |
commit | 72bf5f5c590b14528a9bf4c1a7f8f3ce573edb3a (patch) | |
tree | 884ec10d63934f94cdd1b4c295acb0a5d5e23dcd /buildstream/plugin.py | |
parent | 8216ff8dac91692c9358c3e535f5a0a2c26c1332 (diff) | |
download | buildstream-chandan/element-cache.tar.gz |
source.py,plugin.py: Allow elements to have a cache directorychandan/element-cache
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.
Diffstat (limited to 'buildstream/plugin.py')
-rw-r--r-- | buildstream/plugin.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/buildstream/plugin.py b/buildstream/plugin.py index a65db4d42..6b4dbb175 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 |