Skip to content
Snippets Groups Projects
Commit 9502c629 authored by alexey.stratulat's avatar alexey.stratulat
Browse files

Prepared the basis for creating python-cellframe

parent 8b6c4a91
No related branches found
No related tags found
1 merge request!1Features 2466
project(CellFrame C)
cmake_minimum_required(VERSION 2.8)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_COLOR_MAKEFILE ON)
set(CMAKE_C_STANDARD 11)
set(SUBMODULES_NO_BUILD ON)
#add_subdirectory(libdap)
#add_subdirectory(libdap-crypto)
file(GLOB PYTHON_CELLFRAME_SRCS src/*.c)
file(GLOB PYTHON_CELLFRAME_HEADERS include/*.h)
set(Python_ADDITIONAL_VERSIONS 3.7)
find_package (PythonLibs REQUIRED)
#find_package(PkgConfig)
#pkg_check_modules(PC_JSON-C REQUIRED json-c)
include_directories(${PYTHON_INCLUDE_DIR} include/)
add_library(${PROJECT_NAME} SHARED ${PYTHON_CELLFRAME_SRCS} ${PYTHON_CELLFRAME_HEADERS})
target_link_libraries(${PROJECT_NAME})
target_link_libraries(${PROJECT_NAME} ${PYTHON_LIBRARIES})
#target_compile_options(
# dap_core PRIVATE
# "-fpic"
#)
#target_link_libraries(${PROJECT_NAME} dap_core dap_crypto)
#file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/src/libdapConnector.py
# DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
#file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test/main_test.py
# DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
#if(BUILD_DAP_TESTS)
# file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test/main_test.py
# DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
# enable_testing()
#add_subdirectory(test)
#endif()
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifdef __cplusplus
extern "C" {
#endif
PyObject *python_cellframe_init(PyObject *self, PyObject *args);
static PyMethodDef CellFramePythonMethods[] = {
{"init", python_cellframe_init, METH_VARARGS, "Initialization of the python-cellframe interface DAP (Deus Applicaions Prototypes)"},
//{"deinit", dap_server_core_deinit, METH_NOARGS, "Deinitialization of the DAP (Deus Applicaions Prototypes) server core library"},
//{"loop", dap_server_core_loop, METH_VARARGS, ""},
//{"listen", dap_server_core_listen, METH_VARARGS, ""},
{NULL, NULL, 0, NULL}
};
static struct PyModuleDef CellFramePythonModule = {
PyModuleDef_HEAD_INIT,
"libCellFrame", /* name of module */
NULL, /* module documentation, may be NULL */
-1, /* size of per-interpreter state of the module,
or -1 if the module keeps state in global variables. */
CellFramePythonMethods
};
PyMODINIT_FUNC PyInit_libCellFrame(void);
#ifdef __cplusplus
}
#endif
#include "python-cellframe.h"
PyMODINIT_FUNC PyInit_libCellFrame(void){
PyObject *module = PyModule_Create(&CellFramePythonModule);
return module;
}
PyObject *python_cellframe_init(PyObject *self, PyObject *args){
return PyLong_FromLong(0);
}
int main(int argc, char **argv) {
wchar_t *program = Py_DecodeLocale(argv[0], NULL);
if (program == NULL) {
fprintf(stderr, "Fatal error: cannot decode argv[0]\n");
exit(1);
}
/* Add a built-in module, before Py_Initialize */
PyImport_AppendInittab("libCellFrame", PyInit_libCellFrame);
/* Pass argv[0] to the Python interpreter */
Py_SetProgramName(program);
/* Initialize the Python interpreter. Required. */
Py_Initialize();
/* Optionally import the module; alternatively,
import can be deferred until the embedded script
imports it. */
PyImport_ImportModule("libCellFrame");
PyMem_RawFree(program);
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment