Merge pull request #334 from wheremyfoodat/delete-emu

Add libuv to lua bindings
This commit is contained in:
wheremyfoodat
2024-02-01 20:00:14 +00:00
committed by GitHub
5 changed files with 36 additions and 2 deletions

6
.gitmodules vendored
View File

@@ -49,3 +49,9 @@
[submodule "third_party/oaknut"]
path = third_party/oaknut
url = https://github.com/merryhime/oaknut
[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

View File

@@ -266,6 +266,16 @@ set(THIRD_PARTY_SOURCE_FILES third_party/imgui/imgui.cpp
third_party/xxhash/xxhash.c
)
if(ENABLE_LUAJIT AND NOT ANDROID)
# Build luv and libuv for Lua TCP server usage if we're not on Android
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)
set(LIBUV_BUILD_SHARED OFF)
add_subdirectory(third_party/libuv)
endif()
if(ENABLE_QT_GUI)
include_directories(third_party/duckstation)
@@ -433,6 +443,11 @@ endif()
if(ENABLE_LUAJIT)
target_compile_definitions(Alber PUBLIC "PANDA3DS_ENABLE_LUA=1")
target_link_libraries(Alber PRIVATE libluajit)
# If we're not on Android, link libuv too
if (NOT ANDROID)
target_link_libraries(Alber PRIVATE uv_a)
endif()
endif()
if(ENABLE_OPENGL)

View File

@@ -1,6 +1,12 @@
#ifdef PANDA3DS_ENABLE_LUA
#include "lua_manager.hpp"
#ifndef __ANDROID__
extern "C" {
#include "luv.h"
}
#endif
void LuaManager::initialize() {
L = luaL_newstate(); // Open Lua
@@ -9,10 +15,15 @@ void LuaManager::initialize() {
initialized = false;
return;
}
luaL_openlibs(L);
initializeThunks();
#ifndef __ANDROID__
lua_pushstring(L, "luv");
luaopen_luv(L);
lua_settable(L, LUA_GLOBALSINDEX);
#endif
initializeThunks();
initialized = true;
haveScript = false;
}

1
third_party/libuv vendored Submodule

Submodule third_party/libuv added at b8368a1441

1
third_party/luv vendored Submodule

Submodule third_party/luv added at 3e55ac4331