From 66ca0a94ebd3841e2387a02cd4d6160902ff9f42 Mon Sep 17 00:00:00 2001
From: "alexey.stratulat" <alexey.stratulat@demlabs.net>
Date: Fri, 20 Mar 2020 17:01:29 +0700
Subject: [PATCH] [+] Added submodule python-cellframe and import CellFrame
 added inclusion of the python-cellframe module.

---
 .gitmodules                 | 3 +++
 CMakeLists.txt              | 4 +++-
 include/dap_chain_plugins.h | 1 +
 python-cellframe            | 1 +
 src/dap_chain_plugins.c     | 2 ++
 5 files changed, 10 insertions(+), 1 deletion(-)
 create mode 100644 .gitmodules
 create mode 160000 python-cellframe

diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 00000000..66ca5e84
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "python-cellframe"]
+	path = python-cellframe
+	url = https://gitlab.demlabs.net/cellframe/python-cellframe.git
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 15472c37..719087b1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,6 +6,8 @@ set(CMAKE_COLOR_MAKEFILE   ON)
 set(CMAKE_C_STANDARD 11)
 add_definitions("-fpic")
 add_definitions("-DDAP_LOG_MT")
+add_subdirectory(python-cellframe)
+target_compile_options(API_CellFrame PRIVATE "-fpic")
 
 if(UNIX)
     add_definitions("-DDAP_OS_UNIX")
@@ -22,7 +24,7 @@ add_library(${PROJECT_NAME} STATIC ${CHAIN_PLUGINS_PYTHON_SRCS} ${CHAIN_PLUGINS_
 
 target_link_libraries(${PROJECT_NAME})
 
-target_link_libraries(${PROJECT_NAME} dap_core  )
+target_link_libraries(${PROJECT_NAME} dap_core  API_CellFrame)
 
 target_include_directories(${PROJECT_NAME} PUBLIC include/ )
 
diff --git a/include/dap_chain_plugins.h b/include/dap_chain_plugins.h
index fd98781d..54837f31 100644
--- a/include/dap_chain_plugins.h
+++ b/include/dap_chain_plugins.h
@@ -6,6 +6,7 @@
 #include "dap_file_utils.h"
 #include "dap_chain_plugins_manifest.h"
 #include "dap_chain_plugins_list.h"
+#include "python-cellframe.h"
 
 #ifdef __cplusplus
 extern "C"{
diff --git a/python-cellframe b/python-cellframe
new file mode 160000
index 00000000..72321f76
--- /dev/null
+++ b/python-cellframe
@@ -0,0 +1 @@
+Subproject commit 72321f7659412b5eab817ac1398c8053510ee981
diff --git a/src/dap_chain_plugins.c b/src/dap_chain_plugins.c
index ff3654eb..98a8822e 100644
--- a/src/dap_chain_plugins.c
+++ b/src/dap_chain_plugins.c
@@ -9,6 +9,7 @@ int dap_chain_plugins_init(dap_config_t *config){
             log_it(L_ERROR, "The directory %s was not found.", plugins_root_path);
             return -1;
         }
+        PyImport_AppendInittab("CellFrame", PyInit_libCellFrame);
         Py_Initialize();
         PyObject *sys_module = PyImport_ImportModule("sys");
         sys_path = PyObject_GetAttrString(sys_module, "path");
@@ -107,6 +108,7 @@ void dap_chain_plugins_load_plugin(const char *dir_path, const char *name){
             if (_PyLong_AsInt(res_int) == 0){
                 dap_chain_plugins_list_add(module, name);
             } else {
+                PyErr_Print();
                 log_it(L_ERROR, "Code error %i at initialization %s plugin", _PyLong_AsInt(res_int), name);
             }
         } else {
-- 
GitLab