You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by gi...@apache.org on 2020/12/29 13:14:06 UTC
[buildstream] 21/30: Fix issue when with including in sub-nodes.
This is an automated email from the ASF dual-hosted git repository.
github-bot pushed a commit to branch valentindavid/flatpak-demo
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit ddeb066ea7817b8ef6217b6b9029868c93680dc4
Author: Valentin David <va...@codethink.co.uk>
AuthorDate: Fri Jun 29 10:11:53 2018 +0200
Fix issue when with including in sub-nodes.
---
buildstream/_includes.py | 10 ++++++++++
buildstream/_project.py | 8 ++++++--
tests/format/include.py | 14 ++++++++++++++
3 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/buildstream/_includes.py b/buildstream/_includes.py
index 2bd885a..fd99a6c 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 7aa72b6..2b9d637 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 8a79ed9..4b26c97 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'