wscript
changeset 2207 d841cca00990
parent 2178 763aa96fffd4
child 2212 4ba90810ae30
--- a/wscript	Wed Jan 02 13:39:56 2008 +0100
+++ b/wscript	Thu Jan 03 14:14:17 2008 +0000
@@ -74,7 +74,10 @@
                          ' It should be a shell command string containing %s inside,'
                          ' which will be replaced by the actual program.'),
                    type="string", default=None, dest='command_template')
-
+    opt.add_option('--valgrind',
+                   help=('Change the default command template to run programs and unit tests with valgrind'),
+                   action="store_true", default=False,
+                   dest='valgrind')
     opt.add_option('--shell',
                    help=('Run a shell with an environment suitably modified to run locally built programs'),
                    action="store_true", default=False,
@@ -233,6 +236,13 @@
         lib.add_objects = list(env['NS3_MODULES'])
 
 
+def get_command_template():
+    if Params.g_options.valgrind:
+        if Params.g_options.command_template:
+            Params.fatal("Options --command-template and --valgrind are conflicting")
+        return "valgrind %s"
+    else:
+        return (Params.g_options.command_template or '%s')
 
 
 def shutdown():
@@ -251,7 +261,7 @@
         lcov_report()
 
     if Params.g_options.run:
-        run_program(Params.g_options.run, Params.g_options.command_template)
+        run_program(Params.g_options.run, get_command_template())
         raise SystemExit(0)
 
     if Params.g_options.command_template:
@@ -273,7 +283,7 @@
             raise SystemExit(1)
         out.close()
 
-    run_program('run-tests')
+    run_program('run-tests', get_command_template())
 
 
 def _find_program(program_name, env):