Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r48596 - in trunk/tools/build/v2: build test
From: jurko.gospodnetic_at_[hidden]
Date: 2008-09-04 21:58:08


Author: jurko
Date: 2008-09-04 21:58:07 EDT (Thu, 04 Sep 2008)
New Revision: 48596
URL: http://svn.boost.org/trac/boost/changeset/48596

Log:
Added a test for and fixed a Boost Build generator selection bug caused by caching viable source target types for different target types and generators and not maintaining those caches when their content gets invalidated by defining a new derived target type. Currently quick-fixed by clearing most of the cached values when registering a new derived target type. Later on this could be made more detailed by clearing only the actually invalidated cache values or updating them directly by simply added the derived target type to them.
Text files modified:
   trunk/tools/build/v2/build/generators.jam | 2
   trunk/tools/build/v2/build/type.jam | 13 +++++++++++
   trunk/tools/build/v2/test/generator_selection.py | 44 ++++++++++++++++++++++++++++++++++++++++
   3 files changed, 58 insertions(+), 1 deletions(-)

Modified: trunk/tools/build/v2/build/generators.jam
==============================================================================
--- trunk/tools/build/v2/build/generators.jam (original)
+++ trunk/tools/build/v2/build/generators.jam 2008-09-04 21:58:07 EDT (Thu, 04 Sep 2008)
@@ -63,7 +63,7 @@
 # something invalidates those cached values by possibly causing some new source
 # types to become viable.
 #
-local rule invalidate-extendable-viable-source-target-type-cache ( )
+rule invalidate-extendable-viable-source-target-type-cache ( )
 {
     local generators-with-cached-source-types = $(.vstg-cached-generators) ;
     .vstg-cached-generators = ;

Modified: trunk/tools/build/v2/build/type.jam
==============================================================================
--- trunk/tools/build/v2/build/type.jam (original)
+++ trunk/tools/build/v2/build/type.jam 2008-09-04 21:58:07 EDT (Thu, 04 Sep 2008)
@@ -76,6 +76,19 @@
         .main-target-type.$(main-rule-name) = $(type) ;
 
         IMPORT $(__name__) : main-target-rule : : $(main-rule-name) ;
+
+ # This is a hack to invalidate generator selection related cached viable
+ # source target type information because it adding a new derived target
+ # type logically adds the new type to the any viable source target type
+ # lists already containing its base type.
+ #
+ # We can improve the current implementation by not clearing the whole
+ # cache but simply updating the cached values. That might be more
+ # performant but needs to be tested and implemented at a later time.
+ if $(base-type)
+ {
+ generators.invalidate-extendable-viable-source-target-type-cache ;
+ }
     }
 }
 

Modified: trunk/tools/build/v2/test/generator_selection.py
==============================================================================
--- trunk/tools/build/v2/test/generator_selection.py (original)
+++ trunk/tools/build/v2/test/generator_selection.py 2008-09-04 21:58:07 EDT (Thu, 04 Sep 2008)
@@ -58,9 +58,53 @@
 
 ################################################################################
 #
+# test_using_a_derived_source_type_created_after_generator_already_used()
+# -----------------------------------------------------------------------
+#
+################################################################################
+
+def test_using_a_derived_source_type_created_after_generator_already_used():
+ """Regression test for a Boost Build bug causing it to not use a generator
+ with a source type derived from one of the generator's sources but created
+ only after already using the generateor.
+ """
+
+ t = BoostBuild.Tester()
+
+ t.write("dummy.cpp", "void f() {}\n")
+
+ t.write("jamroot.jam", """
+# Building this dummy target must not cause a later defined UNGA_CPP target type
+# not to be recognized as a viable source type for building OBJ targets.
+obj dummy : dummy.cpp ;
+alias the-test-output : Other//other-obj ;
+""")
+
+ t.write("Other/source.unga_cpp", "void g() {}\n")
+
+ t.write("Other/jamfile.jam", """
+import type ;
+type.register UNGA_CPP : unga_cpp : CPP ;
+# We are careful not to do anything between defining our new UNGA_CPP target
+# type and using the CPP --> OBJ generator that could potentially cover the
+# Boost Build bug by clearing its internal viable source target type state.
+obj other-obj : source.unga_cpp ;
+""")
+
+ t.run_build_system()
+ t.expect_addition("bin/$toolset/debug/dummy.obj")
+ t.expect_addition("Other/bin/$toolset/debug/other-obj.obj")
+ t.expect_nothing_more()
+
+ t.cleanup()
+
+
+################################################################################
+#
 # main()
 # ------
 #
 ################################################################################
 
 test_generator_added_after_already_building_a_target_of_its_target_type()
+test_using_a_derived_source_type_created_after_generator_already_used()


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