Подключен LuaJit2.1

This commit is contained in:
2025-07-28 12:30:11 +06:00
parent 3e3b66a415
commit a53c2be381
2 changed files with 45 additions and 3 deletions

View File

@@ -70,9 +70,10 @@ set(BOOST_IOSTREAMS_ENABLE_ZLIB ON)
set(BOOST_INCLUDE_LIBRARIES asio thread json iostreams)
FetchContent_Declare(
Boost
URL https://github.com/boostorg/boost/releases/download/boost-1.87.0/boost-1.87.0-cmake.7z
USES_TERMINAL_DOWNLOAD TRUE
DOWNLOAD_NO_EXTRACT FALSE
GIT_REPOSITORY https://github.com/boostorg/boost.git
GIT_TAG boost-1.87.0
GIT_PROGRESS true
USES_TERMINAL_DOWNLOAD true
)
FetchContent_MakeAvailable(Boost)
target_link_libraries(luavox_common INTERFACE Boost::asio Boost::thread Boost::json Boost::iostreams)
@@ -81,6 +82,28 @@ target_link_libraries(luavox_common INTERFACE Boost::asio Boost::thread Boost::j
# find_package(glm REQUIRED)
# target_include_directories(${PROJECT_NAME} PUBLIC ${GLM_INCLUDE_DIR})
# target_link_libraries(${PROJECT_NAME} PUBLIC ${GLM_LIBRARY})
FetchContent_Declare(
luajit
GIT_REPOSITORY https://luajit.org/git/luajit.git
GIT_TAG v2.1
GIT_PROGRESS true
USES_TERMINAL_DOWNLOAD true
)
FetchContent_MakeAvailable(luajit)
FetchContent_Declare(
lua_cmake
GIT_REPOSITORY https://github.com/zhaozg/luajit-cmake.git
GIT_TAG 300c0b3f472be2be158f5b2e6385579ba5c6c0f9
GIT_PROGRESS true
USES_TERMINAL_DOWNLOAD true
)
set(LUAJIT_DIR ${luajit_SOURCE_DIR})
FetchContent_MakeAvailable(lua_cmake)
target_link_libraries(luavox_common INTERFACE luajit::lib luajit::header)
FetchContent_Declare(
glm

View File

@@ -25,9 +25,21 @@
#include "glm/gtc/noise.hpp"
#include <fstream>
extern "C" {
#include "lauxlib.h"
#include "lua.h"
}
namespace js = boost::json;
int luaPanic(lua_State *L)
{
size_t length;
const char *str = luaL_checklstring(L, -1, &length);
MAKE_ERROR("LUA PANIC: unprotected error in call to Lua API (" << std::string_view(str, length) << ")");
return 0;
}
namespace LV::Server {
@@ -53,6 +65,13 @@ GameServer::GameServer(asio::io_context &ioc, fs::path worldPath)
for(size_t iter = 0; iter < BackingAsyncLua.Threads.size(); iter++) {
BackingAsyncLua.Threads[iter] = std::thread(&BackingAsyncLua_t::run, &BackingAsyncLua, iter);
}
// Тест луа
lua_State *m_luastack = luaL_newstate();
lua_atpanic(m_luastack, &luaPanic);
}
GameServer::~GameServer() {