summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-10-11 13:17:17 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-10-11 13:39:02 +0900
commit30be82c6f00e437c1dae070e1364083202762d9a (patch)
tree7ca310c829920d424460f104d7642f47e381c0c0
parentbf679177ffd3041ad72600a87086bee19807753c (diff)
downloadbuildstream-30be82c6f00e437c1dae070e1364083202762d9a.tar.gz
_options/optionpool.py: Implement the (!) assertion directive
These are processed inline with conditionals and before each iteration of conditional processing, ensuring that we always trigger the first assertion ever composited.
-rw-r--r--buildstream/_options/optionpool.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/buildstream/_options/optionpool.py b/buildstream/_options/optionpool.py
index 3686ee6e3..22a846f8e 100644
--- a/buildstream/_options/optionpool.py
+++ b/buildstream/_options/optionpool.py
@@ -170,7 +170,7 @@ class OptionPool():
# Keep processing conditionals on the root node until
# all directly nested conditionals are resolved.
#
- while self.process_conditional(node):
+ while self.process_one_node(node):
pass
# Now recurse into nested dictionaries and lists
@@ -197,8 +197,17 @@ class OptionPool():
#
# Return true if a conditional was processed.
#
- def process_conditional(self, node):
+ def process_one_node(self, node):
conditions = _yaml.node_get(node, list, '(?)', default_value=[]) or None
+ assertion = _yaml.node_get(node, str, '(!)', default_value='') or None
+
+ # Process assersions first, we want to abort on the first encountered
+ # assertion in a given dictionary, and not lose an assertion due to
+ # it being overwritten by a later assertion which might also trigger.
+ if assertion is not None:
+ p = _yaml.node_get_provenance(node, '(!)')
+ raise LoadError(LoadErrorReason.USER_ASSERTION,
+ "{}: {}".format(p, assertion.strip()))
if conditions is not None: