Browse Source

introduce pEpACIDgen - Abstract C Interface Definition Generator

REWORK
heck 5 years ago
parent
commit
2e138e1190
  1. 7
      .gitignore
  2. 12
      Makefile
  3. 2
      requirements.txt
  4. 56
      src/pEp/_gen/Makefile
  5. 12
      src/pEp/_gen/Makefile.conf
  6. 27
      src/pEp/_gen/adapter_main.hh
  7. 25
      src/pEp/_gen/gen/Makefile
  8. 13
      src/pEp/_gen/gen/config.json
  9. 7
      src/pEp/_gen/pEpModule.cc

7
.gitignore

@ -47,4 +47,9 @@ __pycache__/
.DS_store
# pEpACIDgen generated files
/src/pEp/_gen/gen/adapter_main.hh.acid.json
/src/pEp/_gen/gen/adapter_main.hh.acid.yml
/src/pEp/_gen/gen/adapter_main.hh.ast.json
/src/pEp/_gen/gen/py_module.pybind11
/src/pEp/_gen/gen/py_module.yml2

12
Makefile

@ -3,12 +3,20 @@ include Makefile.conf
.PHONY: all compile compile-inplace dist dist-egg dist-whl install install-user venv envtest install-test test develop docs clean clean-all clean-docs
all: dist
# Install pEpACIDgen from local repo clone, not from pypi
install-pepacidgen:
pip3 install -r requirements.txt --find-links ../pEpACIDgen/dist
# Build
# =====
compile:
gen: install-pepacidgen
$(MAKE) -C src/pEp/_gen gen
compile: gen
python3 setup.py build_ext $(DEBUG_OPT) $(PREFIX_OPT)
compile-inplace:
compile-inplace: gen
python3 setup.py build_ext $(DEBUG_OPT) $(PREFIX_OPT) --inplace
# Packaging

2
requirements.txt

@ -0,0 +1,2 @@
pEpACIDgen
pyBind11

56
src/pEp/_gen/Makefile

@ -1,32 +1,46 @@
include ../Makefile.conf
TARGET=$(TARGET_GEN)
include Makefile.conf
# Specific Build settings
CXXFLAGS+=
INCLUDES+=
LIB_DIRS+=
LIBS+=
LDFLAGS+=
TARGET=_gen.so
TARGET_MODULE_DYN=$(TARGET)
TARGET_MODULE_STATIC=$(TARGET)
CXX=clang
CXXFLAGS+=-std=c++11 -g
SRCS+=$(wildcard *.cc)
OBJS+=$(SRCS:.cc=.o)
# Combine Settings
CXXFLAGS+=$(INCLUDES)
LDFLAGS+=$(LIB_DIRS)
LDFLAGS+=$(LIBS)
LDFLAGS_DYN+=-undefined dynamic_lookup $(LIBS_PATH) $(LIBS)
LDFLAGS_STATIC+=-undefined dynamic_lookup
$(info -----BUILD INFO----)
$(info SRCS $(SRCS))
$(info OBJS $(OBJS))
.PHONY: all gen module_dyn module_static clean
all: static
static: gen module_static
dyn: gen module_dyn
gen:
$(MAKE) -C gen
SRCS:=$(wildcard *.cc)
OBJS:=$(SRCS:.cc=.o)
module_dyn: $(TARGET_MODULE_DYN)
.PHONY: clean
$(TARGET_MODULE_DYN) : $(OBJS)
$(CXX) $(LDFLAGS_DYN) -o $@ $^
all: $(TARGET)
module_static: $(TARGET_MODULE_STATIC)
# Using implicit compile target
# And explicit link taget
$(TARGET): $(OBJS)
$(CXX) $(LDFLAGS) -o $@ $^
$(TARGET_MODULE_STATIC) : $(OBJS) $(LIBS_STATIC)
$(CXX) $(LDFLAGS_STATIC) -o $@ $^
clean:
rm -rf $(TARGET)
rm -rf $(OBJS)
$(MAKE) -C gen clean
rm -f $(TARGET)
rm -f $(OBJS)

12
src/pEp/_gen/Makefile.conf

@ -0,0 +1,12 @@
# pyBind11 and python headers
INCLUDES+=$(shell pybind11-config --includes)
# example lib
# INCLUDES+=-I../../../lib/lib_synth_shed
# static lib (.a)
# LIBS_STATIC+=../../../lib/lib_synth_shed/libsynth_shed.a
# dynamic lib (.so)
# LIBS+=-lsynth_shed
# LIBS_PATH+=-L../../../lib/lib_synth_shed/

27
src/pEp/_gen/adapter_main.hh

@ -0,0 +1,27 @@
// This file is under GNU Affero General Public License 3.0
// see LICENSE.txt
#ifndef ADAPTER_MAIN_HH
#define ADAPTER_MAIN_HH
// Engine
#include <pEp/pEpEngine.h>
#include <pEp/keymanagement.h>
#include <pEp/identity_list.h>
#include <pEp/key_reset.h>
#include <pEp/sync_api.h>
#include <pEp/mime.h>
#include <pEp/message.h>
#include <pEp/message_api.h>
#include <pEp/sync_codec.h>
#include <pEp/distribution_codec.h>
#include <pEp/timestamp.h>
#include <pEp/stringpair.h>
// libpEpAdapter
#include <pEp/Adapter.hh>
#include <pEp/callback_dispatcher.hh>
#include <pEp/status_to_string.hh>
#include <pEp/pEpLog.hh>
#endif // ADAPTER_MAIN_HH

25
src/pEp/_gen/gen/Makefile

@ -0,0 +1,25 @@
include ../Makefile.conf
YML2_FILE=py_module.yml2
YSL2_FILE=$(shell pEp_acid_gen-config)
PYBIND11_FILE=py_module.pybind11
$(info -----SYNTH_SHED GEN----)
$(info YML2_FILE $(YML2_FILE))
$(info YSL2_FILE $(YSL2_FILE))
$(info CC_FILE $(PYBIND11_FILE))
.PHONY = yml pybind11
all: $(PYBIND11_FILE)
$(YML2_FILE): config.json
pEp_acid_gen $^
$(PYBIND11_FILE) : $(YML2_FILE)
yml2proc --encoding=utf8 -y $(YSL2_FILE) $(YML2_FILE)
clean:
rm -f $(YML2_FILE)
rm -f $(PYBIND11_FILE)

13
src/pEp/_gen/gen/config.json

@ -0,0 +1,13 @@
{
"module_name": "_gen",
"header_filename": "../../_pEp/adapter_main.hh",
"libclang_path": "/opt/local/libexec/llvm-9.0/lib/libclang.dylib",
"variables": [
],
"functions": [
"myself"
],
"debug_ast" : "True",
"debug_acid" : "True",
"debug_yml" : "True"
}

7
src/pEp/_gen/pEpModule.cc

@ -1,5 +1,8 @@
#include <string>
#include <iostream>
#include <pybind11/pybind11.h>
#include <pybind11/detail/common.h>
#include "adapter_main.hh"
using namespace std;
@ -10,5 +13,7 @@ string testfunc() {
PYBIND11_MODULE(_gen, m) {
m.doc() = "pybind11 example plugin"; // optional module docstring
m.def("add", &testfunc, "A function which adds two numbers");
}
#include "gen/py_module.pybind11"
}

Loading…
Cancel
Save