mirror of
https://github.com/boostorg/build.git
synced 2026-02-13 12:22:17 +00:00
Make free features on the command line affect all targets,
not just directly requested ones. Fixes #985. [SVN r39104]
This commit is contained in:
@@ -41,6 +41,15 @@ rule location ( )
|
||||
return $(r:P) ;
|
||||
}
|
||||
|
||||
# Returns the property set with the
|
||||
# free features from the currently processed
|
||||
# build request.
|
||||
rule command-line-free-features ( )
|
||||
{
|
||||
return $(.command-line-free-features) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Check if we can load 'test-config.jam'. If we can, load it and
|
||||
# ignore user configs.
|
||||
@@ -399,6 +408,7 @@ local results-of-main-targets ;
|
||||
|
||||
for local p in $(expanded)
|
||||
{
|
||||
.command-line-free-features = [ property-set.create [ $(p).free ] ] ;
|
||||
for local t in $(targets)
|
||||
{
|
||||
local g = [ $(t).generate $(p) ] ;
|
||||
|
||||
@@ -1057,6 +1057,7 @@ class basic-target : abstract-target
|
||||
import set sequence errors ;
|
||||
import "class" : new ;
|
||||
import property feature ;
|
||||
import build-system ;
|
||||
|
||||
rule __init__ ( name : project
|
||||
: sources * : requirements * :
|
||||
@@ -1185,12 +1186,21 @@ class basic-target : abstract-target
|
||||
local fn = [ full-name ] ;
|
||||
ECHO [ targets.indent ] "Building target '$(fn)'" ;
|
||||
targets.increase-indent ;
|
||||
ECHO [ targets.indent ] "Build request: " [ $(property-set).raw ] ;
|
||||
ECHO [ targets.indent ] "Build request: " [ $(property-set).raw ] ;
|
||||
local cf = [ build-system.command-line-free-features ] ;
|
||||
ECHO [ targets.indent ] "Command line free features: "
|
||||
[ $(cf).raw ] ;
|
||||
ECHO [ targets.indent ] "Target requirements: " [ $(self.requirements).raw ] ;
|
||||
}
|
||||
|
||||
if ! $(self.generated.$(property-set))
|
||||
{
|
||||
# Apply free features form the command line. If user
|
||||
# said
|
||||
# define=FOO
|
||||
# he most likely want this define to be set for all compiles.
|
||||
property-set = [ $(property-set).refine
|
||||
[ build-system.command-line-free-features ] ] ;
|
||||
local rproperties = [ targets.common-properties $(property-set)
|
||||
$(self.requirements) ] ;
|
||||
|
||||
|
||||
42
test/free_features_request.py
Normal file
42
test/free_features_request.py
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
# Copyright (C) Vladimir Prus 2007.
|
||||
# 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)
|
||||
|
||||
# Tests that a free feature specified on the command
|
||||
# line applies to all targets ever built.
|
||||
from BoostBuild import Tester, List
|
||||
|
||||
|
||||
t = Tester()
|
||||
|
||||
t.write("Jamroot", """
|
||||
exe hello : hello.cpp foo ;
|
||||
lib foo : foo.cpp ;
|
||||
""")
|
||||
t.write("hello.cpp", """
|
||||
extern void foo();
|
||||
#ifdef FOO
|
||||
int main()
|
||||
{
|
||||
foo();
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
""")
|
||||
|
||||
t.write("foo.cpp", """
|
||||
#ifdef FOO
|
||||
void foo() {}
|
||||
#endif
|
||||
""")
|
||||
|
||||
# If FOO is not defined when compiling the 'foo'
|
||||
# target, we'll get a link error at this point.
|
||||
t.run_build_system("hello define=FOO")
|
||||
|
||||
t.expect_addition("bin/$toolset/debug/hello")
|
||||
|
||||
t.cleanup()
|
||||
@@ -150,6 +150,7 @@ tests = [ "rebuilds",
|
||||
"example_libraries",
|
||||
"example_make",
|
||||
"remove_requirement",
|
||||
"free_features_request",
|
||||
]
|
||||
|
||||
if os.name == 'posix':
|
||||
|
||||
Reference in New Issue
Block a user