diff --git a/plugins/lua/CMakeLists.txt b/plugins/lua/CMakeLists.txt index b3a6a51..a801ec3 100644 --- a/plugins/lua/CMakeLists.txt +++ b/plugins/lua/CMakeLists.txt @@ -11,14 +11,21 @@ SET(LUA_HDRS cluainterpreter.h cpilua.h ) +# cpilua.cpp will be appended below SET(LUA_SRCS callbacks.cpp cconsole.cpp cluainterpreter.cpp - cpilua.cpp ) +CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/cpilua.cpp" "${CMAKE_CURRENT_BINARY_DIR}/cpilua.cpp" @ONLY) +LIST(APPEND LUA_SRCS "${CMAKE_CURRENT_BINARY_DIR}/cpilua.cpp") + +ADD_LIBRARY(libvh_lua_wrapper MODULE "wrapper.c") +SET_TARGET_PROPERTIES(libvh_lua_wrapper PROPERTIES OUTPUT_NAME "vh_lua_wrapper") +target_link_libraries(libvh_lua_wrapper ${LUA_LIBRARIES}) + ADD_LIBRARY(liblua_pi MODULE ${LUA_SRCS}) SET_TARGET_PROPERTIES(liblua_pi PROPERTIES OUTPUT_NAME "lua_pi") target_link_libraries(liblua_pi ${LUA_LIBRARIES}) -INSTALL(TARGETS liblua_pi LIBRARY DESTINATION lib) +INSTALL(TARGETS liblua_pi libvh_lua_wrapper LIBRARY DESTINATION lib) diff --git a/plugins/lua/cpilua.cpp b/plugins/lua/cpilua.cpp index 536f28f..979246e 100644 --- a/plugins/lua/cpilua.cpp +++ b/plugins/lua/cpilua.cpp @@ -27,6 +27,9 @@ #include #include #include "src/script_api.h" +#include + +#define WRAPPER_PATH "@CMAKE_INSTALL_PREFIX@/lib/libvh_lua_wrapper.so" namespace nVerliHub { using namespace nUtils; @@ -71,6 +74,12 @@ void cpiLua::SetLogLevel( int level ) void cpiLua::OnLoad(cServerDC *server) { + void* lib_handle = dlopen(WRAPPER_PATH, RTLD_LAZY | RTLD_GLOBAL); + if (!lib_handle) { + std::cerr << "Error during dlopen(libvh_lua_wrapper): " << dlerror() << "\n"; + return; + } + cVHPlugin::OnLoad(server); mQuery = new cQuery(server->mMySQL); diff --git a/plugins/lua/wrapper.c b/plugins/lua/wrapper.c new file mode 100644 index 0000000..479aeb9 --- /dev/null +++ b/plugins/lua/wrapper.c @@ -0,0 +1,21 @@ +/************************************************************************** +* Copyright (C) 2011 by Shurik * +* shurik at sbin.ru * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the * +* Free Software Foundation, Inc., * +* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * +***************************************************************************/ + +// liblua wrapper for Verlihub LuaScript plugin