diff options
Diffstat (limited to 'buildstream/_plugincontext.py')
-rw-r--r-- | buildstream/_plugincontext.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/buildstream/_plugincontext.py b/buildstream/_plugincontext.py index 5a7097485..10e32e58a 100644 --- a/buildstream/_plugincontext.py +++ b/buildstream/_plugincontext.py @@ -22,6 +22,7 @@ import inspect from ._exceptions import PluginError, LoadError, LoadErrorReason from . import utils +from .utils import UtilError # A Context for loading plugin types @@ -223,6 +224,31 @@ class PluginContext(): plugin_type.BST_REQUIRED_VERSION_MAJOR, plugin_type.BST_REQUIRED_VERSION_MINOR)) + # If a BST_MIN_VERSION was specified, then we need to raise an error + # that we are loading a plugin which targets the wrong BuildStream version. + # + try: + min_version = plugin_type.BST_MIN_VERSION + except AttributeError: + return + + # Handle malformed version string specified by plugin + # + try: + major, minor = utils._parse_version(min_version) + except UtilError as e: + raise PluginError( + "Loaded plugin '{}' is not a BuildStream 1 plugin".format(kind), + detail="Error parsing BST_MIN_VERSION: {}".format(e), + reason="plugin-version-mismatch" + ) from e + + raise PluginError( + "Loaded plugin '{}' is a BuildStream {} plugin".format(kind, major), + detail="You need to use BuildStream 1 plugins with BuildStream 1 projects", + reason="plugin-version-mismatch" + ) + # _assert_plugin_format() # # Helper to raise a PluginError if the loaded plugin is of a lesser version then |