[pypy-svn] r66152 - in pypy/trunk/pypy/translator/platform: . test

fijal at codespeak.net fijal at codespeak.net
Wed Jul 8 18:55:46 CEST 2009


Author: fijal
Date: Wed Jul  8 18:55:44 2009
New Revision: 66152

Modified:
   pypy/trunk/pypy/translator/platform/__init__.py
   pypy/trunk/pypy/translator/platform/darwin.py
   pypy/trunk/pypy/translator/platform/test/test_distutils.py
   pypy/trunk/pypy/translator/platform/test/test_maemo.py
   pypy/trunk/pypy/translator/platform/test/test_platform.py
   pypy/trunk/pypy/translator/platform/windows.py
Log:
Don't use -l when creating a shared lib (since you don't need it and
messes up the build system sometimes)


Modified: pypy/trunk/pypy/translator/platform/__init__.py
==============================================================================
--- pypy/trunk/pypy/translator/platform/__init__.py	(original)
+++ pypy/trunk/pypy/translator/platform/__init__.py	Wed Jul  8 18:55:44 2009
@@ -70,7 +70,12 @@
             ofiles.append(self._compile_c_file(self.cc, cfile, compile_args))
         return ofiles
 
-    def execute(self, executable, args=None, env=None):
+    def execute(self, executable, args=None, env=None, compilation_info=None):
+        if env is None:
+            env = {}
+        if compilation_info is not None:
+            env['LD_LIBRARY_PATH'] = ':'.join(
+                [str(i) for i in compilation_info.library_dirs])
         returncode, stdout, stderr = _run_subprocess(str(executable), args,
                                                      env)
         return ExecutionResult(returncode, stdout, stderr)
@@ -120,9 +125,13 @@
         cflags = self.cflags + extra
         return (cflags + list(eci.compile_extra) + args)
 
-    def _link_args_from_eci(self, eci):
-        library_dirs = self._libdirs(eci.library_dirs)
-        libraries = self._libs(eci.libraries)
+    def _link_args_from_eci(self, eci, standalone):
+        if standalone:
+            library_dirs = self._libdirs(eci.library_dirs)
+            libraries = self._libs(eci.libraries)
+        else:
+            library_dirs = []
+            libraries = []
         link_files = self._linkfiles(eci.link_files)
         return (library_dirs + libraries + self.link_flags +
                 link_files + list(eci.link_extra))
@@ -137,8 +146,8 @@
                 exe_name += '.' + self.exe_ext
         else:
             exe_name += '.' + self.so_ext
-        return self._link(self.cc, ofiles, self._link_args_from_eci(eci),
-                          standalone, exe_name)
+        largs = self._link_args_from_eci(eci, standalone)
+        return self._link(self.cc, ofiles, largs, standalone, exe_name)
 
     # below are some detailed informations for platforms
 

Modified: pypy/trunk/pypy/translator/platform/darwin.py
==============================================================================
--- pypy/trunk/pypy/translator/platform/darwin.py	(original)
+++ pypy/trunk/pypy/translator/platform/darwin.py	Wed Jul  8 18:55:44 2009
@@ -38,8 +38,8 @@
             args.append(f)
         return args
 
-    def _link_args_from_eci(self, eci):
-        args = super(Darwin, self)._link_args_from_eci(eci)
+    def _link_args_from_eci(self, eci, standalone):
+        args = super(Darwin, self)._link_args_from_eci(eci, standalone)
         frameworks = self._frameworks(eci.frameworks)
         include_dirs = self._includedirs(eci.include_dirs)
         return (args + frameworks + include_dirs)

Modified: pypy/trunk/pypy/translator/platform/test/test_distutils.py
==============================================================================
--- pypy/trunk/pypy/translator/platform/test/test_distutils.py	(original)
+++ pypy/trunk/pypy/translator/platform/test/test_distutils.py	Wed Jul  8 18:55:44 2009
@@ -8,3 +8,6 @@
 
     def test_nice_errors(self):
         py.test.skip("Unsupported")
+
+    def test_shared_no_links(self):
+        py.test.skip("Unsupported")

Modified: pypy/trunk/pypy/translator/platform/test/test_maemo.py
==============================================================================
--- pypy/trunk/pypy/translator/platform/test/test_maemo.py	(original)
+++ pypy/trunk/pypy/translator/platform/test/test_maemo.py	Wed Jul  8 18:55:44 2009
@@ -31,3 +31,6 @@
         executable = self.platform.compile([cfile], eci)
         res = self.platform.execute(executable)
         self.check_res(res)
+
+    def test_shared_no_links(self):
+        py.test.skip("Unsupported")

Modified: pypy/trunk/pypy/translator/platform/test/test_platform.py
==============================================================================
--- pypy/trunk/pypy/translator/platform/test/test_platform.py	(original)
+++ pypy/trunk/pypy/translator/platform/test/test_platform.py	Wed Jul  8 18:55:44 2009
@@ -1,5 +1,5 @@
 
-import py, sys
+import py, sys, ctypes
 from pypy.tool.udir import udir
 from pypy.translator.platform import CompilationError, Platform
 from pypy.translator.platform import host
@@ -102,6 +102,18 @@
         res = self.platform.execute(executable)
         assert res.out.startswith('4.0')
 
+    def test_shared_no_links(self):
+        eci = ExternalCompilationInfo(libraries = ['xxxxxxxxxxxxxxxxxxx'])
+        tmpdir = udir.join('shared_no_links').ensure(dir=1)
+        c_file = tmpdir.join('shared1.c')
+        c_file.write('''
+        int f(int a, int b)
+        {
+            return (a + b);
+        }
+        ''')
+        library = self.platform.compile([c_file], eci, standalone=False)
+        assert ctypes.CDLL(str(library)).f(3, 4) == 7
 
 def test_equality():
     class X(Platform):

Modified: pypy/trunk/pypy/translator/platform/windows.py
==============================================================================
--- pypy/trunk/pypy/translator/platform/windows.py	(original)
+++ pypy/trunk/pypy/translator/platform/windows.py	Wed Jul  8 18:55:44 2009
@@ -133,8 +133,8 @@
     def _args_for_shared(self, args):
         return ['/dll'] + args
 
-    def _link_args_from_eci(self, eci):
-        args = super(MsvcPlatform, self)._link_args_from_eci(eci)
+    def _link_args_from_eci(self, eci, standalone):
+        args = super(MsvcPlatform, self)._link_args_from_eci(eci, standalone)
         return args + ['/EXPORT:%s' % symbol for symbol in eci.export_symbols]
 
     def _compile_c_file(self, cc, cfile, compile_args):



More information about the Pypy-commit mailing list