$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
From: ghost_at_[hidden]
Date: 2007-09-01 17:46:10
Author: vladimir_prus
Date: 2007-09-01 17:46:09 EDT (Sat, 01 Sep 2007)
New Revision: 39104
URL: http://svn.boost.org/trac/boost/changeset/39104
Log:
Make free features on the command line affect all targets,
not just directly requested ones.
Fixes #985.
Added:
   trunk/tools/build/v2/test/free_features_request.py   (contents, props changed)
Text files modified: 
   trunk/tools/build/v2/build-system.jam  |    10 ++++++++++                              
   trunk/tools/build/v2/build/targets.jam |    12 +++++++++++-                            
   trunk/tools/build/v2/test/test_all.py  |     1 +                                       
   3 files changed, 22 insertions(+), 1 deletions(-)
Modified: trunk/tools/build/v2/build-system.jam
==============================================================================
--- trunk/tools/build/v2/build-system.jam	(original)
+++ trunk/tools/build/v2/build-system.jam	2007-09-01 17:46:09 EDT (Sat, 01 Sep 2007)
@@ -41,6 +41,15 @@
     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 @@
 
 for local p in $(expanded)
 {
+    .command-line-free-features = [ property-set.create [ $(p).free ] ] ;
     for local t in $(targets)
     {   
         local g = [ $(t).generate $(p) ] ;
Modified: trunk/tools/build/v2/build/targets.jam
==============================================================================
--- trunk/tools/build/v2/build/targets.jam	(original)
+++ trunk/tools/build/v2/build/targets.jam	2007-09-01 17:46:09 EDT (Sat, 01 Sep 2007)
@@ -1057,6 +1057,7 @@
     import set sequence errors ;
     import "class" : new ;
     import property feature ;
+    import build-system ;
         
     rule __init__ ( name : project
         : sources * : requirements * : 
@@ -1185,12 +1186,21 @@
             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) ] ;           
             
Added: trunk/tools/build/v2/test/free_features_request.py
==============================================================================
--- (empty file)
+++ trunk/tools/build/v2/test/free_features_request.py	2007-09-01 17:46:09 EDT (Sat, 01 Sep 2007)
@@ -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()
Modified: trunk/tools/build/v2/test/test_all.py
==============================================================================
--- trunk/tools/build/v2/test/test_all.py	(original)
+++ trunk/tools/build/v2/test/test_all.py	2007-09-01 17:46:09 EDT (Sat, 01 Sep 2007)
@@ -150,6 +150,7 @@
           "example_libraries",
           "example_make",
           "remove_requirement",
+          "free_features_request",
           ]
 
 if os.name == 'posix':