diff --git a/.gitmodules b/.gitmodules index 8a6cac49..93bb8f9d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -43,3 +43,9 @@ [submodule "third_party/hydra_core"] path = third_party/hydra_core url = https://github.com/hydra-emu/core +[submodule "third_party/luv"] + path = third_party/luv + url = https://github.com/luvit/luv +[submodule "third_party/libuv"] + path = third_party/libuv + url = https://github.com/libuv/libuv diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a718fbb..52ddb495 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -245,6 +245,15 @@ set(THIRD_PARTY_SOURCE_FILES third_party/imgui/imgui.cpp third_party/xxhash/xxhash.c ) +if(ENABLE_LUAJIT) + # Build luv and libuv for TCP Lua server usage + include_directories(third_party/luv/src) + include_directories(third_party/luv/deps/lua-compat-5.3/c-api) + include_directories(third_party/libuv/include) + set(THIRD_PARTY_SOURCE_FILES ${THIRD_PARTY_SOURCE_FILES} third_party/luv/src/luv.c) + + add_subdirectory(third_party/libuv) +endif() if(ENABLE_QT_GUI) include_directories(third_party/duckstation) @@ -399,7 +408,7 @@ endif() if(ENABLE_LUAJIT) target_compile_definitions(Alber PUBLIC "PANDA3DS_ENABLE_LUA=1") - target_link_libraries(Alber PRIVATE libluajit) + target_link_libraries(Alber PRIVATE libluajit uv) endif() if(ENABLE_OPENGL) diff --git a/src/lua.cpp b/src/lua.cpp index 729b6581..f7e0b719 100644 --- a/src/lua.cpp +++ b/src/lua.cpp @@ -1,6 +1,10 @@ #ifdef PANDA3DS_ENABLE_LUA #include "lua_manager.hpp" +extern "C" { + #include "luv.h" +} + void LuaManager::initialize() { L = luaL_newstate(); // Open Lua @@ -11,6 +15,9 @@ void LuaManager::initialize() { } luaL_openlibs(L); + lua_pushstring(L, "luv"); + luaopen_luv(L); + lua_settable(L, LUA_GLOBALSINDEX); initializeThunks(); initialized = true; diff --git a/third_party/libuv b/third_party/libuv new file mode 160000 index 00000000..b8368a14 --- /dev/null +++ b/third_party/libuv @@ -0,0 +1 @@ +Subproject commit b8368a1441fd4ebdaaae70b67136c80b1a98be32 diff --git a/third_party/luv b/third_party/luv new file mode 160000 index 00000000..3e55ac43 --- /dev/null +++ b/third_party/luv @@ -0,0 +1 @@ +Subproject commit 3e55ac4331d06aa5f43016a142aa2aaa23264105