diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-08-30 21:28:26 -0400 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-08-31 12:38:25 -0400 |
commit | 62a0e325604440b5f5bc341524d9affdf7cd5b1f (patch) | |
tree | 789b938b268378863f653cbdc04767036dedc32c /buildstream | |
parent | 927e043632c50565ac8df0abec723855ba674090 (diff) | |
download | buildstream-62a0e325604440b5f5bc341524d9affdf7cd5b1f.tar.gz |
project.py: Load new definitions of project version requirements
o Define the base buildstream format as BST_FORMAT_VERSION
in the project module
o Load and cache any required versions of plugins
o Assert overall project version is supported at load time
Part of a fix for issue #69
Diffstat (limited to 'buildstream')
-rw-r--r-- | buildstream/data/projectconfig.yaml | 23 | ||||
-rw-r--r-- | buildstream/project.py | 36 |
2 files changed, 59 insertions, 0 deletions
diff --git a/buildstream/data/projectconfig.yaml b/buildstream/data/projectconfig.yaml index 5ebed682d..aa9605358 100644 --- a/buildstream/data/projectconfig.yaml +++ b/buildstream/data/projectconfig.yaml @@ -4,6 +4,29 @@ # # name: myproject +# Format version requirements +# +# Indicates the minimum required format version the +# project requires. +# +required-versions: + + # The minimum base BuildStream format + project: 0 + + # A minimum plugin format version for each individual + # plugin (as advertized by the plugin BST_FORMAT_VERSION + # class attributes), may be asserted here. + # + # E.g., to require version 3 of the the autotools + # element format: + # + # elements: + # autotools: 3 + # + elements: {} + sources: {} + # Base project relative element path, elements will be loaded # from this base. diff --git a/buildstream/project.py b/buildstream/project.py index 095fac137..e6e088e2e 100644 --- a/buildstream/project.py +++ b/buildstream/project.py @@ -49,6 +49,14 @@ class _ProjectVariant(): del self.data['variant'] +BST_FORMAT_VERSION = 0 +"""The base BuildStream format version + +This version is bumped whenever enhancements are made +to the ``project.conf`` format or the format in general. +""" + + class Project(): """Project Configuration @@ -82,6 +90,8 @@ class Project(): self._variants = [] self._host_arch = host_arch self._target_arch = target_arch or host_arch + self._source_format_versions = {} + self._element_format_versions = {} profile_start(Topics.LOAD_PROJECT, self.directory.replace(os.sep, '-')) self._unresolved_config = self._load_first_half() @@ -210,6 +220,32 @@ class Project(): # The project name self.name = _yaml.node_get(self._unresolved_config, str, 'name') + # Version requirements + versions = _yaml.node_get(self._unresolved_config, Mapping, 'required-versions') + + # Assert project version first + format_version = _yaml.node_get(versions, int, 'project') + if BST_FORMAT_VERSION < format_version: + major, minor = utils.get_bst_version() + raise LoadError( + LoadErrorReason.UNSUPPORTED_PROJECT, + "Project requested format version {}, but BuildStream {}.{} only supports up until format version {}" + .format(format_version, major, minor, BST_FORMAT_VERSION)) + + # The source versions + source_versions = _yaml.node_get(versions, Mapping, 'sources', default_value={}) + for key, _ in source_versions.items(): + if key == _yaml.PROVENANCE_KEY: + continue + self._source_format_versions[key] = _yaml.node_get(source_versions, int, key) + + # The element versions + element_versions = _yaml.node_get(versions, Mapping, 'elements', default_value={}) + for key, _ in element_versions.items(): + if key == _yaml.PROVENANCE_KEY: + continue + self._element_format_versions[key] = _yaml.node_get(element_versions, int, key) + # Load the plugin paths plugins = _yaml.node_get(self._unresolved_config, Mapping, 'plugins', default_value={}) self._plugin_source_paths = [os.path.join(self.directory, path) |