$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r83858 - trunk/tools/build/v2/engine
From: steven_at_[hidden]
Date: 2013-04-12 16:36:53
Author: steven_watanabe
Date: 2013-04-12 16:36:52 EDT (Fri, 12 Apr 2013)
New Revision: 83858
URL: http://svn.boost.org/trac/boost/changeset/83858
Log:
Separate the code for recording explicit bindings from search.
Text files modified: 
   trunk/tools/build/v2/engine/rules.c  |    10 +----                                   
   trunk/tools/build/v2/engine/search.c |    68 +++++++++++++++++++++++++-------------- 
   trunk/tools/build/v2/engine/search.h |     1                                         
   3 files changed, 47 insertions(+), 32 deletions(-)
Modified: trunk/tools/build/v2/engine/rules.c
==============================================================================
--- trunk/tools/build/v2/engine/rules.c	(original)
+++ trunk/tools/build/v2/engine/rules.c	2013-04-12 16:36:52 EDT (Fri, 12 Apr 2013)
@@ -183,15 +183,9 @@
         SETTINGS * s = t->settings;
         for ( ; s ; s = s->next )
         {
-            if ( strcmp( object_str( s->symbol ), "LOCATE" ) == 0 )
+            if ( object_equal( s->symbol, constant_LOCATE ) && ! list_empty( s->value ) )
             {
-                pushsettings( root_module(), t->settings );
-                /* We are binding a target with explicit LOCATE. So third
-                 * argument is of no use: nothing will be returned through it.
-                 */
-                object_free( t->boundname );
-                t->boundname = search( t->name, &t->time, 0, 0 );
-                popsettings( root_module(), t->settings );
+                set_explicit_binding( t->name, list_front( s->value ) );
                 break;
             }
         }
Modified: trunk/tools/build/v2/engine/search.c
==============================================================================
--- trunk/tools/build/v2/engine/search.c	(original)
+++ trunk/tools/build/v2/engine/search.c	2013-04-12 16:36:52 EDT (Fri, 12 Apr 2013)
@@ -69,6 +69,50 @@
     }
 }
 
+/* Records the binding of a target with an explicit LOCATE. */
+void set_explicit_binding( OBJECT * target, OBJECT * locate )
+{
+    OBJECT * boundname;
+    OBJECT * key;
+    PATHNAME f[ 1 ];
+    string buf[ 1 ];
+    int found;
+    BINDING * ba;
+
+    if ( !explicit_bindings )
+        explicit_bindings = hashinit( sizeof( BINDING ), "explicitly specified "
+            "locations" );
+
+    string_new( buf );
+
+    /* Parse the filename. */
+    path_parse( object_str( target ), f );
+
+    /* Ignore the grist. */
+    f->f_grist.ptr = 0;
+    f->f_grist.len = 0;
+
+    /* Root the target path at the given location. */
+    f->f_root.ptr = object_str( locate );
+    f->f_root.len = strlen( object_str( locate ) );
+
+    path_build( f, buf );
+    boundname = object_new( buf->value );
+    if ( DEBUG_SEARCH )
+        printf( "explicit locate %s: %s\n", object_str( target ), buf->value );
+    string_free( buf );
+    key = path_as_key( boundname );
+    object_free( boundname );
+
+    ba = (BINDING *)hash_insert( explicit_bindings, key, &found );
+    if ( !found )
+    {
+        ba->binding = key;
+        ba->target = target;
+    }
+    else
+        object_free( key );
+}
 
 /*
  * search.c - find a target along $(SEARCH) or $(LOCATE).
@@ -96,9 +140,6 @@
     int found = 0;
     OBJECT * boundname = 0;
 
-    /* Set to 1 if target location is specified via LOCATE. */
-    int explicitly_located = 0;
-
     if ( another_target )
         *another_target = 0;
 
@@ -126,8 +167,6 @@
         if ( DEBUG_SEARCH )
             printf( "locate %s: %s\n", object_str( target ), buf->value );
 
-        explicitly_located = 1;
-
         key = object_new( buf->value );
         timestamp_from_path( time, key );
         object_free( key );
@@ -209,25 +248,6 @@
     boundname = object_new( buf->value );
     string_free( buf );
 
-    if ( explicitly_located )
-    {
-        int found;
-        BINDING * ba;
-        OBJECT * const key = path_as_key( boundname );
-        /* CONSIDER: We should probably issue a warning if another file is
-         * explicitly bound to the same location. This might break
-         * compatibility, though.
-         */
-        ba = (BINDING *)hash_insert( explicit_bindings, key, &found );
-        if ( !found )
-        {
-            ba->binding = key;
-            ba->target = target;
-        }
-        else
-            object_free( key );
-    }
-
     /* Prepare a call to BINDRULE if the variable is set. */
     call_bind_rule( target, boundname );
 
Modified: trunk/tools/build/v2/engine/search.h
==============================================================================
--- trunk/tools/build/v2/engine/search.h	(original)
+++ trunk/tools/build/v2/engine/search.h	2013-04-12 16:36:52 EDT (Fri, 12 Apr 2013)
@@ -14,6 +14,7 @@
 #include "object.h"
 #include "timestamp.h"
 
+void set_explicit_binding( OBJECT * target, OBJECT * locate );
 OBJECT * search( OBJECT * target, timestamp * const time,
     OBJECT * * another_target, int const file );
 void search_done( void );