From 30be82c6f00e437c1dae070e1364083202762d9a Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Wed, 11 Oct 2017 13:17:17 +0900 Subject: _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. --- buildstream/_options/optionpool.py | 13 +++++++++++-- 1 file 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: -- cgit v1.2.1