Skip to content

Commit

Permalink
HelperRules: Add FSetConditionsHold
Browse files Browse the repository at this point in the history
A rule to check simple element containment conditions on sets.
  • Loading branch information
weinhold committed Dec 9, 2012
1 parent e012438 commit a367460
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions build/jam/HelperRules
Expand Up @@ -96,6 +96,62 @@ rule FSplitPath
return $(components) ;
}


rule FSetConditionsHold conditions : set
{
# FSetConditionsHold <conditions> : <set> ;
# Checks whether the conditions <conditions> are satisfied by the list of
# elements <set> and returns a respective result (if so: "1", if not: empty
# list). The conditions are satisfied when <conditions> is not empty and
# * none of the negative conditions it contains hold and
# * if <conditions> 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 <set>.
# A negative condition is an element that starts with a "!". It holds when
# the string resulting from removing the leading "!" is not contained in
# <set>.
#
# <conditions> - The list of conditions.
# <set> - 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 <platform var> : <var prefix>
Expand Down

0 comments on commit a367460

Please sign in to comment.