2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-15 13:02:11 +00:00

Change handling of generated headers to use the idea of

Matt Armstrong, from jamming mailing list.

* new/search.h
  (search): Add a new parameter 'another_target', which returns
  the name of a target already bound to the same location via LOCATE.

* new/search.c
  (search): Ajust the search algorithm to check for targets bound to searched
  directories.


[SVN r18887]
This commit is contained in:
Vladimir Prus
2003-06-30 14:10:04 +00:00
parent bd07b390f1
commit 8bcec068c6
14 changed files with 168 additions and 48 deletions

View File

@@ -367,7 +367,9 @@ compile_include(
/* include files are not built with make(). */
pushsettings( t->settings );
t->boundname = search( t->name, &t->time );
/* We don't expect that file to be included is generated by some
action. Therefore, pass 0 as third argument. */
t->boundname = search( t->name, &t->time, 0 );
popsettings( t->settings );
parse_file( t->boundname, frame );

View File

@@ -80,7 +80,9 @@ cache_name(void)
TARGET *t = bindtarget( hcachevar->string );
pushsettings( t->settings );
t->boundname = search( t->name, &t->time );
/* Don't expect cache file to be generated, so pass 0
as third argument to search. */
t->boundname = search( t->name, &t->time, 0 );
popsettings( t->settings );
if (hcachevar) {

View File

@@ -264,7 +264,18 @@ make0(
if( t->binding == T_BIND_UNBOUND && !( t->flags & T_FLAG_NOTFILE ) )
{
t->boundname = search( t->name, &t->time );
char* another_target;
t->boundname = search( t->name, &t->time, &another_target );
/* If it was detected that this target refers to an already
existing and bound one, we add include dependency, so that
every target which depends on us will depend on that other
target. */
if( another_target )
{
t->deps[T_DEPS_INCLUDES] = targetlist( t->deps[T_DEPS_INCLUDES],
list_new( L0, another_target ) );
}
t->binding = t->time ? T_BIND_EXISTS : T_BIND_MISSING;
}

View File

@@ -956,7 +956,7 @@ make1bind(
printf( "warning: using independent target %s\n", t->name );
pushsettings( t->settings );
t->boundname = search( t->name, &t->time );
t->boundname = search( t->name, &t->time, 0 );
t->binding = t->time ? T_BIND_EXISTS : T_BIND_MISSING;
popsettings( t->settings );
}

View File

@@ -152,29 +152,18 @@ static void bind_explicitly_located_target(void* xtarget, void* data)
TARGET* t = (TARGET*)xtarget;
if (! (t->flags & T_FLAG_NOTFILE) )
{
/* Check if there's a setting for LOCATE_TARGET */
/* Check if there's a setting for LOCATE */
SETTINGS* s = t->settings;
for(; s ; s = s->next)
{
if (strcmp(s->symbol, "LOCATE") == 0)
{
pushsettings(t->settings);
t->boundname = search( t->name, &t->time );
t->binding = t->time ? T_BIND_EXISTS : T_BIND_MISSING;
/* We're binding a target with explicit LOCATE. So
third argument is of now use: nothing will be returned
through it. */
t->boundname = search( t->name, &t->time, 0 );
popsettings(t->settings);
{
LOCATED_TARGET lt, *lta = <
lt.file_name = t->boundname;
lt.target = t;
if (!located_targets)
located_targets = hashinit( sizeof(LOCATED_TARGET),
"located targets" );
/* TODO: should check if we've entered the item or not. */
hashenter(located_targets, (HASHDATA **)&lta);
}
break;
}
}

View File

@@ -21,8 +21,16 @@
# include "newstr.h"
# include "compile.h"
# include "strings.h"
# include "hash.h"
# include <string.h>
typedef struct _binding {
char* binding;
char* target;
} BINDING;
static struct hash *explicit_bindings = 0;
void call_bind_rule(
char* target_,
char* boundname_ )
@@ -65,19 +73,42 @@ void call_bind_rule(
/*
* search.c - find a target along $(SEARCH) or $(LOCATE)
* First, check if LOCATE is set. If so, use it to determine
* the location of target and return, regardless of whether anything
* exists on that location.
*
* Second, examine all directories in SEARCH. If there's file already
* or there's another target with the same name which was placed
* to this location via LOCATE setting, stop and return the location.
* In case of previous target, return it's name via the third argument.
*
* This bevahiour allow to handle dependency on generated files. If
* caller does not expect that target is generated, 0 can be passed as
* the third argument.
*/
char *
search(
char *target,
time_t *time )
char *target,
time_t *time,
char **another_target
)
{
PATHNAME f[1];
LIST *varlist;
string buf[1];
int found = 0;
/* Will be set to 1 if target location is specified via LOCATE. */
int explicitly_located = 0;
char *boundname = 0;
if( another_target )
*another_target = 0;
if (! explicit_bindings )
explicit_bindings = hashinit( sizeof(BINDING),
"explicitly specified locations");
string_new( buf );
/* Parse the filename */
@@ -96,6 +127,8 @@ search(
if( DEBUG_SEARCH )
printf( "locate %s: %s\n", target, buf->value );
explicitly_located = 1;
timestamp( buf->value, time );
found = 1;
}
@@ -103,6 +136,8 @@ search(
{
while( varlist )
{
BINDING b, *ba = &b;
f->f_root.ptr = varlist->string;
f->f_root.len = strlen( varlist->string );
@@ -114,7 +149,19 @@ search(
timestamp( buf->value, time );
if( *time )
b.binding = buf->value;
if( hashcheck( explicit_bindings, (HASHDATA**)&ba ) )
{
if( DEBUG_SEARCH )
printf(" search %s: found explicitly located target %s\n",
target, ba->target);
if( another_target )
*another_target = ba->target;
found = 1;
break;
}
else if( *time )
{
found = 1;
break;
@@ -144,6 +191,15 @@ search(
boundname = newstr( buf->value );
string_free( buf );
if (explicitly_located)
{
BINDING b = {boundname, target}, *ba = &b;
/* CONSIDER: we probably should issue a warning is another file
is explicitly bound to the same location. This might break
compatibility, though. */
hashenter(explicit_bindings, (HASHDATA**)&ba);
}
/* prepare a call to BINDRULE if the variable is set */
call_bind_rule( target, boundname );

View File

@@ -8,4 +8,4 @@
* search.h - find a target along $(SEARCH) or $(LOCATE)
*/
char *search( char *target, time_t *time );
char *search( char *target, time_t *time, char **another_target );

View File

@@ -367,7 +367,9 @@ compile_include(
/* include files are not built with make(). */
pushsettings( t->settings );
t->boundname = search( t->name, &t->time );
/* We don't expect that file to be included is generated by some
action. Therefore, pass 0 as third argument. */
t->boundname = search( t->name, &t->time, 0 );
popsettings( t->settings );
parse_file( t->boundname, frame );

View File

@@ -80,7 +80,9 @@ cache_name(void)
TARGET *t = bindtarget( hcachevar->string );
pushsettings( t->settings );
t->boundname = search( t->name, &t->time );
/* Don't expect cache file to be generated, so pass 0
as third argument to search. */
t->boundname = search( t->name, &t->time, 0 );
popsettings( t->settings );
if (hcachevar) {

View File

@@ -264,7 +264,18 @@ make0(
if( t->binding == T_BIND_UNBOUND && !( t->flags & T_FLAG_NOTFILE ) )
{
t->boundname = search( t->name, &t->time );
char* another_target;
t->boundname = search( t->name, &t->time, &another_target );
/* If it was detected that this target refers to an already
existing and bound one, we add include dependency, so that
every target which depends on us will depend on that other
target. */
if( another_target )
{
t->deps[T_DEPS_INCLUDES] = targetlist( t->deps[T_DEPS_INCLUDES],
list_new( L0, another_target ) );
}
t->binding = t->time ? T_BIND_EXISTS : T_BIND_MISSING;
}

View File

@@ -956,7 +956,7 @@ make1bind(
printf( "warning: using independent target %s\n", t->name );
pushsettings( t->settings );
t->boundname = search( t->name, &t->time );
t->boundname = search( t->name, &t->time, 0 );
t->binding = t->time ? T_BIND_EXISTS : T_BIND_MISSING;
popsettings( t->settings );
}

View File

@@ -152,29 +152,18 @@ static void bind_explicitly_located_target(void* xtarget, void* data)
TARGET* t = (TARGET*)xtarget;
if (! (t->flags & T_FLAG_NOTFILE) )
{
/* Check if there's a setting for LOCATE_TARGET */
/* Check if there's a setting for LOCATE */
SETTINGS* s = t->settings;
for(; s ; s = s->next)
{
if (strcmp(s->symbol, "LOCATE") == 0)
{
pushsettings(t->settings);
t->boundname = search( t->name, &t->time );
t->binding = t->time ? T_BIND_EXISTS : T_BIND_MISSING;
/* We're binding a target with explicit LOCATE. So
third argument is of now use: nothing will be returned
through it. */
t->boundname = search( t->name, &t->time, 0 );
popsettings(t->settings);
{
LOCATED_TARGET lt, *lta = &lt;
lt.file_name = t->boundname;
lt.target = t;
if (!located_targets)
located_targets = hashinit( sizeof(LOCATED_TARGET),
"located targets" );
/* TODO: should check if we've entered the item or not. */
hashenter(located_targets, (HASHDATA **)&lta);
}
break;
}
}

View File

@@ -21,8 +21,16 @@
# include "newstr.h"
# include "compile.h"
# include "strings.h"
# include "hash.h"
# include <string.h>
typedef struct _binding {
char* binding;
char* target;
} BINDING;
static struct hash *explicit_bindings = 0;
void call_bind_rule(
char* target_,
char* boundname_ )
@@ -65,19 +73,42 @@ void call_bind_rule(
/*
* search.c - find a target along $(SEARCH) or $(LOCATE)
* First, check if LOCATE is set. If so, use it to determine
* the location of target and return, regardless of whether anything
* exists on that location.
*
* Second, examine all directories in SEARCH. If there's file already
* or there's another target with the same name which was placed
* to this location via LOCATE setting, stop and return the location.
* In case of previous target, return it's name via the third argument.
*
* This bevahiour allow to handle dependency on generated files. If
* caller does not expect that target is generated, 0 can be passed as
* the third argument.
*/
char *
search(
char *target,
time_t *time )
char *target,
time_t *time,
char **another_target
)
{
PATHNAME f[1];
LIST *varlist;
string buf[1];
int found = 0;
/* Will be set to 1 if target location is specified via LOCATE. */
int explicitly_located = 0;
char *boundname = 0;
if( another_target )
*another_target = 0;
if (! explicit_bindings )
explicit_bindings = hashinit( sizeof(BINDING),
"explicitly specified locations");
string_new( buf );
/* Parse the filename */
@@ -96,6 +127,8 @@ search(
if( DEBUG_SEARCH )
printf( "locate %s: %s\n", target, buf->value );
explicitly_located = 1;
timestamp( buf->value, time );
found = 1;
}
@@ -103,6 +136,8 @@ search(
{
while( varlist )
{
BINDING b, *ba = &b;
f->f_root.ptr = varlist->string;
f->f_root.len = strlen( varlist->string );
@@ -114,7 +149,19 @@ search(
timestamp( buf->value, time );
if( *time )
b.binding = buf->value;
if( hashcheck( explicit_bindings, (HASHDATA**)&ba ) )
{
if( DEBUG_SEARCH )
printf(" search %s: found explicitly located target %s\n",
target, ba->target);
if( another_target )
*another_target = ba->target;
found = 1;
break;
}
else if( *time )
{
found = 1;
break;
@@ -144,6 +191,15 @@ search(
boundname = newstr( buf->value );
string_free( buf );
if (explicitly_located)
{
BINDING b = {boundname, target}, *ba = &b;
/* CONSIDER: we probably should issue a warning is another file
is explicitly bound to the same location. This might break
compatibility, though. */
hashenter(explicit_bindings, (HASHDATA**)&ba);
}
/* prepare a call to BINDRULE if the variable is set */
call_bind_rule( target, boundname );

View File

@@ -8,4 +8,4 @@
* search.h - find a target along $(SEARCH) or $(LOCATE)
*/
char *search( char *target, time_t *time );
char *search( char *target, time_t *time, char **another_target );