summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin David <valentin.david@codethink.co.uk>2018-07-02 11:55:55 +0200
committerValentin David <valentin.david@codethink.co.uk>2018-07-02 16:25:58 +0200
commit52b6b40838ba590de53d181b449fd337730baae0 (patch)
tree4bf6c7c07630aef935238c19cc1440d7ede44109
parent9df849dfa282e124b876e1ba869023f1eecd1397 (diff)
downloadbuildstream-52b6b40838ba590de53d181b449fd337730baae0.tar.gz
Always process local includes.
-rw-r--r--buildstream/_includes.py35
-rw-r--r--buildstream/_project.py3
-rw-r--r--tests/format/include.py6
-rw-r--r--tests/format/include/overrides-junction/element.bst1
-rw-r--r--tests/format/include/overrides-junction/project.conf20
-rw-r--r--tests/format/include/overrides-junction/subproject/extra_conf.yml16
-rw-r--r--tests/format/include/overrides-junction/subproject/project.conf1
7 files changed, 59 insertions, 23 deletions
diff --git a/buildstream/_includes.py b/buildstream/_includes.py
index a35772387..3640f7ae5 100644
--- a/buildstream/_includes.py
+++ b/buildstream/_includes.py
@@ -10,19 +10,10 @@ 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(),
- current_loader=None):
+ current_loader=None,
+ only_local=False):
if current_loader is None:
current_loader = self._loader
@@ -32,6 +23,8 @@ class Includes:
if includes:
for include in includes:
+ if only_local and ':' in include:
+ continue
include_node, file_path, sub_loader = self._include_file(include,
current_loader)
if file_path in included:
@@ -42,13 +35,15 @@ class Includes:
try:
included.add(file_path)
self.process(include_node, included=included,
- current_loader=sub_loader)
+ current_loader=sub_loader,
+ only_local=only_local)
finally:
included.remove(file_path)
_yaml.composite(node, include_node)
for _, value in _yaml.node_items(node):
- self._process_value(value, current_loader=current_loader)
+ self._process_value(value, current_loader=current_loader,
+ only_local=only_local)
def _include_file(self, include, loader):
shortname = include
@@ -68,12 +63,16 @@ class Includes:
project=project)
return self._loaded[key], file_path, current_loader
- def _process_value(self, value, *, current_loader=None):
+ def _process_value(self, value, *,
+ current_loader=None,
+ only_local=False):
if isinstance(value, Mapping):
- self.process(value, current_loader=current_loader)
+ self.process(value, current_loader=current_loader, only_local=only_local)
elif isinstance(value, list):
- self._process_list(value, current_loader=current_loader)
+ self._process_list(value, current_loader=current_loader, only_local=only_local)
- def _process_list(self, values, *, current_loader=None):
+ def _process_list(self, values, *,
+ current_loader=None,
+ only_local=False):
for value in values:
- self._process_value(value, current_loader=current_loader)
+ self._process_value(value, current_loader=current_loader, only_local=only_local)
diff --git a/buildstream/_project.py b/buildstream/_project.py
index 5156539d7..5e89f8805 100644
--- a/buildstream/_project.py
+++ b/buildstream/_project.py
@@ -301,7 +301,6 @@ class Project():
def source_overrides(self):
return self.config.source_overrides
-
# translate_url():
#
# Translates the given url which may be specified with an alias
@@ -459,7 +458,7 @@ class Project():
self._project_includes = Includes(self.loader)
config_no_include = _yaml.node_copy(self._config_node)
- self._project_includes.ignore_includes(config_no_include)
+ self._project_includes.process(config_no_include, only_local=True)
self._load_pass(config_no_include, self.first_pass_config, True)
diff --git a/tests/format/include.py b/tests/format/include.py
index ba8d4a08d..938b98719 100644
--- a/tests/format/include.py
+++ b/tests/format/include.py
@@ -93,7 +93,7 @@ def test_junction_element_partial_project_project(cli, tmpdir, datafiles):
@pytest.mark.datafiles(DATA_DIR)
-def test_junction_element_partial_project_file(cli, tmpdir, datafiles):
+def test_junction_element_not_partial_project_file(cli, tmpdir, datafiles):
"""
Junction elements never depend on fully include processed project.
"""
@@ -122,7 +122,7 @@ def test_junction_element_partial_project_file(cli, tmpdir, datafiles):
'junction.bst'])
result.assert_success()
loaded = _yaml.load_data(result.output)
- assert 'included' not in loaded
+ assert 'included' in loaded
@pytest.mark.datafiles(DATA_DIR)
@@ -171,7 +171,7 @@ def test_include_element_overrides_sub_include(cli, tmpdir, datafiles):
@pytest.mark.datafiles(DATA_DIR)
def test_junction_do_not_use_included_overrides(cli, tmpdir, datafiles):
- project = os.path.join(str(datafiles), 'overrides')
+ project = os.path.join(str(datafiles), 'overrides-junction')
generate_junction(tmpdir,
os.path.join(project, 'subproject'),
diff --git a/tests/format/include/overrides-junction/element.bst b/tests/format/include/overrides-junction/element.bst
new file mode 100644
index 000000000..4d7f70266
--- /dev/null
+++ b/tests/format/include/overrides-junction/element.bst
@@ -0,0 +1 @@
+kind: manual
diff --git a/tests/format/include/overrides-junction/project.conf b/tests/format/include/overrides-junction/project.conf
new file mode 100644
index 000000000..d03bec634
--- /dev/null
+++ b/tests/format/include/overrides-junction/project.conf
@@ -0,0 +1,20 @@
+name: test
+
+elements:
+ junction:
+ variables:
+ main_override: True
+ manual:
+ variables:
+ manual_main_override: True
+ config:
+ build-commands:
+ - "first"
+
+sources:
+ git:
+ variables:
+ from_main: True
+
+(@):
+ - junction.bst:extra_conf.yml
diff --git a/tests/format/include/overrides-junction/subproject/extra_conf.yml b/tests/format/include/overrides-junction/subproject/extra_conf.yml
new file mode 100644
index 000000000..3cd3530c5
--- /dev/null
+++ b/tests/format/include/overrides-junction/subproject/extra_conf.yml
@@ -0,0 +1,16 @@
+elements:
+ junction:
+ variables:
+ included_override: True
+ manual:
+ variables:
+ manual_included_override: True
+ config:
+ build-commands:
+ (>):
+ - "second"
+
+sources:
+ git:
+ variables:
+ from_included: True
diff --git a/tests/format/include/overrides-junction/subproject/project.conf b/tests/format/include/overrides-junction/subproject/project.conf
new file mode 100644
index 000000000..7a6655421
--- /dev/null
+++ b/tests/format/include/overrides-junction/subproject/project.conf
@@ -0,0 +1 @@
+name: test-sub