diff --git a/bindings/CMakeLists.txt b/bindings/CMakeLists.txt new file mode 100644 index 0000000..a3301ed --- /dev/null +++ b/bindings/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.12) +project(hakoniwa_multi_language_project) + +find_package(SWIG REQUIRED) +include(${SWIG_USE_FILE}) +set(CMAKE_SWIG_FLAGS "") + +# ヘッダーファイルのインクルードパスを設定 +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../src/include) +# SWIGインターフェースファイルの相対パスを設定 +set(SWIG_INTERFACE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/hako_asset.i) +set_source_files_properties(${SWIG_INTERFACE_FILE} PROPERTIES CPLUSPLUS ON) +# ライブラリのフルパスを検索 +find_library(ASSETS_LIBRARY + NAMES assets + PATHS /usr/local/lib/hakoniwa +) + +add_subdirectory(python) + diff --git a/bindings/cmake-build/.gitkeep b/bindings/cmake-build/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/bindings/hako_asset.i b/bindings/hako_asset.i new file mode 100644 index 0000000..b7cbff7 --- /dev/null +++ b/bindings/hako_asset.i @@ -0,0 +1,26 @@ +%module hako_asset + +%{ +#include "hako_asset.h" +%} + +%include "hako_primitive_types.h" + + +%typemap(in) hako_asset_callbacks_t *callbacks (void *ptr) { + $1 = (hako_asset_callbacks_t *)malloc(sizeof(hako_asset_callbacks_t)); + if (!$1) { + PyErr_NoMemory(); + return NULL; + } + $1->on_initialize = NULL; + $1->on_simulation_step = NULL; + $1->on_manual_timing_control = NULL; + $1->on_reset = NULL; + ptr = $1; +} + +%typemap(freearg) hako_asset_callbacks_t *callbacks { + free($1); +} +%include "hako_asset.h" diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt new file mode 100644 index 0000000..97a2c58 --- /dev/null +++ b/bindings/python/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.12) +project(hakoniwa_python_swig_project) + +find_package(PythonLibs REQUIRED) +include_directories(${PYTHON_INCLUDE_PATH}) + +swig_add_library(hako_asset_py LANGUAGE python SOURCES ${SWIG_INTERFACE_FILE}) +swig_link_libraries(hako_asset_py ${PYTHON_LIBRARIES} ${ASSETS_LIBRARY})