diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-09-02 17:49:00 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-09-03 15:19:48 +0900 |
commit | 4df625c84c8d755631ab818587870e29e5f1e2e9 (patch) | |
tree | 2ce502e608990ff1d4ba7692bb10d63f79169c1c /buildstream | |
parent | 62b7ec4595b2dfb67674026c89ed891632680da1 (diff) | |
download | buildstream-4df625c84c8d755631ab818587870e29e5f1e2e9.tar.gz |
plugin.py: Added _configure() and _get_configuring() private APIs
Keeps track of whether the plugin is currently being configured.
Adjusted Element and Source classes to call _configure() in place
of calling configure() directly.
This is a part of #620
Diffstat (limited to 'buildstream')
-rw-r--r-- | buildstream/element.py | 2 | ||||
-rw-r--r-- | buildstream/plugin.py | 27 | ||||
-rw-r--r-- | buildstream/source.py | 2 |
3 files changed, 29 insertions, 2 deletions
diff --git a/buildstream/element.py b/buildstream/element.py index 70e12313c..6a6d1a9b8 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -262,7 +262,7 @@ class Element(Plugin): # Collect the composited element configuration and # ask the element to configure itself. self.__config = self.__extract_config(meta) - self.configure(self.__config) + self._configure(self.__config) # Extract Sandbox config self.__sandbox_config = self.__extract_sandbox_config(meta) diff --git a/buildstream/plugin.py b/buildstream/plugin.py index 836b60834..f57c0e15c 100644 --- a/buildstream/plugin.py +++ b/buildstream/plugin.py @@ -162,6 +162,7 @@ class Plugin(): self.__provenance = provenance # The Provenance information self.__type_tag = type_tag # The type of plugin (element or source) self.__unique_id = _plugin_register(self) # Unique ID + self.__configuring = False # Whether we are currently configuring # Infer the kind identifier modulename = type(self).__module__ @@ -651,7 +652,32 @@ class Plugin(): else: yield log + # _configure(): + # + # Calls configure() for the plugin, this must be called by + # the core instead of configure() directly, so that the + # _get_configuring() state is up to date. + # + # Args: + # node (dict): The loaded configuration dictionary + # + def _configure(self, node): + self.__configuring = True + self.configure(node) + self.__configuring = False + + # _get_configuring(): + # + # Checks whether the plugin is in the middle of having + # its Plugin.configure() method called + # + # Returns: + # (bool): Whether we are currently configuring + def _get_configuring(self): + return self.__configuring + # _preflight(): + # # Calls preflight() for the plugin, and allows generic preflight # checks to be added # @@ -659,6 +685,7 @@ class Plugin(): # SourceError: If it's a Source implementation # ElementError: If it's an Element implementation # ProgramNotFoundError: If a required host tool is not found + # def _preflight(self): self.preflight() diff --git a/buildstream/source.py b/buildstream/source.py index 15acba732..bec01553b 100644 --- a/buildstream/source.py +++ b/buildstream/source.py @@ -247,7 +247,7 @@ class Source(Plugin): self.__config = self.__extract_config(meta) self.__first_pass = meta.first_pass - self.configure(self.__config) + self._configure(self.__config) COMMON_CONFIG_KEYS = ['kind', 'directory'] """Common source config keys |