diff options
author | Armin Rigo <arigo@tunes.org> | 2012-08-18 11:59:50 +0200 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2012-08-18 11:59:50 +0200 |
commit | 7edcee52da19657c2513a7c46729d66841973602 (patch) | |
tree | 4321e3e4b831c2a6af612215170e273e47314c31 | |
parent | 5dd5f536ac8bc885df527952c2f4192d65ae4000 (diff) | |
download | cffi-7edcee52da19657c2513a7c46729d66841973602.tar.gz |
Support for "sources=[..]" in verify(), as per Daniel Holth's suggestion
(issue #17). Test.
-rw-r--r-- | cffi/ffiplatform.py | 6 | ||||
-rw-r--r-- | testing/test_zdistutils.py | 18 |
2 files changed, 22 insertions, 2 deletions
diff --git a/cffi/ffiplatform.py b/cffi/ffiplatform.py index 447edbb..a76a20f 100644 --- a/cffi/ffiplatform.py +++ b/cffi/ffiplatform.py @@ -11,9 +11,11 @@ class VerificationMissing(Exception): """ -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.""" diff --git a/testing/test_zdistutils.py b/testing/test_zdistutils.py index 5175adb..3778f81 100644 --- a/testing/test_zdistutils.py +++ b/testing/test_zdistutils.py @@ -157,6 +157,24 @@ class DistUtilsTest(object): 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 |