Commits

Philip Jenvey committed d3a9a3b Merge

merge default

  • Participants
  • Parent commits 55f31f3, c7f8dea
  • Branches py3k

Comments (0)

Files changed (3)

pypy/module/sys/version.py

 
 if platform.name == 'msvc':
     COMPILER_INFO = 'MSC v.%d 32 bit' % (platform.version * 10 + 600)
-elif platform.cc is not None and platform.cc.startswith('gcc'):
-    out = platform.execute(platform.cc, '--version').out
-    match = re.search(' (\d+\.\d+(\.\d+)*)', out)
-    if match:
-        COMPILER_INFO = "GCC " + match.group(1)
-    else:
-        COMPILER_INFO = "GCC"
+elif platform.cc is not None and platform.cc.startswith(('gcc', 'clang')):
+    from rpython.rtyper.tool import rffi_platform
+    COMPILER_INFO = 'GCC ' + rffi_platform.getdefinedstring('__VERSION__', '')
 else:
     COMPILER_INFO = ""
 

rpython/rtyper/tool/rffi_platform.py

         DEFINED = DefinedConstantInteger(macro)
     return configure(CConfig)['DEFINED']
 
+def getdefinedstring(macro, c_header_source):
+    class CConfig:
+        _compilation_info_ = eci_from_header(c_header_source)
+        DEFINED = DefinedConstantString(macro)
+    return configure(CConfig)['DEFINED']
+
 def getintegerfunctionresult(function, args=None, c_header_source='', includes=[]):
     class CConfig:
         _compilation_info_ = eci_from_header(c_header_source)

rpython/rtyper/tool/test/test_rffi_platform.py

     value = rffi_platform.getdefineddouble('BLAH', '#define BLAH (double)0/0')
     assert isnan(value)
 
+def test_defined_constant_string():
+    value = rffi_platform.getdefinedstring('MCDONC', '')
+    assert value is None
+    value = rffi_platform.getdefinedstring('RAYDEO',
+                                           '#define RAYDEO "Michael Merickel"')
+    assert value == 'Michael Merickel'
+
 def test_getintegerfunctionresult():
     func = 'int sum(int a, int b) {return a + b;}'
     value = rffi_platform.getintegerfunctionresult('sum', [6, 7], func)