import os.path
import re
+import subprocess
-import SCons.Defaults
import SCons.Tool
import SCons.Util
env['SHOBJSUFFIX'] = '.pic.o'
# determine compiler version
if env['CXX']:
- line = os.popen(env['CXX'] + ' --version').readline()
+ try:
+ pipe = subprocess.Popen([env['CXX'], '--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['CXXVERSION'] = line
+ line = pipe.stdout.readline()
match = re.search(r'[0-9]+(\.[0-9]+)+', line)
if match:
env['CXXVERSION'] = match.group(0)
-
def exists(env):
return env.Detect(compilers)
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-import SCons.Util
-
import cc
import os
import re
+import subprocess
+
+import SCons.Util
compilers = ['gcc', 'cc']
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)