Update of /cvsroot/boost/boost/tools/jam/src
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv30148

Modified Files:
      Tag: Boost_Jam_994
        execcmd.h execmac.c execnt.c execunix.c execvms.c make1.c 
Log Message:
Added initial dart support to execcmd and make1.

Updated the execcmd closure function signature to pass the executed 
command string and the command output into the make_closure function.



Index: execcmd.h
===================================================================
RCS file: /cvsroot/boost/boost/tools/jam/src/execcmd.h,v
retrieving revision 1.3.6.2
retrieving revision 1.3.6.3
diff -u -d -r1.3.6.2 -r1.3.6.3
--- execcmd.h   2 Jun 2007 21:55:30 -0000       1.3.6.2
+++ execcmd.h   4 Jun 2007 23:38:42 -0000       1.3.6.3
@@ -19,7 +19,7 @@
 
 void execcmd(
        char *string,
-       void (*func)( void *closure, int status, timing_info* ),
+       void (*func)( void *closure, int status, timing_info*, char *, char * ),
        void *closure,
        LIST *shell,
         char *action,

Index: execmac.c
===================================================================
RCS file: /cvsroot/boost/boost/tools/jam/src/execmac.c,v
retrieving revision 1.2
retrieving revision 1.2.36.1
diff -u -d -r1.2 -r1.2.36.1
--- execmac.c   6 Nov 2001 15:36:16 -0000       1.2
+++ execmac.c   4 Jun 2007 23:38:42 -0000       1.2.36.1
@@ -47,7 +47,7 @@
 void
 execcmd( 
        char *string,
-       void (*func)( void *closure, int status ),
+        void (*func)( void *closure, int status, timing_info*, char *, char * 
),
        void *closure,
        LIST *shell )
 {

Index: execnt.c
===================================================================
RCS file: /cvsroot/boost/boost/tools/jam/src/execnt.c,v
retrieving revision 1.32.2.1
retrieving revision 1.32.2.2
diff -u -d -r1.32.2.1 -r1.32.2.2
--- execnt.c    2 Jun 2007 00:45:48 -0000       1.32.2.1
+++ execnt.c    4 Jun 2007 23:38:42 -0000       1.32.2.2
@@ -498,7 +498,7 @@
 void
 execcmd( 
     char *string,
-    void (*func)( void *closure, int status, timing_info* ),
+    void (*func)( void *closure, int status, timing_info*, char 
*invoked_command, char *command_output),
     void *closure,
     LIST *shell,
     char *rule_name,

Index: execunix.c
===================================================================
RCS file: /cvsroot/boost/boost/tools/jam/src/execunix.c,v
retrieving revision 1.10.2.10
retrieving revision 1.10.2.11
diff -u -d -r1.10.2.10 -r1.10.2.11
--- execunix.c  3 Jun 2007 20:14:46 -0000       1.10.2.10
+++ execunix.c  4 Jun 2007 23:38:42 -0000       1.10.2.11
@@ -65,13 +65,14 @@
 
 static struct
 {
-    int            pid;        /* on win32, a real process handle */
-    int     fd[2];         /* file descriptors for stdout and stderr */
-    FILE   *stream[2];     /* child's stdout (0) and stderr (1) file stream */
-    int     com_len;    /* length of comamnd buffer */
-    char   *command;    /* buffer to hold command rule being invoked */
-    char   *buffer[2];     /* buffer to hold stdout and stderr, if any */
-    void    (*func)( void *closure, int status, timing_info* );
+    int            pid;              /* on win32, a real process handle */
+    int     fd[2];            /* file descriptors for stdout and stderr */
+    FILE   *stream[2];        /* child's stdout (0) and stderr (1) file stream 
*/
+    int     com_len;          /* length of comamnd buffer */
+    char   *action_target;    /* buffer to hold action and target invoked */
+    char   *command;          /* buffer to hold command being invoked */
+    char   *buffer[2];        /* buffer to hold stdout and stderr, if any */
+    void    (*func)( void *closure, int status, timing_info*, char *, char * );
     void   *closure;
 } cmdtab[ MAXJOBS ] = {{0}};
 
@@ -93,7 +94,7 @@
 void
 execcmd( 
        char *string,
-       void (*func)( void *closure, int status, timing_info* ),
+       void (*func)( void *closure, int status, timing_info*, char *, char * ),
        void *closure,
        LIST *shell,
         char *action,
@@ -156,6 +157,10 @@
        /* increment jobs running */
        ++cmdsrunning;
 
+        /* save off actual command string */
+        cmdtab[ slot ].command = BJAM_MALLOC_ATOMIC(strlen(string)+1);
+        strcpy(cmdtab[slot].command, string);
+
         /* create pipe from child to parent */
 
         if (pipe(out) < 0)
@@ -230,18 +235,18 @@
             len = strlen(action) + strlen(target) + 2;
             if (cmdtab[slot].com_len < len) 
             {
-                BJAM_FREE(cmdtab[ slot ].command);
-                cmdtab[ slot ].command = BJAM_MALLOC_ATOMIC(len);
+                BJAM_FREE(cmdtab[ slot ].action_target);
+                cmdtab[ slot ].action_target = BJAM_MALLOC_ATOMIC(len);
                 cmdtab[ slot ].com_len = len;
             }
-            strcpy(cmdtab[ slot ].command, action);
-            strcat(cmdtab[ slot ].command, " ");
-            strcat(cmdtab[ slot ].command, target);
+            strcpy(cmdtab[ slot ].action_target, action);
+            strcat(cmdtab[ slot ].action_target, " ");
+            strcat(cmdtab[ slot ].action_target, target);
         }
         else
         {
-            BJAM_FREE(cmdtab[ slot ].command);
-            cmdtab[ slot ].command = 0;
+            BJAM_FREE(cmdtab[ slot ].action_target);
+            cmdtab[ slot ].action_target= 0;
             cmdtab[ slot ].com_len = 0;
         }
 
@@ -387,9 +392,9 @@
                         times(&old_time);
 
                         /* print out the rule and target name */
-                        if (cmdtab[i].command)
+                        if (cmdtab[i].action_target)
                         {
-                            printf("%s\n", cmdtab[i].command);
+                            printf("%s\n", cmdtab[i].action_target);
 
                             /* print out the command output, if requested */
                             if (globs.pipe_action & STDOUT_FILENO || 
@@ -400,7 +405,7 @@
                                     printf("%s", cmdtab[i].buffer[OUT]);
                                     if (globs.pipe_action & STDERR_FILENO)
                                         if (cmdtab[i].buffer[ERR])
-                                            fprintf(stderr, "%s\n", 
cmdtab[i].command);
+                                            fprintf(stderr, "%s\n", 
cmdtab[i].action_target);
                                 }
                             }
 
@@ -409,12 +414,6 @@
                                     fprintf(stderr, "%s", 
cmdtab[i].buffer[ERR]);
                         }
 
-                        BJAM_FREE(cmdtab[i].buffer[OUT]);
-                        cmdtab[i].buffer[OUT] = 0;
-
-                        BJAM_FREE(cmdtab[i].buffer[ERR]);
-                        cmdtab[i].buffer[ERR] = 0;
-
                         times(&new_time);
 
                         time.system = (double)(new_time.tms_cstime - 
old_time.tms_cstime) / CLOCKS_PER_SEC;
@@ -431,7 +430,17 @@
                         else
                             rstat = EXEC_CMD_OK;
 
-                        (*cmdtab[ i ].func)( cmdtab[ i ].closure, rstat, &time 
);
+                        /* assume -p0 in effect so only pass buffer[0] 
containing merged output */
+                        (*cmdtab[ i ].func)( cmdtab[ i ].closure, rstat, 
&time, cmdtab[i].command, cmdtab[i].buffer[0] );
+
+                        BJAM_FREE(cmdtab[i].buffer[OUT]);
+                        cmdtab[i].buffer[OUT] = 0;
+
+                        BJAM_FREE(cmdtab[i].buffer[ERR]);
+                        cmdtab[i].buffer[ERR] = 0;
+
+                        BJAM_FREE(cmdtab[i].command);
+                        cmdtab[i].command = 0;
 
                         cmdtab[i].func = 0;
                         cmdtab[i].closure = 0;

Index: execvms.c
===================================================================
RCS file: /cvsroot/boost/boost/tools/jam/src/execvms.c,v
retrieving revision 1.2.36.1
retrieving revision 1.2.36.2
diff -u -d -r1.2.36.1 -r1.2.36.2
--- execvms.c   2 Jun 2007 00:45:48 -0000       1.2.36.1
+++ execvms.c   4 Jun 2007 23:38:42 -0000       1.2.36.2
@@ -49,7 +49,7 @@
 void
 execcmd( 
        char *string,
-       void (*func)( void *closure, int status ),
+        void (*func)( void *closure, int status, timing_info*, char *, char * 
),
        void *closure,
        LIST *shell,
     char *rule_name,

Index: make1.c
===================================================================
RCS file: /cvsroot/boost/boost/tools/jam/src/make1.c,v
retrieving revision 1.32.2.3
retrieving revision 1.32.2.4
diff -u -d -r1.32.2.3 -r1.32.2.4
--- make1.c     2 Jun 2007 01:39:29 -0000       1.32.2.3
+++ make1.c     4 Jun 2007 23:38:43 -0000       1.32.2.4
@@ -103,7 +103,7 @@
 static void make1b( state *pState );
 static void make1c( state *pState );
 static void make1d( state *pState );
-static void make_closure(void *closure, int status, timing_info*);
+static void make_closure(void *closure, int status, timing_info*, char *, char 
*);
 
 typedef struct _stack
 {
@@ -717,14 +717,60 @@
     }
 }
 
+static void append_int_string(LOL *l, int x)
+{
+    char buffer[50];
+    sprintf(buffer, "%i", x);
+    lol_add(l, list_new(L0, newstr(buffer)));
+}
+
+/* Look up the __DART_RULE__ variable on the given target, and if
+ * non-empty, invoke the rule it names, passing the given
+ * timing_info
+ */
+static void call_dart_rule(TARGET* target, int status, timing_info* time)
+{
+    LIST* dart_rule;
+    
+    pushsettings(target->settings);
+    dart_rule = var_get( "__DART_RULE__" );
+    popsettings(target->settings);
+
+    if (dart_rule)
+    {
+        /* We'll prepend $(__DART_RULE__[2-]) to the first argument */
+        LIST* initial_args = list_copy( L0, dart_rule->next );
+            
+        /* Prepare the argument list */
+        FRAME frame[1];
+        frame_init( frame );
+
+        /* First argument is the name of the target */
+        lol_add( frame->args, list_new( initial_args, target->name ) );
+        append_int_string(frame->args, status);
+        append_double_string(frame->args, time->user);
+        append_double_string(frame->args, time->system);
+
+        if( lol_get( frame->args, 2 ) )
+            evaluate_rule( dart_rule->string, frame );
+            
+        /* Clean up */
+        frame_free( frame );
+    }
+}
+
+
 static void make_closure(
-    void *closure, int status, timing_info* time)
+    void *closure, int status, timing_info* time, char *executed_command,
+    char *command_output)
 {
     TARGET* built = (TARGET*)closure;
 
     call_timing_rule(built, time);
     if (DEBUG_EXECCMD)
         printf("%f sec system; %f sec user\n", time->system, time->user);
+
+    call_dart_rule(built, status, time);
     
     push_state(&state_stack, built, NULL, T_STATE_MAKE1D)->status = status;
 }


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs

Reply via email to