aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xconfigure.py16
-rwxr-xr-xsrc/scripts/python_uniitests.py8
2 files changed, 15 insertions, 9 deletions
diff --git a/configure.py b/configure.py
index 311c04e5b..fe65edcc6 100755
--- a/configure.py
+++ b/configure.py
@@ -2578,9 +2578,9 @@ class CompilerDetector(object):
'clang': ['-v'],
}
_version_patterns = {
- 'msvc': r'Compiler Version ([0-9]+).([0-9]+).[0-9\.]+ for',
- 'gcc': r'gcc version ([0-9]+.[0-9])+.[0-9]+',
- 'clang': r'clang version ([0-9]+.[0-9])[ \.]',
+ 'msvc': r'Compiler Version ([0-9]+\.[0-9]+)\.[0-9\.]+ for',
+ 'gcc': r'gcc version ([0-9]+\.[0-9]+)\.[0-9]+',
+ 'clang': r'clang version ([0-9]+\.[0-9])[ \.]',
}
def __init__(self, cc_name, cc_bin, os_name):
@@ -2619,12 +2619,10 @@ class CompilerDetector(object):
'19.00': '2015',
'19.10': '2017'
}
- cl_version = match.group(1) + '.' + match.group(2)
- if cl_version in cl_version_to_msvc_version:
- cc_version = cl_version_to_msvc_version[cl_version]
- else:
- logging.warning('Unable to determine MSVC version from output "%s"' % (cc_output))
- return None
+ try:
+ cc_version = cl_version_to_msvc_version[match.group(1)]
+ except KeyError:
+ raise InternalError('Unknown MSVC version in output "%s"' % (cc_output))
else:
cc_version = match.group(1)
elif match is None and self._cc_name == 'clang' and self._os_name in ['darwin', 'ios']:
diff --git a/src/scripts/python_uniitests.py b/src/scripts/python_uniitests.py
index 63f8bfc93..d116d13b8 100755
--- a/src/scripts/python_uniitests.py
+++ b/src/scripts/python_uniitests.py
@@ -36,6 +36,14 @@ class CompilerDetection(unittest.TestCase):
compiler_out = "clang version 20170406."
self.assertEqual(detector.version_from_compiler_output(compiler_out), None)
+ def test_msvc_invalid(self):
+ detector = CompilerDetector("msvc", "cl.exe", "windows")
+
+ compiler_out = ""
+ self.assertEqual(detector.version_from_compiler_output(compiler_out), None)
+ compiler_out = "Compiler Version 1900242131. for x86"
+ self.assertEqual(detector.version_from_compiler_output(compiler_out), None)
+
def test_gcc_version(self):
detector = CompilerDetector("gcc", "g++", "linux")
compiler_out = """Using built-in specs.