diff options
author | Greg Noel <GregNoel@tigris.org> | 2008-09-10 06:33:28 (GMT) |
---|---|---|
committer | Greg Noel <GregNoel@tigris.org> | 2008-09-10 06:33:28 (GMT) |
commit | 311e482d13e4bfbcd643e0fb7cdc017ac55b6dc9 (patch) | |
tree | 3746e797b6da1964a13b594ec14730e23bc6f360 /src/engine/SCons/Tool/gcc.py | |
parent | fb90c8e0ede35a39d13dd21a3521e4a740d8e1f1 (diff) | |
download | SCons-311e482d13e4bfbcd643e0fb7cdc017ac55b6dc9.zip SCons-311e482d13e4bfbcd643e0fb7cdc017ac55b6dc9.tar.gz SCons-311e482d13e4bfbcd643e0fb7cdc017ac55b6dc9.tar.bz2 |
Issues 2076 and 2232, use ENV and suppress stderr when checking GCC version ID
Diffstat (limited to 'src/engine/SCons/Tool/gcc.py')
-rw-r--r-- | src/engine/SCons/Tool/gcc.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/engine/SCons/Tool/gcc.py b/src/engine/SCons/Tool/gcc.py index ad02e0d..4e81ba8 100644 --- a/src/engine/SCons/Tool/gcc.py +++ b/src/engine/SCons/Tool/gcc.py @@ -33,11 +33,12 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import SCons.Util - import cc import os import re +import subprocess + +import SCons.Util compilers = ['gcc', 'cc'] @@ -52,7 +53,20 @@ def generate(env): env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS -fPIC') # determine compiler version if env['CC']: - line = os.popen(env['CC'] + ' --version').readline() + try: + pipe = subprocess.Popen([env['CC'], '--version'], + env=env['ENV'], + stderr = subprocess.PIPE, + stdout = subprocess.PIPE) + except OSError: + 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. + #line = pipe.stdout.read().strip() + #if line: + # env['CCVERSION'] = line + line = pipe.stdout.readline() match = re.search(r'[0-9]+(\.[0-9]+)+', line) if match: env['CCVERSION'] = match.group(0) |