[pypy-svn] r66156 - in pypy/trunk/pypy/rpython/lltypesystem: . test

fijal at codespeak.net fijal at codespeak.net
Fri Jul 10 09:11:42 CEST 2009


Author: fijal
Date: Fri Jul 10 09:11:41 2009
New Revision: 66156

Modified:
   pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py
   pypy/trunk/pypy/rpython/lltypesystem/test/test_ll2ctypes.py
Log:
a test and a fix for prefixes


Modified: pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py
==============================================================================
--- pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py	(original)
+++ pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py	Fri Jul 10 09:11:41 2009
@@ -820,11 +820,13 @@
             ext = platform.so_ext
             prefixes = platform.so_prefixes
             for dir in eci.library_dirs:
+                if libpath:
+                    break
                 for prefix in prefixes:
                     tryfile = os.path.join(dir, prefix + libname + '.' + ext)
-                if os.path.isfile(tryfile):
-                    libpath = tryfile
-                    break
+                    if os.path.isfile(tryfile):
+                        libpath = tryfile
+                        break
             if not libpath:
                 libpath = ctypes.util.find_library(libname)
                 if not libpath and os.path.isabs(libname):

Modified: pypy/trunk/pypy/rpython/lltypesystem/test/test_ll2ctypes.py
==============================================================================
--- pypy/trunk/pypy/rpython/lltypesystem/test/test_ll2ctypes.py	(original)
+++ pypy/trunk/pypy/rpython/lltypesystem/test/test_ll2ctypes.py	Fri Jul 10 09:11:41 2009
@@ -1013,3 +1013,28 @@
         f = rffi.llexternal('f', [rffi.INT, rffi.INT], rffi.INT,
                             compilation_info=eci)
         assert f(3, 4) == 7
+
+    def test_prefix(self):
+
+        if sys.platform != 'linux2':
+            py.test.skip("Not supported")
+
+        from pypy.translator.platform import platform
+        from pypy.translator.tool.cbuild import ExternalCompilationInfo
+
+        tmpdir = udir.join('lib_on_libppaths_prefix')
+        tmpdir.ensure(dir=1)
+        c_file = tmpdir.join('c_file.c')
+        c_file.write('int f(int a, int b) { return (a + b); }')
+        eci = ExternalCompilationInfo()
+        so = platform.compile([c_file], eci, standalone=False)
+        sopath = py.path.local(so)
+        sopath.move(sopath.dirpath().join('libc_file.so'))
+        eci = ExternalCompilationInfo(
+            libraries = ['c_file'],
+            library_dirs = [str(so.dirpath())]
+        )
+        f = rffi.llexternal('f', [rffi.INT, rffi.INT], rffi.INT,
+                            compilation_info=eci)
+        assert f(3, 4) == 7
+        



More information about the Pypy-commit mailing list