diff --git a/.gitignore b/.gitignore index c575f6a..4bf4f5f 100644 --- a/.gitignore +++ b/.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 diff --git a/Makefile b/Makefile index b2ebd10..be82796 100644 --- a/Makefile +++ b/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 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..ded7134 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +pEpACIDgen +pyBind11 diff --git a/src/pEp/_gen/Makefile b/src/pEp/_gen/Makefile index 9c18dc3..77351f2 100644 --- a/src/pEp/_gen/Makefile +++ b/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) diff --git a/src/pEp/_gen/Makefile.conf b/src/pEp/_gen/Makefile.conf new file mode 100644 index 0000000..7e94d6d --- /dev/null +++ b/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/ diff --git a/src/pEp/_gen/adapter_main.hh b/src/pEp/_gen/adapter_main.hh new file mode 100644 index 0000000..a942b9a --- /dev/null +++ b/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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// libpEpAdapter +#include +#include +#include +#include + +#endif // ADAPTER_MAIN_HH diff --git a/src/pEp/_gen/gen/Makefile b/src/pEp/_gen/gen/Makefile new file mode 100644 index 0000000..af62435 --- /dev/null +++ b/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) + diff --git a/src/pEp/_gen/gen/config.json b/src/pEp/_gen/gen/config.json new file mode 100644 index 0000000..ba322a4 --- /dev/null +++ b/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" +} diff --git a/src/pEp/_gen/pEpModule.cc b/src/pEp/_gen/pEpModule.cc index 1286a29..b8bc418 100644 --- a/src/pEp/_gen/pEpModule.cc +++ b/src/pEp/_gen/pEpModule.cc @@ -1,5 +1,8 @@ #include +#include #include +#include +#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" + +}