summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin David <valentin.david@codethink.co.uk>2018-06-29 10:11:53 +0200
committerValentin David <valentin.david@codethink.co.uk>2018-07-02 16:25:58 +0200
commitddeb066ea7817b8ef6217b6b9029868c93680dc4 (patch)
treea530aa5e749035622bcb44beb958b51c7cf7cb1c
parent7eccd568b857954231697d1f82713c3f7a5f95dd (diff)
downloadbuildstream-ddeb066ea7817b8ef6217b6b9029868c93680dc4.tar.gz
Fix issue when with including in sub-nodes.
-rw-r--r--buildstream/_includes.py10
-rw-r--r--buildstream/_project.py8
-rw-r--r--tests/format/include.py14
3 files changed, 30 insertions, 2 deletions
diff --git a/buildstream/_includes.py b/buildstream/_includes.py
index 2bd885ac7..fd99a6c44 100644
--- a/buildstream/_includes.py
+++ b/buildstream/_includes.py
@@ -10,6 +10,16 @@ class Includes:
self._loader = loader
self._loaded = {}
+ def ignore_includes(self, node):
+ if isinstance(node, Mapping):
+ if '(@)' in node:
+ del node['(@)']
+ for _, value in _yaml.node_items(node):
+ self.ignore_includes(value)
+ elif isinstance(node, list):
+ for value in node:
+ self.ignore_includes(value)
+
def process(self, node, *, included=set()):
includes = _yaml.node_get(node, list, '(@)', default_value=None)
if '(@)' in node:
diff --git a/buildstream/_project.py b/buildstream/_project.py
index 7aa72b6e6..2b9d637a6 100644
--- a/buildstream/_project.py
+++ b/buildstream/_project.py
@@ -455,9 +455,13 @@ class Project():
parent=parent_loader,
tempdir=tempdir)
- self._load_pass(_yaml.node_copy(config), self.first_pass_config, True)
-
project_includes = Includes(self.loader)
+
+ config_no_include = _yaml.node_copy(config)
+ project_includes.ignore_includes(config_no_include)
+
+ self._load_pass(config_no_include, self.first_pass_config, True)
+
project_includes.process(config)
self._load_pass(config, self.config, False)
diff --git a/tests/format/include.py b/tests/format/include.py
index 8a79ed94d..4b26c9780 100644
--- a/tests/format/include.py
+++ b/tests/format/include.py
@@ -215,3 +215,17 @@ def test_recusive_include(cli, tmpdir, datafiles):
'--format', '%{vars}',
'element.bst'])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.RECURSIVE_INCLUDE)
+
+
+@pytest.mark.datafiles(DATA_DIR)
+def test_inner(cli, datafiles):
+ project = os.path.join(str(datafiles), 'inner')
+ result = cli.run(project=project, args=[
+ '-o', 'build_arch', 'x86_64',
+ 'show',
+ '--deps', 'none',
+ '--format', '%{vars}',
+ 'element.bst'])
+ result.assert_success()
+ loaded = _yaml.load_data(result.output)
+ assert loaded['build_arch'] == 'x86_64'