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

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]
This commit is contained in:
Vladimir Prus
2010-03-04 23:02:57 +00:00
parent 5f9ec50378
commit 52c1c81918
4 changed files with 33 additions and 2 deletions

View File

@@ -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 )

View File

@@ -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 );

View File

@@ -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

View File

@@ -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
*/