For development statically link dcc-rs

This links the python bindings statically to libdeltachat.a if the
DCC_RS_DEV environment variable is set to the project's root.  This is
a little simpler then requiring the manual CFLAGS and LD_LIBRARY_PATH
tweaking.

It also adds a script to easily invoke the integration tests locally
without forgetting steps.
This commit is contained in:
Floris Bruynooghe
2019-06-10 17:17:34 +02:00
parent af8d056206
commit 5090b4d24b
7 changed files with 88 additions and 45 deletions

View File

@@ -2,7 +2,7 @@ from deltachat import capi, const
from deltachat.capi import ffi
from deltachat.account import Account # noqa
__version__ = "0.10.0dev1"
__version__ = "0.10.0.dev2"
_DC_CALLBACK_MAP = {}

View File

@@ -1,17 +1,21 @@
import distutils.ccompiler
import distutils.log
import distutils.sysconfig
import tempfile
import os
import cffi
# XXX hack out the header and library dirs
# relying on CFLAGS and LD_LIBRARY_PATH being set properly is not good
# (but we also don't want to rely on global installs of headers and libs)
HEADERDIR = os.environ["CFLAGS"].split("-I", 1)[1]
LIBDIR = os.environ["LD_LIBRARY_PATH"]
def ffibuilder():
projdir = os.environ.get('DCC_RS_DEV')
if projdir:
libs = []
objs = [os.path.join(projdir, 'target', 'release', 'libdeltachat.a')]
incs = [os.path.join(projdir, 'deltachat-ffi')]
else:
libs = ['deltachat']
objs = []
incs = []
builder = cffi.FFI()
builder.set_source(
'deltachat.capi',
@@ -35,9 +39,9 @@ def ffibuilder():
return result;
}
""",
libraries=['deltachat'],
include_dirs=[HEADERDIR],
library_dirs=[LIBDIR],
include_dirs=incs,
libraries=libs,
extra_objects=objs,
)
builder.cdef("""
typedef int... time_t;
@@ -45,6 +49,7 @@ def ffibuilder():
extern const char * dupstring_helper(const char* string);
extern int dc_get_event_signature_types(int);
""")
distutils.log.set_verbosity(distutils.log.INFO)
cc = distutils.ccompiler.new_compiler(force=True)
distutils.sysconfig.customize_compiler(cc)
with tempfile.NamedTemporaryFile(mode='w', suffix='.h') as src_fp:
@@ -53,7 +58,7 @@ def ffibuilder():
with tempfile.NamedTemporaryFile(mode='r') as dst_fp:
cc.preprocess(source=src_fp.name,
output_file=dst_fp.name,
include_dirs=[HEADERDIR],
include_dirs=incs,
macros=[('PY_CFFI', '1')])
builder.cdef(dst_fp.read())
builder.cdef("""