[pypy-svn] r62707 - in pypy/trunk/pypy/translator: platform tool tool/test

santagada at codespeak.net santagada at codespeak.net
Sat Mar 7 15:27:11 CET 2009


Author: santagada
Date: Sat Mar  7 15:27:11 2009
New Revision: 62707

Modified:
   pypy/trunk/pypy/translator/platform/__init__.py
   pypy/trunk/pypy/translator/platform/posix.py
   pypy/trunk/pypy/translator/platform/windows.py
   pypy/trunk/pypy/translator/tool/cbuild.py
   pypy/trunk/pypy/translator/tool/test/test_cbuild.py
Log:
Added a new link_files parameter that is passed directly to the linker. Updated a test for it, but would really like to have advice on how to test it better.

Modified: pypy/trunk/pypy/translator/platform/__init__.py
==============================================================================
--- pypy/trunk/pypy/translator/platform/__init__.py	(original)
+++ pypy/trunk/pypy/translator/platform/__init__.py	Sat Mar  7 15:27:11 2009
@@ -120,8 +120,9 @@
     def _link_args_from_eci(self, eci):
         library_dirs = self._libdirs(eci.library_dirs)
         libraries = self._libs(eci.libraries)
+        link_files = self._linkfiles(eci.link_files)
         return (library_dirs + libraries + self.link_flags +
-                list(eci.link_extra))
+                link_files + list(eci.link_extra))
 
     def _finish_linking(self, ofiles, eci, outputfilename, standalone):
         if outputfilename is None:

Modified: pypy/trunk/pypy/translator/platform/posix.py
==============================================================================
--- pypy/trunk/pypy/translator/platform/posix.py	(original)
+++ pypy/trunk/pypy/translator/platform/posix.py	Sat Mar  7 15:27:11 2009
@@ -23,6 +23,9 @@
     def _includedirs(self, include_dirs):
         return ['-I%s' % (idir,) for idir in include_dirs]
 
+    def _linkfiles(self, link_files):
+        return list(link_files)
+
     def _compile_c_file(self, cc, cfile, compile_args):
         oname = cfile.new(ext='o')
         args = ['-c'] + compile_args + [str(cfile), '-o', str(oname)]

Modified: pypy/trunk/pypy/translator/platform/windows.py
==============================================================================
--- pypy/trunk/pypy/translator/platform/windows.py	(original)
+++ pypy/trunk/pypy/translator/platform/windows.py	Sat Mar  7 15:27:11 2009
@@ -126,6 +126,9 @@
                 )
         return ['/LIBPATH:%s' % (ldir,) for ldir in library_dirs]
 
+    def _linkfiles(self, link_files):
+        return list(link_files)
+
     def _args_for_shared(self, args):
         return ['/dll'] + args
 

Modified: pypy/trunk/pypy/translator/tool/cbuild.py
==============================================================================
--- pypy/trunk/pypy/translator/tool/cbuild.py	(original)
+++ pypy/trunk/pypy/translator/tool/cbuild.py	Sat Mar  7 15:27:11 2009
@@ -18,7 +18,7 @@
                    'post_include_bits', 'libraries', 'library_dirs',
                    'separate_module_sources', 'separate_module_files',
                    'export_symbols', 'compile_extra', 'link_extra',
-                   'frameworks']
+                   'frameworks', 'link_files']
     _DUPLICATES_OK = ['compile_extra', 'link_extra']
 
     def __init__(self,
@@ -34,6 +34,7 @@
                  compile_extra           = [],
                  link_extra              = [],
                  frameworks              = [],
+                 link_files              = [],
                  platform                = None):
         """
         pre_include_bits: list of pieces of text that should be put at the top
@@ -76,6 +77,9 @@
         link to a framework bundle. Not suitable for unix-like .dylib
         installations.
 
+        link_files: list of file names which will be directly passed to the
+        linker
+
         platform: an object that can identify the platform
         """
         for name in self._ATTRIBUTES:

Modified: pypy/trunk/pypy/translator/tool/test/test_cbuild.py
==============================================================================
--- pypy/trunk/pypy/translator/tool/test/test_cbuild.py	(original)
+++ pypy/trunk/pypy/translator/tool/test/test_cbuild.py	Sat Mar  7 15:27:11 2009
@@ -41,16 +41,20 @@
     def test_merge2(self):
         e1 = ExternalCompilationInfo(
             pre_include_bits  = ['1'],
+            link_files = ['1.c']
         )
         e2 = ExternalCompilationInfo(
             pre_include_bits  = ['2'],
+            link_files = ['1.c', '2.c']
         )
         e3 = ExternalCompilationInfo(
             pre_include_bits  = ['3'],
+            link_files = ['1.c', '2.c', '3.c']
         )
         e = e1.merge(e2)
         e = e.merge(e3, e3)
         assert e.pre_include_bits == ('1', '2', '3')
+        assert e.link_files == ('1.c', '2.c', '3.c')
 
     def test_convert_sources_to_c_files(self):
         eci = ExternalCompilationInfo(



More information about the Pypy-commit mailing list