[pypy-svn] r64016 - in pypy/branch/cbuild-llvm/pypy/translator/tool: . test

getxsick at codespeak.net getxsick at codespeak.net
Mon Apr 13 05:24:26 CEST 2009


Author: getxsick
Date: Mon Apr 13 05:24:23 2009
New Revision: 64016

Modified:
   pypy/branch/cbuild-llvm/pypy/translator/tool/cbuild.py
   pypy/branch/cbuild-llvm/pypy/translator/tool/test/test_cbuild.py
Log:
added a new function ExternalCompilationInfo.from_llvm_config() and related tests


Modified: pypy/branch/cbuild-llvm/pypy/translator/tool/cbuild.py
==============================================================================
--- pypy/branch/cbuild-llvm/pypy/translator/tool/cbuild.py	(original)
+++ pypy/branch/cbuild-llvm/pypy/translator/tool/cbuild.py	Mon Apr 13 05:24:23 2009
@@ -154,6 +154,25 @@
         return eci1.merge(eci2)
     from_config_tool = classmethod(from_config_tool)
 
+    def from_llvm_config(cls, llvmconfig='llvm-config'):
+        """
+        Return a new ExternalCompilationInfo instance by executing
+        the 'llvmconfig' with --cflags, --ldflags and '--libs all' arguments.
+        """
+        path = py.path.local.sysfind(execonfigtool)
+        if not path:
+            raise ImportError("cannot find %r" % (execonfigtool,))
+            # we raise ImportError to be nice to the pypy.config.pypyoption
+            # logic of skipping modules depending on non-installed libs
+        cflags = py.process.cmdexec('"%s" --cflags' % (str(path),))
+        eci1 = cls.from_compiler_flags(cflags)
+        libs = py.process.cmdexec('"%s" --ldflags' % (str(path),))
+        eci2 = cls.from_linker_flags(libs)
+        libs = py.process.cmdexec('"%s" --libs all' % (str(path),))
+        eci3 = cls.from_linker_flags(libs)
+        return eci1.merge(eci2.merge(eci3))
+    from_llvm_config = classmethod(from_llvm_config)
+
     def _value(self):
         return tuple([getattr(self, x) for x in self._ATTRIBUTES]
                      + [self.platform])

Modified: pypy/branch/cbuild-llvm/pypy/translator/tool/test/test_cbuild.py
==============================================================================
--- pypy/branch/cbuild-llvm/pypy/translator/tool/test/test_cbuild.py	(original)
+++ pypy/branch/cbuild-llvm/pypy/translator/tool/test/test_cbuild.py	Mon Apr 13 05:24:23 2009
@@ -117,6 +117,15 @@
         eci = ExternalCompilationInfo.from_config_tool('sdl-config')
         assert 'SDL' in eci.libraries
 
+    def test_from_config_tool_llvm(self):
+        llvmconfig = py.path.local.sysfind('llvm-config')
+        if not llvmconfig:
+            py.test.skip("llvm-config not installed")
+        eci = ExternalCompilationInfo.from_config_tool(
+                '/home/xsx/_usr/llvm/bin/llvm-config',
+                )
+        assert 'LLVMCore' in eci.libraries
+
     def test_from_missing_config_tool(self):
         py.test.raises(ImportError,
                        ExternalCompilationInfo.from_config_tool,



More information about the Pypy-commit mailing list