Browse Source

tools/starpu_fxt_tool.c: add a usage internal function

Nathalie Furmento 12 years ago
parent
commit
61f0670df5
1 changed files with 37 additions and 8 deletions
  1. 37 8
      tools/starpu_fxt_tool.c

+ 37 - 8
tools/starpu_fxt_tool.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2011-2012  Université de Bordeaux 1
- * Copyright (C) 2012  Centre National de la Recherche Scientifique
+ * Copyright (C) 2011-2013  Universite de Bordeaux 1
+ * Copyright (C) 2012-2013  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -19,8 +19,28 @@
  * This program should be used to parse the log generated by FxT 
  */
 
+#include <config.h>
 #include <starpu.h>
 
+#define PROGNAME "starpu_fxt_tool"
+
+static void usage(char **argv)
+{
+	fprintf(stderr, "Generate a trace in the Paje format\n\n");
+	fprintf(stderr, "Usage: %s [ options ]\n", PROGNAME);
+        fprintf(stderr, "\n");
+        fprintf(stderr, "Options:\n");
+        fprintf(stderr, "   -i <input file>     specify the input file\n");
+        fprintf(stderr, "   -o <output file>    specify the output file\n");
+        fprintf(stderr, "   -c                  use a different colour for every type of task\n");
+        fprintf(stderr, "   -no-counter         set the FxT no counter option\n");
+        fprintf(stderr, "   -no-bus             set the FxT no bus option\n");
+	fprintf(stderr, "   -h, --help          display this help and exit\n");
+	fprintf(stderr, "   -v, --version       output version information and exit\n\n");
+        fprintf(stderr, "Reports bugs to <"PACKAGE_BUGREPORT">.");
+        fprintf(stderr, "\n");
+}
+
 static struct starpu_fxt_options options;
 
 static void parse_args(int argc, char **argv)
@@ -65,9 +85,14 @@ static void parse_args(int argc, char **argv)
 
 		if (strcmp(argv[i], "-h") == 0
 		 || strcmp(argv[i], "--help") == 0) {
-		        fprintf(stderr, "Usage : %s [-c] [-no-counter] [-no-bus] [-i input_filename] [-o output_filename]\n", argv[0]);
-			fprintf(stderr, "\t-c: use a different colour for every type of task.\n");
-		        exit(-1);
+			usage(argv);
+			exit(EXIT_SUCCESS);
+		}
+
+		if (strcmp(argv[i], "-v") == 0
+		 || strcmp(argv[i], "--version") == 0) {
+		        fputs(PROGNAME " (" PACKAGE_NAME ") " PACKAGE_VERSION "\n", stderr);
+			exit(EXIT_SUCCESS);
 		}
 
 		/* That's pretty dirty: if the reading_input_filenames flag is
@@ -79,15 +104,19 @@ static void parse_args(int argc, char **argv)
 			continue;
 		}
 	}
+
+	if (!options.ninputfiles)
+	{
+		fprintf(stderr, "Incorrect usage, aborting\n");
+                usage(argv);
+		exit(-1);
+	}
 }
 
 int main(int argc, char **argv)
 {
 	parse_args(argc, argv);
 
-	if (options.ninputfiles == 0)
-	     return 77;
-
 	starpu_fxt_generate_trace(&options);
 
 	return 0;