Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r60157 - trunk/tools/jam/src
From: ghost_at_[hidden]
Date: 2010-03-04 18:02:58


Author: vladimir_prus
Date: 2010-03-04 18:02:57 EST (Thu, 04 Mar 2010)
New Revision: 60157
URL: http://svn.boost.org/trac/boost/changeset/60157

Log:
Implement PRECIOUS builtin.

Note that existing code already tried to assume that the 'together'
flag means precious, but as described at:
http://public.perforce.com:8080/@md=d&cd=//public/jam/src/&cdf=//public/jam/src/make1.c&c=klD@/1494?ac=10
this was not really wrong.

Now, PRECIOUS makes the target never removed. I plan to extend it so that
user can control what exit codes cause the target to be removed.

Text files modified:
   trunk/tools/jam/src/builtins.c | 20 ++++++++++++++++++++
   trunk/tools/jam/src/builtins.h | 1 +
   trunk/tools/jam/src/make1.c | 12 ++++++++++--
   trunk/tools/jam/src/rules.h | 2 ++
   4 files changed, 33 insertions(+), 2 deletions(-)

Modified: trunk/tools/jam/src/builtins.c
==============================================================================
--- trunk/tools/jam/src/builtins.c (original)
+++ trunk/tools/jam/src/builtins.c 2010-03-04 18:02:57 EST (Thu, 04 Mar 2010)
@@ -375,6 +375,12 @@
                         builtin_pad, 0, args );
       }
 
+ {
+ char * args[] = { "targets", "*", 0 };
+ bind_builtin( "PRECIOUS",
+ builtin_precious, 0, args );
+ }
+
       /* Initialize builtin modules. */
       init_set();
       init_path();
@@ -1685,6 +1691,20 @@
     }
 }
 
+LIST *builtin_precious( PARSE *parse, FRAME *frame )
+{
+ LIST* targets = lol_get(frame->args, 0);
+
+ for ( ; targets; targets = list_next( targets ) )
+ {
+ TARGET* t = bindtarget (targets->string);
+ t->flags |= T_FLAG_PRECIOUS;
+ }
+
+ return L0;
+}
+
+
 #ifdef HAVE_PYTHON
 
 LIST * builtin_python_import_rule( PARSE * parse, FRAME * frame )

Modified: trunk/tools/jam/src/builtins.h
==============================================================================
--- trunk/tools/jam/src/builtins.h (original)
+++ trunk/tools/jam/src/builtins.h 2010-03-04 18:02:57 EST (Thu, 04 Mar 2010)
@@ -59,6 +59,7 @@
 LIST *builtin_md5( PARSE *parse, FRAME *frame );
 LIST *builtin_file_open( PARSE *parse, FRAME *frame );
 LIST *builtin_pad( PARSE *parse, FRAME *frame );
+LIST *builtin_precious( PARSE *parse, FRAME *frame );
 
 void backtrace( FRAME *frame );
 

Modified: trunk/tools/jam/src/make1.c
==============================================================================
--- trunk/tools/jam/src/make1.c (original)
+++ trunk/tools/jam/src/make1.c 2010-03-04 18:02:57 EST (Thu, 04 Mar 2010)
@@ -839,12 +839,20 @@
     /* If the command was interrupted or failed and the target is not
      * "precious", remove the targets.
      */
- if ( ( status != EXEC_CMD_OK ) && !( cmd->rule->actions->flags & RULE_TOGETHER ) )
+ if (status != EXEC_CMD_OK)
     {
         LIST * targets = lol_get( &cmd->args, 0 );
         for ( ; targets; targets = list_next( targets ) )
- if ( !unlink( targets->string ) )
+ {
+ int need_unlink = 1;
+ TARGET* t = bindtarget ( targets->string );
+ if (t->flags & T_FLAG_PRECIOUS)
+ {
+ need_unlink = 0;
+ }
+ if (need_unlink && !unlink( targets->string ) )
                 printf( "...removing %s\n", targets->string );
+ }
     }
 
     /* Free this command and call make1c() to move onto the next one scheduled

Modified: trunk/tools/jam/src/rules.h
==============================================================================
--- trunk/tools/jam/src/rules.h (original)
+++ trunk/tools/jam/src/rules.h 2010-03-04 18:02:57 EST (Thu, 04 Mar 2010)
@@ -166,6 +166,8 @@
  */
 #define T_FLAG_ISFILE 0x0400
 
+#define T_FLAG_PRECIOUS 0x0800
+
     char binding; /* how target relates to a real file or
                                        * folder
                                        */


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