diff --git a/src/py/CMakeLists.txt b/src/py/CMakeLists.txt index d38b5b2d..f6cf1a73 100644 --- a/src/py/CMakeLists.txt +++ b/src/py/CMakeLists.txt @@ -1,20 +1,29 @@ -find_package(Python3 COMPONENTS Interpreter Development REQUIRED) +find_package(PythonLibs 3.8 COMPONENTS Interpreter Development REQUIRED) +cmake_policy(SET CMP0167 NEW) +find_package(Boost COMPONENTS python3 REQUIRED) +set(CMAKE_SHARED_MODULE_PREFIX "") + +# target x86_64 for module add_library( - yaze_py - py/yaze_python.cc + yaze_py MODULE + py/yaze_py.cc ) set(PYTHON_HEADERS /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/Headers) target_include_directories( yaze_py PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/ lib/ app/ ${PYTHON_HEADERS} + ${Boost_INCLUDE_DIRS} + ${PYTHON_INCLUDE_DIRS} ) target_link_libraries( yaze_py PUBLIC - Python + ${PYTHON_LIBRARIES} + Boost::python3 ) \ No newline at end of file diff --git a/src/py/yaze_python.cc b/src/py/yaze_py.cc similarity index 50% rename from src/py/yaze_python.cc rename to src/py/yaze_py.cc index 77ce79dc..9d426a1b 100644 --- a/src/py/yaze_python.cc +++ b/src/py/yaze_py.cc @@ -1,7 +1,22 @@ -#include "yaze_python.h" +#include "yaze_py.h" #include +#include + +#include "yaze.h" + +BOOST_PYTHON_MODULE(yaze) { + using namespace boost::python; + def("yaze_init", yaze_init); + + class_("Rom") + .def_readonly("filename", &Rom::filename) + .def_readonly("data", &Rom::data) + .def_readonly("size", &Rom::size) + .def_readonly("impl", &Rom::impl); +} + static PyObject *SpamError; static PyObject *yaze_init(PyObject *self, PyObject *args) { diff --git a/src/py/yaze_python.h b/src/py/yaze_py.h similarity index 89% rename from src/py/yaze_python.h rename to src/py/yaze_py.h index 8b000b7d..9d6c459b 100644 --- a/src/py/yaze_python.h +++ b/src/py/yaze_py.h @@ -16,6 +16,6 @@ static struct PyModuleDef yaze_module = {PyModuleDef_HEAD_INIT, -1, // Interpreter state size YazeMethods}; -PyMODINIT_FUNC PyInit_yaze(void) { return PyModule_Create(&yaze_module); } +// PyMODINIT_FUNC PyInit_yaze(void) { return PyModule_Create(&yaze_module); } #endif // YAZE_PYTHON_H \ No newline at end of file