Fix various macOS compatibility issues

This commit is contained in:
Lucca Jiménez Könings 2021-11-25 01:41:41 +01:00 committed by Lion
parent 6247061d09
commit 1a2a123d87
6 changed files with 17 additions and 14 deletions

View File

@ -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")

View File

@ -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

View File

@ -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

View File

@ -42,7 +42,7 @@ static std::string LuaToString(const sol::object Value, size_t Indent = 1, bool
ss << Value.as<float>();
return ss.str();
}
case sol::type::nil:
case sol::type::lua_nil:
case sol::type::none:
return "<nil>";
case sol::type::boolean:

View File

@ -1,7 +1,7 @@
#include "SignalHandling.h"
#include "Common.h"
#ifdef __unix
#if defined(__unix) || defined(__linux) || defined(__APPLE__)
#include <csignal>
static void UnixSignalHandler(int sig) {
switch (sig) {
@ -48,7 +48,7 @@ BOOL WINAPI Win32CtrlC_Handler(DWORD CtrlType) {
void SetupSignalHandlers() {
// signal handlers for unix#include <windows.h>
#if defined(__unix) || defined(__linux)
#if defined(__unix) || defined(__linux) || defined(__APPLE__)
beammp_trace("registering handlers for signals");
signal(SIGPIPE, UnixSignalHandler);
signal(SIGTERM, UnixSignalHandler);

View File

@ -281,7 +281,7 @@ sol::table TLuaEngine::StateThreadData::Lua_TriggerGlobalEvent(const std::string
auto Vector = Self.get<std::vector<std::shared_ptr<TLuaResult>>>("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) {