12345678910111213141516171819202122232425262728 |
- from cffi import FFI, __version__ as cffi_version
- def get_header():
- f = open('/usr/local/include/pcilib.h')
- lines = [x for x in f if not x.startswith('#') and not 'logger' in x and not 'extern "C"' in x]
- # cut last 4 lines because they contain the rest of the extern "C" bits
- lines = lines[:-4]
- # hack because we cannot figure out the system-dependent timeval structure
- lines.insert(0, 'struct timeval { uint32_t tv_sec; uint32_t tv_usec; };')
- return '\n'.join(lines)
- builder = FFI()
- builder.set_source("_pciffi",
- r"""
- #include <sys/time.h>
- #include <pcilib.h>
- """,
- libraries=['pcilib'])
- builder.cdef(get_header())
- if __name__ == '__main__':
- builder.compile(verbose=True)
|