Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r79584 - trunk/tools/build/v2/engine
From: jurko.gospodnetic_at_[hidden]
Date: 2012-07-18 10:24:20


Author: jurko
Date: 2012-07-18 10:24:19 EDT (Wed, 18 Jul 2012)
New Revision: 79584
URL: http://svn.boost.org/trac/boost/changeset/79584

Log:
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).
Text files modified:
   trunk/tools/build/v2/engine/builtins.c | 19 ++---------
   trunk/tools/build/v2/engine/rules.c | 63 +++++++++++++++++++++++----------------
   trunk/tools/build/v2/engine/rules.h | 7 ++-
   3 files changed, 45 insertions(+), 44 deletions(-)

Modified: trunk/tools/build/v2/engine/builtins.c
==============================================================================
--- trunk/tools/build/v2/engine/builtins.c (original)
+++ trunk/tools/build/v2/engine/builtins.c 2012-07-18 10:24:19 EDT (Wed, 18 Jul 2012)
@@ -502,23 +502,12 @@
     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 */

Modified: trunk/tools/build/v2/engine/rules.c
==============================================================================
--- trunk/tools/build/v2/engine/rules.c (original)
+++ trunk/tools/build/v2/engine/rules.c 2012-07-18 10:24:19 EDT (Wed, 18 Jul 2012)
@@ -46,23 +46,51 @@
 
 
 /*
- * 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
@@ -179,23 +207,6 @@
 
 
 /*
- * 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.
  */
 

Modified: trunk/tools/build/v2/engine/rules.h
==============================================================================
--- trunk/tools/build/v2/engine/rules.h (original)
+++ trunk/tools/build/v2/engine/rules.h 2012-07-18 10:24:19 EDT (Wed, 18 Jul 2012)
@@ -252,12 +252,13 @@
 /* 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 * );


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