-
Notifications
You must be signed in to change notification settings - Fork 0
/
extend_build.py
32 lines (24 loc) · 961 Bytes
/
extend_build.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from sample_build import ffibuilder
from cffi import FFI
import os
extended_ffibuilder = FFI()
extended_ffibuilder.include(ffibuilder)
extended_ffibuilder.cdef("""
int do_more_stuff(point_t p);
""")
# set_source() gives the name of the python extension module to
# produce, and some C source code as a string. This C code needs
# to make the declarated functions, types and globals available,
# so it is often just the "#include".
extended_ffibuilder.set_source("_extended_cffi",
"""
#include "./sample/sample.h" // the C header of the library
#include "stdio.h"
int do_more_stuff(point_t p);
""",
library_dirs=['./sample','./extended'],
include_dirs=['./sample'],
libraries=['sample', 'extended'],
extra_link_args=['-Wl,-rpath=' + os.path.abspath('./sample')+',-rpath=' + os.path.abspath('./extended')]) # library name, for the linker
if __name__ == "__main__":
extended_ffibuilder.compile(verbose=True)