summaryrefslogtreecommitdiff
path: root/buildstream/_loader
diff options
context:
space:
mode:
authorValentin David <valentin.david@codethink.co.uk>2018-07-18 12:29:40 +0200
committerTiago Gomes <tiago.gomes@codethink.co.uk>2018-08-03 12:54:33 +0100
commitf47b80c37e625280c37731f57a8b2f12fc7eac79 (patch)
treee07474bf4040550d1995adb5621ed9d881267605 /buildstream/_loader
parent054112e270c369910a6d81b8dc90ae0f2cd4e24d (diff)
downloadbuildstream-f47b80c37e625280c37731f57a8b2f12fc7eac79.tar.gz
Add support for include '(@)' in project.conf and .bst files
Fixes #331.
Diffstat (limited to 'buildstream/_loader')
-rw-r--r--buildstream/_loader/loader.py19
-rw-r--r--buildstream/_loader/metaelement.py5
-rw-r--r--buildstream/_loader/metasource.py2
3 files changed, 22 insertions, 4 deletions
diff --git a/buildstream/_loader/loader.py b/buildstream/_loader/loader.py
index 280805981..6e46197ab 100644
--- a/buildstream/_loader/loader.py
+++ b/buildstream/_loader/loader.py
@@ -29,6 +29,7 @@ from .. import _yaml
from ..element import Element
from .._profile import Topics, profile_start, profile_end
from .._platform import Platform
+from .._includes import Includes
from .types import Symbol, Dependency
from .loadelement import LoadElement
@@ -69,6 +70,7 @@ class Loader():
self._context = context
self._options = project.options # Project options (OptionPool)
self._basedir = basedir # Base project directory
+ self._first_pass_options = project.first_pass_config.options # Project options (OptionPool)
self._tempdir = tempdir # A directory to cleanup
self._parent = parent # The parent loader
@@ -76,6 +78,8 @@ class Loader():
self._elements = {} # Dict of elements
self._loaders = {} # Dict of junction loaders
+ self._includes = Includes(self)
+
# load():
#
# Loads the project based on the parameters given to the constructor
@@ -215,7 +219,7 @@ class Loader():
# Load the data and process any conditional statements therein
fullpath = os.path.join(self._basedir, filename)
try:
- node = _yaml.load(fullpath, shortname=filename, copy_tree=rewritable)
+ node = _yaml.load(fullpath, shortname=filename, copy_tree=rewritable, project=self.project)
except LoadError as e:
if e.reason == LoadErrorReason.MISSING_FILE:
# If we can't find the file, try to suggest plausible
@@ -241,7 +245,15 @@ class Loader():
message, detail=detail) from e
else:
raise
- self._options.process_node(node)
+ kind = _yaml.node_get(node, str, Symbol.KIND)
+ if kind == "junction":
+ self._first_pass_options.process_node(node)
+ else:
+ self.project.ensure_fully_loaded()
+
+ self._includes.process(node)
+
+ self._options.process_node(node)
element = LoadElement(node, filename, self)
@@ -433,7 +445,8 @@ class Loader():
_yaml.node_get(node, Mapping, Symbol.ENVIRONMENT, default_value={}),
_yaml.node_get(node, list, Symbol.ENV_NOCACHE, default_value=[]),
_yaml.node_get(node, Mapping, Symbol.PUBLIC, default_value={}),
- _yaml.node_get(node, Mapping, Symbol.SANDBOX, default_value={}))
+ _yaml.node_get(node, Mapping, Symbol.SANDBOX, default_value={}),
+ element_kind == 'junction')
# Cache it now, make sure it's already there before recursing
self._meta_elements[element_name] = meta_element
diff --git a/buildstream/_loader/metaelement.py b/buildstream/_loader/metaelement.py
index 16788e92b..c13d5591e 100644
--- a/buildstream/_loader/metaelement.py
+++ b/buildstream/_loader/metaelement.py
@@ -36,9 +36,11 @@ class MetaElement():
# env_nocache: List of environment vars which should not be considered in cache keys
# public: Public domain data dictionary
# sandbox: Configuration specific to the sandbox environment
+ # first_pass: The element is to be loaded with first pass configuration (junction)
#
def __init__(self, project, name, kind, provenance, sources, config,
- variables, environment, env_nocache, public, sandbox):
+ variables, environment, env_nocache, public, sandbox,
+ first_pass):
self.project = project
self.name = name
self.kind = kind
@@ -52,3 +54,4 @@ class MetaElement():
self.sandbox = sandbox
self.build_dependencies = []
self.dependencies = []
+ self.first_pass = first_pass
diff --git a/buildstream/_loader/metasource.py b/buildstream/_loader/metasource.py
index 3bcc21ec6..da2c0e292 100644
--- a/buildstream/_loader/metasource.py
+++ b/buildstream/_loader/metasource.py
@@ -30,6 +30,7 @@ class MetaSource():
# element_kind: The kind of the owning element
# kind: The kind of the source
# config: The configuration data for the source
+ # first_pass: This source will be used with first project pass configuration (used for junctions).
#
def __init__(self, element_name, element_index, element_kind, kind, config, directory):
self.element_name = element_name
@@ -38,3 +39,4 @@ class MetaSource():
self.kind = kind
self.config = config
self.directory = directory
+ self.first_pass = False