Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make sure the process get the --gras-log argument in SG mode (where the arguments...
[simgrid.git] / examples / gras_stub_generator
index 63828eb..9830a96 100755 (executable)
@@ -48,6 +48,8 @@ $warn
 #include <msg.h>
 #include <gras.h>
 
+char *gras_log=NULL;
+    
 EOF
  ;
 foreach (keys %process) { print OUT "int $_(int argc,char *argv[]);\n";        }
@@ -57,11 +59,13 @@ print OUT "\n$warn\n";
 
 foreach (keys %process) {
     print OUT<<EOF
-int launch_$_(int argc, char *argv[]) {
-  if (gras_process_init()) exit(1);
-  $_(argc,argv);
-  if (gras_process_finalize()) exit(1);
+int launch_$_(int argc, char **argv) {
 
+  if (gras_log) {
+      argv=realloc(argv,++argc * sizeof(char**));
+      argv[argc-1] = gras_log;
+  }
+  $_(argc,argv);
   return 0;
 }
 
@@ -72,16 +76,30 @@ print OUT "\n$warn\n";
 
 print OUT <<EOF
 int main (int argc,char *argv[]) {
+  int i,j;
+
+  /** Save the gras-log argument */
+  for (i=1; i<argc; i++) {
+    if (!strncmp(argv[i],"--gras-log=",strlen("--gras-log="))) {
+      gras_log = argv[i];
+      for (j=i+1; j<argc; j++) {
+       argv[j-1] = argv[j];
+      } 
+      argv[j-1] = NULL;
+      argc--;
+      i--; /* compensate effect of next loop incrementation */
+    }
+  }
 
   if (argc != 3) {
-    fprintf(stderr, "Usage: %s platform_file application_description.txt\\n",argv[0]);
+    fprintf(stderr, "Usage: %s platform_file application_description.txt [--gras-log=...]\\n",argv[0]);
     exit(1);
   }
 
-  /*  Simulation setting */
+  /*  Simulation setup */
   MSG_global_init();
   MSG_set_verbosity(MSG_SILENT);
-  MSG_set_channel_number(MAX_CHANNEL);
+  MSG_set_channel_number(GRAS_MAX_CHANNEL);
   MSG_create_environment(argv[1]);
 
   /*  Application deployment */
@@ -115,11 +133,6 @@ $warn
 #include <signal.h>
 #include <gras.h>
 
-/* signal handler for SIGPIPE from NWS */
-void SocketFailure(int sig);
-/* minimum needed from diagnostic.h for initialization, so that we don''t have to ship this file */
-typedef enum {DIAGLOG, DIAGINFO, DIAGWARN, DIAGERROR, DIAGFATAL, DIAGDEBUG} DiagLevels;
-void DirectDiagnostics(DiagLevels level, FILE *whereTo);
 /* user code */
 int $pname(int argc, char *argv[]);
 
@@ -128,19 +141,8 @@ $warn
 int main(int argc, char *argv[]){
   int errcode;
 
-  DirectDiagnostics(DIAGDEBUG, stdout);
-  DirectDiagnostics(DIAGINFO, stdout);
-  DirectDiagnostics(DIAGLOG, stdout);
-  DirectDiagnostics(DIAGWARN, stderr);
-  DirectDiagnostics(DIAGERROR, stderr);
-  DirectDiagnostics(DIAGFATAL, stderr);
-
-  signal(SIGPIPE, SocketFailure);
-
-  gras_process_init();
   errcode=$pname(argc,argv);
-  gras_process_finalize();
-
   return errcode;
 }