mirror of
https://github.com/deltachat/deltachat-core.git
synced 2025-10-04 18:29:19 +02:00
Build from the installed deltachat version
This cleans up the build somewhat: - Move time_t declaration to _build.py - Uses Python's distutils to invoke the "correct" compiler. Or at least does not make this code responsible to picking a compiler - Uses the compiler to find the installed header file, builds against this installed version. Since linking will also be against this installed version this seems to make some sense. This seems somewhat ugly though.
This commit is contained in:
parent
b1261ed028
commit
9048a2dbab
3 changed files with 29 additions and 24 deletions
|
@ -1,23 +1,35 @@
|
|||
import subprocess
|
||||
import distutils.ccompiler
|
||||
import distutils.sysconfig
|
||||
import tempfile
|
||||
|
||||
import cffi
|
||||
|
||||
|
||||
ffibuilder = cffi.FFI()
|
||||
ffibuilder.set_source(
|
||||
def ffibuilder():
|
||||
builder = cffi.FFI()
|
||||
builder.set_source(
|
||||
'deltachat.capi',
|
||||
"""
|
||||
#include <deltachat/mrmailbox.h>
|
||||
""",
|
||||
libraries=['deltachat'],
|
||||
)
|
||||
with tempfile.NamedTemporaryFile(mode='r') as fp:
|
||||
proc = subprocess.run(['gcc', '-E', '-o', fp.name, '-DPY_CFFI=1',
|
||||
'../src/mrmailbox.h'])
|
||||
proc.check_returncode()
|
||||
ffibuilder.cdef(fp.read())
|
||||
)
|
||||
builder.cdef("""
|
||||
typedef int... time_t;
|
||||
""")
|
||||
cc = distutils.ccompiler.new_compiler(force=True)
|
||||
distutils.sysconfig.customize_compiler(cc)
|
||||
with tempfile.NamedTemporaryFile(mode='w', suffix='.h') as src_fp:
|
||||
src_fp.write('#include <deltachat/mrmailbox.h>')
|
||||
src_fp.flush()
|
||||
with tempfile.NamedTemporaryFile(mode='r') as dst_fp:
|
||||
cc.preprocess(source=src_fp.name,
|
||||
output_file=dst_fp.name,
|
||||
macros=[('PY_CFFI', '1')])
|
||||
builder.cdef(dst_fp.read())
|
||||
return builder
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
ffibuilder.compile(verbose=True)
|
||||
builder = ffibuilder()
|
||||
builder.compile(verbose=True)
|
||||
|
|
|
@ -150,18 +150,15 @@ extern "C" {
|
|||
#ifndef PY_CFFI
|
||||
#include <pthread.h>
|
||||
#include <libetpan/libetpan.h> /* defines uint16_t */
|
||||
#endif
|
||||
|
||||
#include "mrarray.h"
|
||||
#endif
|
||||
#include "mrchatlist.h"
|
||||
#ifndef PY_CFFI
|
||||
#include "mrchat.h"
|
||||
#endif
|
||||
#include "mrmsg.h"
|
||||
#include "mrcontact.h"
|
||||
#ifndef PY_CFFI
|
||||
#include "mrlot.h"
|
||||
#include "mrevent.h"
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,10 +26,6 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef PY_CFFI
|
||||
typedef int... time_t;
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct _mrmailbox mrmailbox_t;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue