From: GregNoel Date: Mon, 22 Sep 2008 08:11:34 +0000 (+0000) Subject: make references to subprocess.Popen synchronous X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2614345772378686e4efcf656aa056badab59d53;p=scons.git make references to subprocess.Popen synchronous git-svn-id: http://scons.tigris.org/svn/scons/trunk@3449 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index da02f120..069400c8 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -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 '' diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index b16a1efe..cbf0d17b 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -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: diff --git a/src/engine/SCons/Tool/g++.py b/src/engine/SCons/Tool/g++.py index f8f5b34e..61d095e5 100644 --- a/src/engine/SCons/Tool/g++.py +++ b/src/engine/SCons/Tool/g++.py @@ -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. diff --git a/src/engine/SCons/Tool/gcc.py b/src/engine/SCons/Tool/gcc.py index 232d64aa..7d2b1b87 100644 --- a/src/engine/SCons/Tool/gcc.py +++ b/src/engine/SCons/Tool/gcc.py @@ -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.