yaze_py rename src and header, add boost::python

This commit is contained in:
scawful
2024-08-07 01:08:13 -04:00
parent 3631a962bc
commit 2a1509b311
3 changed files with 30 additions and 6 deletions

View File

@@ -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
)

View File

@@ -1,7 +1,22 @@
#include "yaze_python.h"
#include "yaze_py.h"
#include <Python.h>
#include <boost/python.hpp>
#include "yaze.h"
BOOST_PYTHON_MODULE(yaze) {
using namespace boost::python;
def("yaze_init", yaze_init);
class_<Rom>("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) {

View File

@@ -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