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

Boost Jam code cleanup - moved code for creating new internal include targets into a single location (rules.c module) instead of having it done in two (rules.c & builtins.c modules).

[SVN r79584]
This commit is contained in:
Jurko Gospodnetić
2012-07-18 14:24:19 +00:00
parent 1961065003
commit 58beabb9dc
3 changed files with 45 additions and 44 deletions

View File

@@ -502,23 +502,12 @@ LIST * builtin_depends( FRAME * frame, int flags )
LISTITER end = list_end( targets );
for ( ; iter != end; iter = list_next( iter ) )
{
TARGET * t = bindtarget( list_item( iter ) );
TARGET * const t = bindtarget( list_item( iter ) );
/* If doing INCLUDES, switch to the TARGET's include TARGET, creating it
* if necessary. The internal include TARGET shares the name of its
* parent.
*/
if ( flags )
{
if ( !t->includes )
{
t->includes = copytarget( t );
t->includes->original_target = t;
}
t = t->includes;
}
t->depends = targetlist( t->depends, sources );
target_include_many( t, sources );
else
t->depends = targetlist( t->depends, sources );
}
/* Enter reverse links */

View File

@@ -46,23 +46,51 @@ static struct hash * targethash = 0;
/*
* target_include() - adds the 'included' TARGET to the list of targets included
* by the 'including' TARGET. Such targets are modeled as dependencies of the
* internal include node belonging to the 'including' TARGET.
* get_target_includes() - lazy creates a target's internal includes node
*
* The newly created node is not entered into the hash table as there should
* never be a need to bind them directly from a target names. If you want to
* access an internal includes node by name, first access the actual target and
* then read the internal includes node from there.
*/
void target_include( TARGET * including, TARGET * included )
static TARGET * get_target_includes( TARGET * const t )
{
TARGET * internal;
if ( !including->includes )
if ( !t->includes )
{
including->includes = copytarget( including );
including->includes->original_target = including;
TARGET * const i = (TARGET *)BJAM_MALLOC( sizeof( *t ) );
memset( (char *)i, '\0', sizeof( *i ) );
i->name = object_copy( t->name );
i->boundname = object_copy( i->name );
i->flags |= T_FLAG_NOTFILE | T_FLAG_INTERNAL;
i->original_target = t;
t->includes = i;
}
internal = including->includes;
return t->includes;
}
/*
* target_include() - adds a target to the given targe's 'included' list
* target_include_many() - adds targets to the given target's 'included' list
*
* Included targets are modeled as dependencies of the including target's
* internal include node.
*/
void target_include( TARGET * const including, TARGET * const included )
{
TARGET * const internal = get_target_includes( including );
internal->depends = targetentry( internal->depends, included );
}
void target_include_many( TARGET * const including, LIST * const included_names
)
{
TARGET * const internal = get_target_includes( including );
internal->depends = targetlist( internal->depends, included_names );
}
/*
* enter_rule() - return pointer to RULE, creating it if necessary in
@@ -178,23 +206,6 @@ void bind_explicitly_located_targets()
}
/*
* copytarget() - make a new target with the old target's name.
*
* Not entered into the hash table -- for internal nodes.
*/
TARGET * copytarget( TARGET const * ot )
{
TARGET * const t = (TARGET *)BJAM_MALLOC( sizeof( *t ) );
memset( (char *)t, '\0', sizeof( *t ) );
t->name = object_copy( ot->name );
t->boundname = object_copy( t->name );
t->flags |= T_FLAG_NOTFILE | T_FLAG_INTERNAL;
return t;
}
/*
* touch_target() - mark a target to simulate being new.
*/

View File

@@ -252,12 +252,13 @@ void rule_free ( RULE * );
/* Target related functions. */
void bind_explicitly_located_targets();
TARGET * bindtarget ( OBJECT * const );
TARGET * copytarget ( TARGET const * t );
void freetargets ( TARGETS * );
TARGETS * targetchain ( TARGETS *, TARGETS * );
TARGETS * targetentry ( TARGETS *, TARGET * );
void target_include ( TARGET * including,
TARGET * included );
void target_include ( TARGET * const including,
TARGET * const included );
void target_include_many ( TARGET * const including,
LIST * const included_names );
TARGETS * targetlist ( TARGETS *, LIST * target_names );
void touch_target ( OBJECT * const );
void clear_includes ( TARGET * );