Fix waf problem running programs with arguments.
authorGustavo J. A. M. Carneiro <gjc@inescporto.pt>
Wed, 26 Nov 2008 14:55:35 +0000
changeset 3933 3c149230e98a
parent 3929 909b0a724ed3
child 3934 745312072e11
Fix waf problem running programs with arguments.
wscript
wutils.py
--- a/wscript	Wed Nov 26 12:11:11 2008 +0000
+++ b/wscript	Wed Nov 26 14:55:35 2008 +0000
@@ -447,16 +447,13 @@
 
     if Params.g_options.run:
         # Check that the requested program name is valid
-        try:
-            wutils.find_program(Params.g_options.run, env)
-        except ValueError, ex:
-            Params.fatal(str(ex))
-        
+        program_name, dummy_program_argv = wutils.get_run_program(Params.g_options.run, get_command_template())
+
         # When --run'ing a program, tell WAF to only build that program,
         # nothing more; this greatly speeds up compilation when all you
         # want to do is run a test program.
         if not Params.g_options.compile_targets:
-            Params.g_options.compile_targets = Params.g_options.run
+            Params.g_options.compile_targets = program_name
 
 
 
--- a/wutils.py	Wed Nov 26 12:11:11 2008 +0000
+++ b/wutils.py	Wed Nov 26 14:55:35 2008 +0000
@@ -94,13 +94,12 @@
         Params.fatal("Command %s exited with code %i" % (argv, retval))
     return retval
 
-def run_program(program_string, command_template=None):
+def get_run_program(program_string, command_template=None):
     """
-    if command_template is not None, then program_string == program
-    name and argv is given by command_template with %s replaced by the
-    full path to the program.  Else, program_string is interpreted as
-    a shell command with first name being the program name.
+    Return the program name and argv of the process that would be executed by
+    run_program(program_string, command_template).
     """
+    #print "get_run_program_argv(program_string=%r, command_template=%r)" % (program_string, command_template)
     env = Params.g_build.env_of_name('default')
 
     if command_template in (None, '%s'):
@@ -132,7 +131,16 @@
             Params.fatal("%s does not appear to be a program" % (program_name,))
 
         execvec = shlex.split(command_template % (program_node.abspath(env),))
+    return program_name, execvec
 
+def run_program(program_string, command_template=None):
+    """
+    if command_template is not None, then program_string == program
+    name and argv is given by command_template with %s replaced by the
+    full path to the program.  Else, program_string is interpreted as
+    a shell command with first name being the program name.
+    """
+    dummy_program_name, execvec = get_run_program(program_string, command_template)
     former_cwd = os.getcwd()
     if (Params.g_options.cwd_launch):
         os.chdir(Params.g_options.cwd_launch)