From 1a2a123d87a08304eb3edf9f6f6c30f35d33620d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucca=20Jim=C3=A9nez=20K=C3=B6nings?= Date: Thu, 25 Nov 2021 01:41:41 +0100 Subject: [PATCH] Fix various macOS compatibility issues --- CMakeLists.txt | 11 +++++++---- include/TLuaEngine.h | 2 +- src/Common.cpp | 2 +- src/LuaAPI.cpp | 2 +- src/SignalHandling.cpp | 4 ++-- src/TLuaEngine.cpp | 10 +++++----- 6 files changed, 17 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ba8e99..70bf321 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,9 @@ add_compile_definitions(CPPHTTPLIB_OPENSSL_SUPPORT __linux) if(APPLE) set(LUA_INCLUDE_DIR /usr/local/Cellar/lua@5.3/5.3.6/include/lua5.3) set(LUA_LIBRARIES lua) + include_directories(/usr/local/opt/openssl@1.1/include) link_directories(/usr/local/Cellar/lua@5.3/5.3.6/lib) + link_directories(/usr/local/opt/openssl@1.1/lib) endif() if (WIN32) @@ -121,15 +123,16 @@ target_link_libraries(BeamMP-Server sol2::sol2 ${LUA_LIBRARIES}) message(STATUS "CURL IS ${CURL_LIBRARIES}") if (UNIX) - target_link_libraries(BeamMP-Server + target_link_libraries(BeamMP-Server z - pthread - stdc++fs + pthread ${LUA_LIBRARIES} crypto ${OPENSSL_LIBRARIES} commandline - sentry) + sentry + ssl + ) elseif (WIN32) include(FindLua) message(STATUS "Looking for libz") diff --git a/include/TLuaEngine.h b/include/TLuaEngine.h index 50d5235..c38afc8 100644 --- a/include/TLuaEngine.h +++ b/include/TLuaEngine.h @@ -32,7 +32,7 @@ struct TLuaResult { std::atomic_bool Ready; std::atomic_bool Error; std::string ErrorMessage; - sol::object Result { sol::nil }; + sol::object Result { sol::lua_nil }; TLuaStateId StateId; std::string Function; // TODO: Add condition_variable diff --git a/src/Common.cpp b/src/Common.cpp index d578241..59fb366 100644 --- a/src/Common.cpp +++ b/src/Common.cpp @@ -118,7 +118,7 @@ void RegisterThread(const std::string& str) { #ifdef WIN32 ThreadId = std::to_string(GetCurrentThreadId()); #elif __APPLE__ - ThreadId = std::to_string(getpid()); + ThreadId = std::to_string(getpid()); // todo: research if 'getpid()' is a valid, posix compliant alternative to 'gettid()' #else ThreadId = std::to_string(gettid()); #endif diff --git a/src/LuaAPI.cpp b/src/LuaAPI.cpp index d1ff0a8..7b56543 100644 --- a/src/LuaAPI.cpp +++ b/src/LuaAPI.cpp @@ -42,7 +42,7 @@ static std::string LuaToString(const sol::object Value, size_t Indent = 1, bool ss << Value.as(); return ss.str(); } - case sol::type::nil: + case sol::type::lua_nil: case sol::type::none: return ""; case sol::type::boolean: diff --git a/src/SignalHandling.cpp b/src/SignalHandling.cpp index f95c54e..49f50c5 100644 --- a/src/SignalHandling.cpp +++ b/src/SignalHandling.cpp @@ -1,7 +1,7 @@ #include "SignalHandling.h" #include "Common.h" -#ifdef __unix +#if defined(__unix) || defined(__linux) || defined(__APPLE__) #include static void UnixSignalHandler(int sig) { switch (sig) { @@ -48,7 +48,7 @@ BOOL WINAPI Win32CtrlC_Handler(DWORD CtrlType) { void SetupSignalHandlers() { // signal handlers for unix#include -#if defined(__unix) || defined(__linux) +#if defined(__unix) || defined(__linux) || defined(__APPLE__) beammp_trace("registering handlers for signals"); signal(SIGPIPE, UnixSignalHandler); signal(SIGTERM, UnixSignalHandler); diff --git a/src/TLuaEngine.cpp b/src/TLuaEngine.cpp index 6d80e67..cd712c1 100644 --- a/src/TLuaEngine.cpp +++ b/src/TLuaEngine.cpp @@ -281,7 +281,7 @@ sol::table TLuaEngine::StateThreadData::Lua_TriggerGlobalEvent(const std::string auto Vector = Self.get>>("ReturnValueImpl"); for (const auto& Value : Vector) { if (!Value->Ready) { - return sol::nil; + return sol::lua_nil; } Result.add(Value->Result); } @@ -313,7 +313,7 @@ sol::table TLuaEngine::StateThreadData::Lua_GetPlayerIdentifiers(int ID) { if (MaybeClient && !MaybeClient.value().expired()) { auto IDs = MaybeClient.value().lock()->GetIdentifiers(); if (IDs.empty()) { - return sol::nil; + return sol::lua_nil; } sol::table Result = mStateView.create_table(); for (const auto& Pair : IDs) { @@ -321,7 +321,7 @@ sol::table TLuaEngine::StateThreadData::Lua_GetPlayerIdentifiers(int ID) { } return Result; } else { - return sol::nil; + return sol::lua_nil; } } @@ -356,7 +356,7 @@ sol::table TLuaEngine::StateThreadData::Lua_GetPlayerVehicles(int ID) { VehicleData = *LockedData.VehicleData; } // End Vehicle Data Lock Scope if (VehicleData.empty()) { - return sol::nil; + return sol::lua_nil; } sol::state_view StateView(mState); sol::table Result = StateView.create_table(); @@ -365,7 +365,7 @@ sol::table TLuaEngine::StateThreadData::Lua_GetPlayerVehicles(int ID) { } return Result; } else - return sol::nil; + return sol::lua_nil; } sol::table TLuaEngine::StateThreadData::Lua_HttpCreateConnection(const std::string& host, uint16_t port) {