summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-02-20 20:32:21 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-03-20 16:55:56 +0900
commit3f8f5b3e4bcfc58031d516b03cd2fb74a736021f (patch)
tree33efd8de1d7c957897caffa4b88914f3704e14dd
parentb78db5f209f276727164cad467290edb133b3ab7 (diff)
downloadbuildstream-3f8f5b3e4bcfc58031d516b03cd2fb74a736021f.tar.gz
_project.py: Load project.refs while loading the project.
This also bumps the format version to signify a new format where storing refs centralized in project.refs is now supported.
-rw-r--r--buildstream/_project.py22
-rw-r--r--buildstream/data/projectconfig.yaml9
2 files changed, 26 insertions, 5 deletions
diff --git a/buildstream/_project.py b/buildstream/_project.py
index 6c71f03d3..ece234ed8 100644
--- a/buildstream/_project.py
+++ b/buildstream/_project.py
@@ -32,6 +32,7 @@ from ._options import OptionPool
from ._artifactcache import artifact_cache_specs_from_config_node
from ._elementfactory import ElementFactory
from ._sourcefactory import SourceFactory
+from ._projectrefs import ProjectRefs, ProjectRefStorage
# The base BuildStream format version
@@ -39,7 +40,7 @@ from ._sourcefactory import SourceFactory
# This version is bumped whenever enhancements are made
# to the `project.conf` format or the core element format.
#
-BST_FORMAT_VERSION = 4
+BST_FORMAT_VERSION = 5
# The separator we use for user specified aliases
_ALIAS_SEPARATOR = ':'
@@ -100,6 +101,10 @@ class Project():
self._source_format_versions = {}
self._element_format_versions = {}
self._fail_on_overlap = False
+ self._ref_storage = None # The ProjectRefStorage setting
+
+ # The project.refs management object for this project
+ self.refs = ProjectRefs(self.directory)
# Shell options
self._shell_command = [] # The default interactive shell command
@@ -166,7 +171,8 @@ class Project():
'split-rules', 'elements', 'plugins',
'aliases', 'name',
'artifacts', 'options',
- 'fail-on-overlap', 'shell'
+ 'fail-on-overlap', 'shell',
+ 'ref-storage'
])
# The project name, element path and option declarations
@@ -295,6 +301,18 @@ class Project():
# Fail on overlap
self._fail_on_overlap = _yaml.node_get(config, bool, 'fail-on-overlap')
+ # Use separate file for storing source references
+ self._ref_storage = _yaml.node_get(config, str, 'ref-storage')
+ if self._ref_storage not in [ProjectRefStorage.INLINE, ProjectRefStorage.PROJECT_REFS]:
+ p = _yaml.node_get_provenance(config, 'ref-storage')
+ raise LoadError(LoadErrorReason.INVALID_DATA,
+ "{}: Invalid value '{}' specified for ref-storage"
+ .format(p, self._ref_storage))
+
+ # Load project.refs if it exists, this may be ignored.
+ if self._ref_storage == ProjectRefStorage.PROJECT_REFS:
+ self.refs.load(self._options)
+
# Parse shell options
shell_options = _yaml.node_get(config, Mapping, 'shell')
_yaml.node_validate(shell_options, ['command', 'environment', 'host-files'])
diff --git a/buildstream/data/projectconfig.yaml b/buildstream/data/projectconfig.yaml
index 7bbcf69e0..d8fefc5e1 100644
--- a/buildstream/data/projectconfig.yaml
+++ b/buildstream/data/projectconfig.yaml
@@ -7,12 +7,15 @@
# Require format version 0
format-version: 0
-# Overlaps are just warnings
-fail-on-overlap: False
-
# Elements are found at the project root
element-path: .
+# Store source references in element files
+ref-storage: inline
+
+# Overlaps are just warnings
+fail-on-overlap: False
+
# Variable Configuration
#