make references to subprocess.Popen synchronous
authorGregNoel <GregNoel@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Mon, 22 Sep 2008 08:11:34 +0000 (08:11 +0000)
committerGregNoel <GregNoel@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Mon, 22 Sep 2008 08:11:34 +0000 (08:11 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@3449 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Action.py
src/engine/SCons/Environment.py
src/engine/SCons/Tool/g++.py
src/engine/SCons/Tool/gcc.py

index da02f120b4a8114f9e7f17a314eb888a67429914..069400c8c36247c5ebe1fdd7e33bf7b532b9fd25 100644 (file)
@@ -543,8 +543,8 @@ def _subproc(env, cmd, error = 'ignore', **kw):
         # return a dummy Popen instance that only returns error
         class popen:
             def __init__(self, e): self.exception = e
-            def communicate(): return ('','')
-            def wait(): return -self.exception.errno
+            def communicate(self): return ('','')
+            def wait(self): return -self.exception.errno
             stdin = None
             class f:
                 def read(self): return ''
index b16a1efeb87ff84fcc1e66b460156d72e1fc29b7..cbf0d17b91f93d1dd65e11a78f8959b1120f93c8 100644 (file)
@@ -37,7 +37,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
 import copy
 import os
-import os.path
+import sys
 import re
 import shlex
 import string
@@ -537,13 +537,9 @@ class SubstitutionEnvironment:
         # run constructed command
         #FUTURE p = SCons.Action._subproc(self, command, **kw)
         p = apply(SCons.Action._subproc, (self, command), kw)
-        out = p.stdout.read()
-        p.stdout.close()
-        err = p.stderr.read()
-        p.stderr.close()
+        out,err = p.communicate()
         status = p.wait()
         if err:
-            import sys
             sys.stderr.write(err)
         if status:
             raise OSError("'%s' exited %d" % (command, status))
@@ -1847,7 +1843,6 @@ class Base(SubstitutionEnvironment):
             errstr = result.errstr
             if result.filename:
                 errstr = result.filename + ': ' + errstr
-            import sys
             sys.stderr.write("scons: *** %s\n" % errstr)
             return result.status
         else:
index f8f5b34e521e90fd9abad36f38dcd83bd68446c1..61d095e575da086a4405a76e89d812347a0d3da9 100644 (file)
@@ -63,9 +63,11 @@ def generate(env):
         env['SHOBJSUFFIX'] = '.pic.o'
     # determine compiler version
     if env['CXX']:
+        #pipe = SCons.Action._subproc(env, [env['CXX'], '-dumpversion'],
         pipe = SCons.Action._subproc(env, [env['CXX'], '--version'],
                                      stderr = subprocess.PIPE,
                                      stdout = subprocess.PIPE)
+        if pipe.wait() != 0: return
         # -dumpversion was added in GCC 3.0.  As long as we're supporting
         # GCC versions older than that, we should use --version and a
         # regular expression.
index 232d64aa8d72976f53b746c5bba09a804a435db3..7d2b1b87b3511d21ca364e0d1d9bad4d1326ae45 100644 (file)
@@ -53,9 +53,11 @@ def generate(env):
         env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS -fPIC')
     # determine compiler version
     if env['CC']:
+        #pipe = SCons.Action._subproc(env, [env['CC'], '-dumpversion'],
         pipe = SCons.Action._subproc(env, [env['CC'], '--version'],
                                      stderr = subprocess.PIPE,
                                      stdout = subprocess.PIPE)
+        if pipe.wait() != 0: return
         # -dumpversion was added in GCC 3.0.  As long as we're supporting
         # GCC versions older than that, we should use --version and a
         # regular expression.