python: Enable build with the local build of the Olm C library.
This patch adds the ability to build the bindings without having a globally installed Olm C library. Provided that the C library is already built, the tests can be run now with make test. Signed-off-by: Damir Jelić <poljar@termina.org.uk>
This commit is contained in:
parent
e3d6673371
commit
ac071d9c0d
3 changed files with 19 additions and 4 deletions
1
Makefile
1
Makefile
|
@ -125,6 +125,7 @@ $(RELEASE_TARGET): $(RELEASE_OBJECTS)
|
|||
-Wl,--version-script,version_script.ver \
|
||||
$(OUTPUT_OPTION) $(RELEASE_OBJECTS)
|
||||
ln -sf libolm.so.$(VERSION) $(BUILD_DIR)/libolm.so.$(MAJOR)
|
||||
ln -sf libolm.so.$(VERSION) $(BUILD_DIR)/libolm.so
|
||||
|
||||
debug: $(DEBUG_TARGET)
|
||||
.PHONY: debug
|
||||
|
|
|
@ -3,7 +3,7 @@ PYTHON ?= python
|
|||
all: olm
|
||||
|
||||
olm:
|
||||
$(PYTHON) setup.py build
|
||||
DEVELOP=$(DEVELOP) $(PYTHON) setup.py build
|
||||
|
||||
install: olm
|
||||
$(PYTHON) setup.py install --skip-build -O1 --root=$(DESTDIR)
|
||||
|
@ -24,12 +24,14 @@ clean:
|
|||
develop: _libolm.o
|
||||
py2develop: _libolm.so
|
||||
|
||||
_libolm.so: DEVELOP ?= 1
|
||||
_libolm.so: include/olm/olm.h olm_build.py
|
||||
python2 olm_build.py
|
||||
DEVELOP=$(DEVELOP) python2 olm_build.py
|
||||
-rm _libolm.c
|
||||
|
||||
_libolm.o: DEVELOP ?= 1
|
||||
_libolm.o: include/olm/olm.h olm_build.py
|
||||
python3 olm_build.py
|
||||
DEVELOP=$(DEVELOP) python3 olm_build.py
|
||||
-rm _libolm.c
|
||||
|
||||
.PHONY: all olm install clean test develop
|
||||
|
|
|
@ -24,6 +24,15 @@ from cffi import FFI
|
|||
ffibuilder = FFI()
|
||||
PATH = os.path.dirname(__file__)
|
||||
|
||||
DEVELOP = os.environ.get("DEVELOP")
|
||||
|
||||
compile_args = []
|
||||
link_args = []
|
||||
|
||||
if DEVELOP and DEVELOP.lower() in ["yes", "true", "1"]:
|
||||
compile_args = ["-I../include"]
|
||||
link_args = ['-Wl,-L=../build,-rpath=../build']
|
||||
|
||||
|
||||
ffibuilder.set_source(
|
||||
"_libolm",
|
||||
|
@ -31,7 +40,10 @@ ffibuilder.set_source(
|
|||
#include <olm/olm.h>
|
||||
#include <olm/inbound_group_session.h>
|
||||
#include <olm/outbound_group_session.h>
|
||||
""", libraries=["olm"])
|
||||
""",
|
||||
libraries=["olm"],
|
||||
extra_compile_args=compile_args,
|
||||
extra_link_args=link_args)
|
||||
|
||||
with open(os.path.join(PATH, "include/olm/olm.h")) as f:
|
||||
ffibuilder.cdef(f.read(), override=True)
|
||||
|
|
Loading…
Reference in a new issue