File tree Expand file tree Collapse file tree 2 files changed +29
-6
lines changed
Expand file tree Collapse file tree 2 files changed +29
-6
lines changed Original file line number Diff line number Diff line change 1616LINUX_KEY = "Linux"
1717
1818#TODO: add check for other compilers
19+ GCC_CLANG_VERSION = "4.2.1" # always returned by clang -dumpversion
1920MIN_GCC_VERSION = "4.7.0"
2021SUPPORTED_VERSIONS = {"gcc" : MIN_GCC_VERSION ,
2122 "gcc-linux" : MIN_GCC_VERSION
@@ -79,8 +80,10 @@ def _check_version(compiler_name, compiler_exec):
7980 if compiler_name in SUPPORTED_VERSIONS .keys ():
8081 import subprocess
8182 from distutils .version import StrictVersion
82- version = subprocess .check_output (compiler_exec + ' -dumpversion' , shell = True ).decode ().rstrip ()
83- if StrictVersion (version ) < StrictVersion (SUPPORTED_VERSIONS [compiler_name ]):
84- raise UnsupportedCompilerException ("Compiler '%s' with version '%s' is not supported. Minimum version is '%s'" % (compiler_name ,
85- version ,
86- SUPPORTED_VERSIONS [compiler_name ]))
83+ sversion = subprocess .check_output (compiler_exec + ' -dumpversion' , shell = True ).decode ().rstrip ()
84+ version = StrictVersion (sversion )
85+ if version < StrictVersion (SUPPORTED_VERSIONS [compiler_name ]):
86+ if version != StrictVersion (GCC_CLANG_VERSION ): # dont raise an exception if its gcc proxied clang
87+ raise UnsupportedCompilerException ("Compiler '%s' with version '%s' is not supported. Minimum version is '%s'" % (compiler_exec ,
88+ sversion ,
89+ SUPPORTED_VERSIONS [compiler_name ]))
Original file line number Diff line number Diff line change @@ -116,7 +116,27 @@ def test_get_cxxflags_invalid_compiler(self):
116116 pytest .fail ("Compiler is not supported" )
117117 except UnsupportedCompilerException :
118118 assert True
119-
119+
120+ def test_get_cxxflags_gcc_clang (self ):
121+ compiler_name = "gcc"
122+ with patch ("platform.system" ) as sys_mock :
123+ sys_mock .return_value = options .DARWIN_KEY
124+ with patch ("distutils.ccompiler.new_compiler" ) as new_cc_mock :
125+ with patch ("subprocess.check_output" ) as command_mock :
126+ command_mock .return_value = options .GCC_CLANG_VERSION .encode ('utf-8' )
127+ cc_mock = MagicMock ()
128+ cc_mock .compiler = [compiler_name ]
129+ new_cc_mock .return_value = cc_mock
130+ flags = get_cxxflags ()
131+ assert flags is not None
132+
133+ try :
134+ compiler = DARWIN_MAPPING [compiler_name ]
135+ except KeyError :
136+ compiler = compiler_name
137+
138+ assert map (eq , flags , options .CXX_FLAGS [compiler ])
139+
120140if __name__ == '__main__' :
121141 test = TestOptions ()
122142 test .test_get_cxxflags_Darwin ()
You can’t perform that action at this time.
0 commit comments