From 52c1c81918c23da3007db0ff8fa39c9e95cd69af Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Thu, 4 Mar 2010 23:02:57 +0000 Subject: [PATCH] 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. [SVN r60157] --- historic/jam/src/builtins.c | 20 ++++++++++++++++++++ historic/jam/src/builtins.h | 1 + historic/jam/src/make1.c | 12 ++++++++++-- historic/jam/src/rules.h | 2 ++ 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/historic/jam/src/builtins.c b/historic/jam/src/builtins.c index 66d178af7..4f94edc3a 100644 --- a/historic/jam/src/builtins.c +++ b/historic/jam/src/builtins.c @@ -375,6 +375,12 @@ void load_builtins() 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_pad( PARSE *parse, FRAME *frame ) } } +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 ) diff --git a/historic/jam/src/builtins.h b/historic/jam/src/builtins.h index ba37b87ea..1edaab738 100644 --- a/historic/jam/src/builtins.h +++ b/historic/jam/src/builtins.h @@ -59,6 +59,7 @@ LIST *builtin_shell( PARSE *parse, FRAME *frame ); 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 ); diff --git a/historic/jam/src/make1.c b/historic/jam/src/make1.c index 26ee5c41e..8001f3339 100644 --- a/historic/jam/src/make1.c +++ b/historic/jam/src/make1.c @@ -839,12 +839,20 @@ static void make1d( state * pState ) /* 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 diff --git a/historic/jam/src/rules.h b/historic/jam/src/rules.h index 9ad4171b6..78e056202 100644 --- a/historic/jam/src/rules.h +++ b/historic/jam/src/rules.h @@ -166,6 +166,8 @@ struct _target */ #define T_FLAG_ISFILE 0x0400 +#define T_FLAG_PRECIOUS 0x0800 + char binding; /* how target relates to a real file or * folder */