$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r83848 - trunk/tools/build/v2/build
From: steven_at_[hidden]
Date: 2013-04-11 16:23:45
Author: steven_watanabe
Date: 2013-04-11 16:23:43 EDT (Thu, 11 Apr 2013)
New Revision: 83848
URL: http://svn.boost.org/trac/boost/changeset/83848
Log:
Optimizations in virtual-target.add-prefix-and-suffix.
Text files modified: 
   trunk/tools/build/v2/build/property-set.jam |    11 +++++++++                               
   trunk/tools/build/v2/build/property.jam     |    46 +++++++++++++++++++++++++++------------ 
   trunk/tools/build/v2/build/type.jam         |    43 ++++++++----------------------------    
   3 files changed, 53 insertions(+), 47 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	2013-04-11 16:23:43 EDT (Thu, 11 Apr 2013)
@@ -298,6 +298,17 @@
         return $($(feature)) ;
     }
 
+    # Returns true if the property-set contains all the
+    # specified properties.
+    #
+    rule contains-raw ( properties * )
+    {
+        if $(properties) in $(self.raw)
+        {
+            return true ;
+        }
+    }
+
     # private
 
     rule init-base ( )
Modified: trunk/tools/build/v2/build/property.jam
==============================================================================
--- trunk/tools/build/v2/build/property.jam	(original)
+++ trunk/tools/build/v2/build/property.jam	2013-04-11 16:23:43 EDT (Thu, 11 Apr 2013)
@@ -742,11 +742,10 @@
 
     # Associate 'value' with 'properties'.
     #
-    rule insert ( properties + : value )
+    rule insert ( properties * : value )
     {
-        self.all-flags += $(self.next-flag) ;
-        self.properties.$(self.next-flag) = $(properties) ;
-        self.value.$(self.next-flag) = $(value) ;
+        self.all-flags += self.$(self.next-flag) ;
+        self.$(self.next-flag) = $(value) $(properties) ;
 
         self.next-flag = [ numbers.increment $(self.next-flag) ] ;
     }
@@ -755,25 +754,44 @@
     # more than one subset has a value assigned to it, returns the value for the
     # longest subset, if it is unique.
     #
-    rule find ( properties + )
+    rule find ( property-set )
     {
-        return [ find-replace $(properties) ] ;
+        # First find all matches.
+        local matches ;
+        local match-ranks ;
+        for local i in $(self.all-flags)
+        {
+            local list = $($(i)) ;
+            if [ $(property-set).contains-raw $(list[2-]) ] 
+            {
+                matches += $(list[1]) ;
+                match-ranks += [ sequence.length $(list) ] ;
+            }
+        }
+        local best = [ sequence.select-highest-ranked $(matches)
+            : $(match-ranks) ] ;
+        if $(best[2])
+        {
+            import errors : error : errors.error ;
+            errors.error "Ambiguous key $(properties:J= :E=)" ;
+        }
+        return $(best) ;
     }
 
     # Returns the value associated with 'properties'. If 'value' parameter is
     # given, replaces the found value.
     #
-    rule find-replace ( properties + : value ? )
+    rule find-replace ( properties * : value ? )
     {
         # First find all matches.
         local matches ;
         local match-ranks ;
         for local i in $(self.all-flags)
         {
-            if $(self.properties.$(i)) in $(properties)
+            if $($(i)[2-]) in $(properties)
             {
                 matches += $(i) ;
-                match-ranks += [ sequence.length $(self.properties.$(i)) ] ;
+                match-ranks += [ sequence.length $($(i)) ] ;
             }
         }
         local best = [ sequence.select-highest-ranked $(matches)
@@ -783,10 +801,10 @@
             import errors : error : errors.error ;
             errors.error "Ambiguous key $(properties:J= :E=)" ;
         }
-        local original = $(self.value.$(best)) ;
+        local original = $($(best)[1]) ;
         if $(value)
         {
-            self.value.$(best) = $(value) ;
+            $(best) = $(value) $($(best)[2-]) ;
         }
         return $(original) ;
     }
@@ -901,12 +919,12 @@
     $(pm).insert <toolset>gcc <os>NT : obj ;
     $(pm).insert <toolset>gcc <os>CYGWIN : obj ;
 
