summaryrefslogtreecommitdiff
path: root/tools/build/v2/engine/command.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/build/v2/engine/command.c')
-rw-r--r--tools/build/v2/engine/command.c34
1 files changed, 14 insertions, 20 deletions
diff --git a/tools/build/v2/engine/command.c b/tools/build/v2/engine/command.c
index d2ea068149..8161014c05 100644
--- a/tools/build/v2/engine/command.c
+++ b/tools/build/v2/engine/command.c
@@ -33,10 +33,11 @@
CMD * cmd_new( RULE * rule, LIST * targets, LIST * sources, LIST * shell )
{
CMD * cmd = (CMD *)BJAM_MALLOC( sizeof( CMD ) );
+ LISTITER iter = list_begin( shell ), end = list_end( shell );
/* Lift line-length limitation entirely when JAMSHELL is just "%". */
- int no_limit = ( shell && !strcmp(shell->string,"%") && !list_next(shell) );
+ int no_limit = ( iter != end && !strcmp( object_str( list_item( iter ) ), "%") && list_next( iter ) == end );
int max_line = MAXLINE;
- int allocated = -1;
+ FRAME frame[1];
cmd->rule = rule;
cmd->shell = shell;
@@ -45,27 +46,20 @@ CMD * cmd_new( RULE * rule, LIST * targets, LIST * sources, LIST * shell )
lol_init( &cmd->args );
lol_add( &cmd->args, targets );
lol_add( &cmd->args, sources );
- cmd->buf = 0;
+ string_new( cmd->buf );
- do
- {
- BJAM_FREE( cmd->buf ); /* free any buffer from previous iteration */
-
- cmd->buf = (char*)BJAM_MALLOC_ATOMIC( max_line + 1 );
-
- if ( cmd->buf == 0 )
- break;
-
- allocated = var_string( rule->actions->command, cmd->buf, max_line, &cmd->args );
-
- max_line = max_line * 2;
- }
- while ( ( allocated < 0 ) && ( max_line < INT_MAX / 2 ) );
+ frame_init( frame );
+ frame->module = rule->module;
+ lol_init( frame->args );
+ lol_add( frame->args, list_copy( targets ) );
+ lol_add( frame->args, list_copy( sources ) );
+ function_run_actions( rule->actions->command, frame, stack_global(), cmd->buf );
+ frame_free( frame );
if ( !no_limit )
{
/* Bail if the result will not fit in MAXLINE. */
- char * s = cmd->buf;
+ char * s = cmd->buf->value;
while ( *s )
{
size_t l = strcspn( s, "\n" );
@@ -95,6 +89,6 @@ void cmd_free( CMD * cmd )
{
lol_free( &cmd->args );
list_free( cmd->shell );
- BJAM_FREE( cmd->buf );
- BJAM_FREE( (char *)cmd );
+ string_free( cmd->buf );
+ BJAM_FREE( (void *)cmd );
}