Commits

Armin Rigo committed da964df Merge

merge heads

Comments (0)

Files changed (2)

cffi/ffiplatform.py

     """
 
 
-def get_extension(srcfilename, modname, **kwds):
+def get_extension(srcfilename, modname, sources=(), **kwds):
     from distutils.core import Extension
-    return Extension(name=modname, sources=[srcfilename], **kwds)
+    allsources = [srcfilename]
+    allsources.extend(sources)
+    return Extension(name=modname, sources=allsources, **kwds)
 
 def compile(tmpdir, ext):
     """Compile a C extension module using distutils."""

testing/test_zdistutils.py

         v.get_extension()
         assert os.path.exists(v.sourcefilename)
 
+    def test_extension_object_extra_sources(self):
+        ffi = FFI()
+        ffi.cdef("double test1eoes(double x);")
+        extra_source = str(udir.join('extension_extra_sources.c'))
+        with open(extra_source, 'w') as f:
+            f.write('double test1eoes(double x) { return x * 6.0; }\n')
+        csrc = '''/*9*/
+        double test1eoes(double x);   /* or #include "extra_sources.h" */
+        '''
+        lib = ffi.verify(csrc, sources=[extra_source],
+                         force_generic_engine=self.generic)
+        assert lib.test1eoes(7.0) == 42.0
+        v = ffi.verifier
+        ext = v.get_extension()
+        assert 'distutils.extension.Extension' in str(ext.__class__)
+        assert ext.sources == [v.sourcefilename, extra_source]
+        assert ext.name == v.get_module_name()
+
 
 class TestDistUtilsCPython(DistUtilsTest):
     generic = False
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.