2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-16 01:12:13 +00:00

Implement 'indirect conditional requirements', which are simular to V1's

convention that rules used in requiremenst are called to provide extra features.


[SVN r32694]
This commit is contained in:
Vladimir Prus
2006-02-07 10:26:17 +00:00
parent c0a4499a77
commit 4c1960e774
4 changed files with 115 additions and 2 deletions

View File

@@ -79,6 +79,7 @@ import virtual-target ;
import path ;
import set ;
import assert ;
import indirect ;
# Base class for all abstract targets.
class abstract-target
@@ -934,23 +935,47 @@ rule common-properties2 ( build-request requirements )
local raw = [ $(build-request).raw ] ;
raw = [ property.refine $(raw) :
[ feature.expand [ $(requirements).non-conditional ] ] ] ;
# We've collected properties that surely must be present in common
# properties. We now try to figure out what other properties
# should be added in order to satisfy rules (4)-(6) from the docs.
local conditionals = [ $(requirements).conditional ] ;
local count = $(conditionals) and-once-more ;
# The 'count' variable has one element for each conditional feature
# and for each occurence of '<indirect-conditional>' feature.
# It's used as a loop counter: for each iteration of the loop
# before we remove one element and the property set should
# stabilize before we've done. It's supposed to #conditionals iterations
# should be enough for properties to propagate along conditions in any
# direction.
local count = $(conditionals)
[ $(requirements).get <conditional> ]
and-once-more ;
local prev ;
local current = $(raw) ;
# It's assumed that ordinary conditional requirements can't add
# <indirect-conditional> properties, and that rules refered
# by <indirect-conditional> properties can't add new
# <indirect-conditional> properties. So the list of indirect conditionals
# does not change.
local indirect = [ $(requirements).get <conditional> ] ;
indirect = [ MATCH @(.*) : $(indirect) ] ;
local ok ;
while $(count)
{
# Evaluate conditionals in context of current properties
local e = [ property.evaluate-conditionals-in-context $(conditionals)
: $(current) ] ;
# Evaluate indirect conditionals.
for local i in $(indirect)
{
e += [ indirect.call $(i) $(current) ] ;
}
if $(e) = $(prev)
{
# If we got the same result, we've found final properties.

View File

@@ -0,0 +1,84 @@
#!/usr/bin/python
# Copyright (C) Vladimir Prus 2006.
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
from BoostBuild import Tester, List
import string
t = Tester()
t.write("Jamroot", """
exe a1 : a1.cpp : <conditional>@a1-rule ;
rule a1-rule ( properties * )
{
if <variant>debug in $(properties)
{
return <define>OK ;
}
}
exe a2 : a2.cpp : <conditional>@$(__name__).a2-rule <variant>debug:<optimization>speed ;
rule a2-rule ( properties * )
{
if <optimization>speed in $(properties)
{
return <define>OK ;
}
}
exe a3 : a3.cpp : <conditional>@$(__name__).a3-rule-1 <conditional>@$(__name__).a3-rule-2 ;
rule a3-rule-1 ( properties * )
{
if <optimization>speed in $(properties)
{
return <define>OK ;
}
}
rule a3-rule-2 ( properties * )
{
if <variant>debug in $(properties)
{
return <optimization>speed ;
}
}
""")
t.write("a1.cpp", """
#ifdef OK
int main() {}
#endif
""")
t.write("a2.cpp", """
#ifdef OK
int main() {}
#endif
""")
t.write("a3.cpp", """
#ifdef OK
int main() {}
#endif
""")
t.run_build_system()
t.expect_addition("bin/$toolset/debug/a1.exe")
t.expect_addition("bin/$toolset/debug/optimization-speed/a2.exe")
t.expect_addition("bin/$toolset/debug/optimization-speed/a3.exe")
t.cleanup()

View File

@@ -134,6 +134,7 @@ tests = [ "rebuilds",
"project_root_rule",
"resolution",
"build_file",
"indirect_conditional",
]
if os.name == 'posix':

View File

@@ -177,6 +177,9 @@ feature instruction-set :
vr4100 vr4111 vr4120 vr4130 vr4300 vr5000 vr5400 vr5500
#
: propagated optional ;
feature conditional : : incidental free ;
# Windows-specific features