From a3674601c04675b28aa3fcaf4101ca361d021d9c Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sun, 9 Dec 2012 03:44:16 +0100 Subject: [PATCH] HelperRules: Add FSetConditionsHold A rule to check simple element containment conditions on sets. --- build/jam/HelperRules | 56 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/build/jam/HelperRules b/build/jam/HelperRules index 3d1efce667c..5cce26dc7da 100644 --- a/build/jam/HelperRules +++ b/build/jam/HelperRules @@ -96,6 +96,62 @@ rule FSplitPath return $(components) ; } + +rule FSetConditionsHold conditions : set +{ + # FSetConditionsHold : ; + # Checks whether the conditions are satisfied by the list of + # elements and returns a respective result (if so: "1", if not: empty + # list). The conditions are satisfied when is not empty and + # * none of the negative conditions it contains hold and + # * if contains any positive conditions, at least one one of + # those holds. + # A positive condition is an element not starting with a "!". It holds when + # the element is contained in . + # A negative condition is an element that starts with a "!". It holds when + # the string resulting from removing the leading "!" is not contained in + # . + # + # - The list of conditions. + # - The elements against which the conditions are tested. + # + # Examples: + # For set { a b c } the following conditions hold: + # { a }, { a d }, { !d }, { !d !e }, { a !d }, { b !e !f } + # The following conditions don't hold: + # { }, { d }, { d e }, { !a }, { !a b }, { !d e } { a b !c !d } + + local hasPositive ; + local hasNegative ; + local positiveMatch ; + local condition ; + for condition in $(conditions) { + switch $(condition) { + case !* : + { + hasNegative = 1 ; + condition = [ Match "!(.*)" : $(condition) ] ; + if $(condition) in $(set) { + return ; + } + } + case * : + { + hasPositive = 1 ; + if $(condition) in $(set) { + positiveMatch = 1 ; + } + } + } + } + + if $(hasPositive) { + return $(positiveMatch) ; + } + return $(hasNegative) ; +} + + rule SetPlatformCompatibilityFlagVariables { # SetPlatformCompatibilityFlagVariables :