Boost logo

Boost-Commit :

From: steven_at_[hidden]
Date: 2008-07-17 23:11:08


Author: steven_watanabe
Date: 2008-07-17 23:11:08 EDT (Thu, 17 Jul 2008)
New Revision: 47536
URL: http://svn.boost.org/trac/boost/changeset/47536

Log:
Make dependency properties specified in project requirements
not cause errors in subprojects.

* build/property.jam
  (tranlate-dependencies) New rule to bind dependency
  properties to the project that they are specified in.

* build/property-set.jam
  (create-from-user-input) Add call to property.translate-dependencies

* test/test_all.py test/inherited_dependency.py
  Test case for this fix.

Added:
   trunk/tools/build/v2/test/inherited_dependency.py (contents, props changed)
Text files modified:
   trunk/tools/build/v2/build/property-set.jam | 5 +++++
   trunk/tools/build/v2/build/property.jam | 29 +++++++++++++++++++++++++++++
   trunk/tools/build/v2/test/test_all.py | 3 ++-
   3 files changed, 36 insertions(+), 1 deletions(-)

Modified: trunk/tools/build/v2/build/property-set.jam
==============================================================================
--- trunk/tools/build/v2/build/property-set.jam (original)
+++ trunk/tools/build/v2/build/property-set.jam 2008-07-17 23:11:08 EDT (Thu, 17 Jul 2008)
@@ -378,10 +378,15 @@
 #
 rule create-from-user-input ( raw-properties * : jamfile-module location )
 {
+ import project ;
+ import path ;
     local specification = [ property.translate-paths $(raw-properties)
         : $(location) ] ;
     specification = [ property.translate-indirect $(specification)
         : $(jamfile-module) ] ;
+ local project-id = [ project.attribute $(jamfile-module) id ] ;
+ project-id ?= [ path.root [ project.attribute $(jamfile-module) location ] [ path.pwd ] ] ;
+ specification = [ property.translate-dependencies $(specification) : $(project-id) ] ;
     specification =
         [ property.expand-subfeatures-in-conditions $(specification) ] ;
     specification = [ property.make $(specification) ] ;

Modified: trunk/tools/build/v2/build/property.jam
==============================================================================
--- trunk/tools/build/v2/build/property.jam (original)
+++ trunk/tools/build/v2/build/property.jam 2008-07-17 23:11:08 EDT (Thu, 17 Jul 2008)
@@ -511,6 +511,35 @@
     return $(result) ;
 }
 
+rule translate-dependencies ( specification * : project-id )
+{
+ local result ;
+ for local p in $(specification)
+ {
+ local split = [ split-conditional $(p) ] ;
+ local condition = "" ;
+ if $(split)
+ {
+ condition = $(split[1]): ;
+ p = $(split[2]) ;
+ }
+
+ if dependency in [ feature.attributes $(p:G) ]
+ {
+ if [ regex.match (.*//.*) : $(p:G=) ] {
+ result += $(condition)$(p) ;
+ } else {
+ result += $(condition)$(p:G)$(project-id)//$(p:G=) ;
+ }
+ }
+ else
+ {
+ result += $(condition)$(p) ;
+ }
+ }
+ return $(result) ;
+}
+
 
 # Class maintaining a property set -> string mapping.
 #

Added: trunk/tools/build/v2/test/inherited_dependency.py
==============================================================================
--- (empty file)
+++ trunk/tools/build/v2/test/inherited_dependency.py 2008-07-17 23:11:08 EDT (Thu, 17 Jul 2008)
@@ -0,0 +1,55 @@
+#!/usr/bin/python
+#
+# Copyright (c) 2008 Steven Watanabe
+#
+# 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
+
+tester = Tester()
+
+# test without giving the project an explicit id.
+tester.write("Jamroot", """
+ lib test : test.cpp ;
+ project : requirements <library>test ;
+ build-project a ;
+""")
+
+tester.write("test.cpp", """
+ #ifdef _WIN32
+ __declspec(dllexport)
+ #endif
+ void foo() {}
+""")
+
+tester.write("a/test1.cpp", """
+ int main() {}
+""")
+
+tester.write("a/Jamfile", """
+ exe test1 : test1.cpp ;
+""")
+
+tester.run_build_system()
+
+tester.expect_addition("bin/$toolset/debug/test.obj")
+tester.expect_addition("a/bin/$toolset/debug/test1.exe")
+
+tester.rm("bin")
+tester.rm("a/bin")
+
+# this time, do give the project an id.
+tester.write("Jamroot", """
+ lib test : test.cpp ;
+ project test_project : requirements <library>test ;
+ build-project a ;
+""")
+
+tester.run_build_system()
+
+tester.expect_addition("bin/$toolset/debug/test.obj")
+tester.expect_addition("a/bin/$toolset/debug/test1.exe")
+
+tester.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 2008-07-17 23:11:08 EDT (Thu, 17 Jul 2008)
@@ -168,7 +168,8 @@
           "remove_requirement",
           "free_features_request",
           "file_name_handling",
- "sort_rule"
+ "sort_rule",
+ "inherited_dependency"
           ]
 
 if os.name == 'posix':


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk