From f588f95a2791856f17744116a2d9b677e6cc67bb Mon Sep 17 00:00:00 2001 From: Thomas Nagy Date: Sat, 13 Jul 2013 19:06:08 +0200 Subject: [PATCH] Issue 1339 detect the sun compiler version number --- waflib/Tools/c_config.py | 21 +++++++++++++++++++++ waflib/Tools/suncc.py | 2 ++ waflib/Tools/suncxx.py | 2 ++ 3 files changed, 25 insertions(+) diff --git a/waflib/Tools/c_config.py b/waflib/Tools/c_config.py index 25289541..6dce68b8 100755 --- a/waflib/Tools/c_config.py +++ b/waflib/Tools/c_config.py @@ -1136,6 +1136,27 @@ def get_xlc_version(conf, cc): else: conf.fatal('Could not determine the XLC version.') +@conf +def get_suncc_version(conf, cc): + """Get the compiler version""" + + cmd = cc + ['-V'] + try: + out, err = conf.cmd_and_log(cmd, output=0) + except Errors.WafError: + conf.fatal('Could not find suncc %r' % cmd) + + version = (out or err) + version = version.split('\n')[0] + + version_re = re.compile(r'cc:\s+sun\s+(c\+\+|c)\s+(?P\d*)\.(?P\d*)', re.I).search + match = version_re(version) + if match: + k = match.groupdict() + conf.env['CC_VERSION'] = (k['major'], k['minor']) + else: + conf.fatal('Could not determine the suncc version.') + # ============ the --as-needed flag should added during the configuration, not at runtime ========= @conf diff --git a/waflib/Tools/suncc.py b/waflib/Tools/suncc.py index efe790ef..9ea51b29 100644 --- a/waflib/Tools/suncc.py +++ b/waflib/Tools/suncc.py @@ -28,6 +28,8 @@ def find_scc(conf): v['CC'] = cc v['CC_NAME'] = 'sun' + conf.get_suncc_version(cc) + @conf def scc_common_flags(conf): diff --git a/waflib/Tools/suncxx.py b/waflib/Tools/suncxx.py index 704829a8..600b7b9b 100644 --- a/waflib/Tools/suncxx.py +++ b/waflib/Tools/suncxx.py @@ -29,6 +29,8 @@ def find_sxx(conf): v['CXX'] = cc v['CXX_NAME'] = 'sun' + conf.get_suncc_version(cc) + @conf def sxx_common_flags(conf):