summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Tool/g++.py
diff options
context:
space:
mode:
authorMichael Haubenwallner <haubi@gentoo.org>2014-05-15 08:17:03 (GMT)
committerMichael Haubenwallner <haubi@gentoo.org>2014-05-15 08:17:03 (GMT)
commitc82684ba964183647a1965589ef852eacd9e5447 (patch)
treeeeac860a5e8bba755f8f5dc091702bc78989d8a0 /src/engine/SCons/Tool/g++.py
parent80cdee0bb0319a9c14abd9c60b4123aee07f0274 (diff)
downloadSCons-c82684ba964183647a1965589ef852eacd9e5447.zip
SCons-c82684ba964183647a1965589ef852eacd9e5447.tar.gz
SCons-c82684ba964183647a1965589ef852eacd9e5447.tar.bz2
Respect preset CC/CXX values detecting cc/c++/gcc/g++ Tools.
As the user-preset values for CC/CXX should rule always, also respect them in exists() and generate() methods of these Tools. As a result, the value for CCVERSION/CXXVERSION does match the CC/CXX compiler used (issue#1723).
Diffstat (limited to 'src/engine/SCons/Tool/g++.py')
-rw-r--r--src/engine/SCons/Tool/g++.py30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/engine/SCons/Tool/g++.py b/src/engine/SCons/Tool/g++.py
index e4da5fe..5cf3827 100644
--- a/src/engine/SCons/Tool/g++.py
+++ b/src/engine/SCons/Tool/g++.py
@@ -40,6 +40,8 @@ import subprocess
import SCons.Tool
import SCons.Util
+import gcc
+
cplusplus = __import__('c++', globals(), locals(), [])
compilers = ['g++']
@@ -48,9 +50,10 @@ def generate(env):
"""Add Builders and construction variables for g++ to an Environment."""
static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
- cplusplus.generate(env)
+ if 'CXX' not in env:
+ env['CXX'] = env.Detect(compilers) or compilers[0]
- env['CXX'] = env.Detect(compilers)
+ cplusplus.generate(env)
# platform specific settings
if env['PLATFORM'] == 'aix':
@@ -62,26 +65,13 @@ def generate(env):
elif env['PLATFORM'] == 'sunos':
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'],
- stdin = 'devnull',
- stderr = 'devnull',
- 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.
- #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)
+ version = gcc.detect_version(env, env['CXX'])
+ if version:
+ env['CXXVERSION'] = version
def exists(env):
- return env.Detect(compilers)
+ # is executable, and is a GNU compiler (or accepts '--version' at least)
+ return gcc.detect_version(env, env.Detect(env.get('CXX', compilers)))
# Local Variables:
# tab-width:4