-    assert.equal o : [ $(pm).find <toolset>gcc ] ;
+    assert.equal o : [ $(pm).find-replace <toolset>gcc ] ;
 
-    assert.equal obj : [ $(pm).find <toolset>gcc <os>NT ] ;
+    assert.equal obj : [ $(pm).find-replace <toolset>gcc <os>NT ] ;
 
     try ;
-        $(pm).find <toolset>gcc <os>NT <os>CYGWIN ;
+        $(pm).find-replace <toolset>gcc <os>NT <os>CYGWIN ;
     catch "Ambiguous key <toolset>gcc <os>NT <os>CYGWIN" ;
 
     # Test ordinary properties.
Modified: trunk/tools/build/v2/build/type.jam
==============================================================================
--- trunk/tools/build/v2/build/type.jam	(original)
+++ trunk/tools/build/v2/build/type.jam	2013-04-11 16:23:43 EDT (Thu, 11 Apr 2013)
@@ -54,6 +54,12 @@
         .base.$(type) = $(base-type) ;
         .derived.$(base-type) += $(type) ;
 
+        # Store suffixes for generated targets.
+        .suffixes.$(type) = [ new property-map ] ;
+
+        # Store prefixes for generated targets (e.g. "lib" for library).
+        .prefixes.$(type) = [ new property-map ] ;
+
         if $(suffixes)-is-defined
         {
             # Specify mapping from suffixes to type.
@@ -233,11 +239,6 @@
 }
 
 
-# Store suffixes for generated targets.
-.suffixes = [ new property-map ] ;
-
-# Store prefixes for generated targets (e.g. "lib" for library).
-.prefixes = [ new property-map ] ;
 
 
 # Sets a file suffix to be used when generating a target of 'type' with the
@@ -309,15 +310,13 @@
 
 local rule set-generated-target-ps ( ps : type : properties * : psval )
 {
-    properties = <target-type>$(type) $(properties) ;
-    $(.$(ps)es).insert $(properties) : $(psval) ;
+    $(.$(ps)es.$(type)).insert $(properties) : $(psval) ;
 }
 
 
 local rule change-generated-target-ps ( ps : type : properties * : psval )
 {
-    properties = <target-type>$(type) $(properties) ;
-    local prev = [ $(.$(ps)es).find-replace $(properties) : $(psval) ] ;
+    local prev = [ $(.$(ps)es.$(type)).find-replace $(properties) : $(psval) ] ;
     if ! $(prev)
     {
         set-generated-target-ps $(ps) : $(type) : $(properties) : $(psval) ;
@@ -330,13 +329,13 @@
 # 'ps' can be either "prefix" or "suffix".  If no prefix/suffix is specified for
 # 'type', returns prefix/suffix for base type, if any.
 #
-local rule generated-target-ps-real ( ps : type : properties * )
+local rule generated-target-ps ( ps : type : property-set )
 {
     local result ;
     local found ;
     while $(type) && ! $(found)
     {
-        result = [ $(.$(ps)es).find <target-type>$(type) $(properties) ] ;
+        result = [ $(.$(ps)es.$(type)).find $(property-set) ] ;
         # If the prefix/suffix is explicitly set to an empty string, we consider
         # prefix/suffix to be found. If we were not to compare with "", there
         # would be no way to specify an empty prefix/suffix.
@@ -354,28 +353,6 @@
 }
 
 
-local rule generated-target-ps ( ps : type : property-set )
-{
-    local key = .$(ps).$(type).$(property-set) ;
-    local v = $($(key)) ;
-    if ! $(v)
-    {
-        v = [ generated-target-ps-real $(ps) : $(type) : [ $(property-set).raw ]
-            ] ;
-        if ! $(v)
-        {
-            v = none ;
-        }
-        $(key) = $(v) ;
-    }
-
-    if $(v) != none
-    {
-        return $(v) ;
-    }
-}
-
-
 # Returns file type given its name. If there are several dots in filename, tries
 # each suffix. E.g. for name of "file.so.1.2" suffixes "2", "1", and "so" will
 # be tried.