mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-04 00:36:14 +00:00
Fix various macOS compatibility issues
This commit is contained in:
parent
6247061d09
commit
1a2a123d87
@ -21,7 +21,9 @@ add_compile_definitions(CPPHTTPLIB_OPENSSL_SUPPORT __linux)
|
|||||||
if(APPLE)
|
if(APPLE)
|
||||||
set(LUA_INCLUDE_DIR /usr/local/Cellar/lua@5.3/5.3.6/include/lua5.3)
|
set(LUA_INCLUDE_DIR /usr/local/Cellar/lua@5.3/5.3.6/include/lua5.3)
|
||||||
set(LUA_LIBRARIES lua)
|
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/Cellar/lua@5.3/5.3.6/lib)
|
||||||
|
link_directories(/usr/local/opt/openssl@1.1/lib)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
@ -124,12 +126,13 @@ if (UNIX)
|
|||||||
target_link_libraries(BeamMP-Server
|
target_link_libraries(BeamMP-Server
|
||||||
z
|
z
|
||||||
pthread
|
pthread
|
||||||
stdc++fs
|
|
||||||
${LUA_LIBRARIES}
|
${LUA_LIBRARIES}
|
||||||
crypto
|
crypto
|
||||||
${OPENSSL_LIBRARIES}
|
${OPENSSL_LIBRARIES}
|
||||||
commandline
|
commandline
|
||||||
sentry)
|
sentry
|
||||||
|
ssl
|
||||||
|
)
|
||||||
elseif (WIN32)
|
elseif (WIN32)
|
||||||
include(FindLua)
|
include(FindLua)
|
||||||
message(STATUS "Looking for libz")
|
message(STATUS "Looking for libz")
|
||||||
|
@ -32,7 +32,7 @@ struct TLuaResult {
|
|||||||
std::atomic_bool Ready;
|
std::atomic_bool Ready;
|
||||||
std::atomic_bool Error;
|
std::atomic_bool Error;
|
||||||
std::string ErrorMessage;
|
std::string ErrorMessage;
|
||||||
sol::object Result { sol::nil };
|
sol::object Result { sol::lua_nil };
|
||||||
TLuaStateId StateId;
|
TLuaStateId StateId;
|
||||||
std::string Function;
|
std::string Function;
|
||||||
// TODO: Add condition_variable
|
// TODO: Add condition_variable
|
||||||
|
@ -118,7 +118,7 @@ void RegisterThread(const std::string& str) {
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
ThreadId = std::to_string(GetCurrentThreadId());
|
ThreadId = std::to_string(GetCurrentThreadId());
|
||||||
#elif __APPLE__
|
#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
|
#else
|
||||||
ThreadId = std::to_string(gettid());
|
ThreadId = std::to_string(gettid());
|
||||||
#endif
|
#endif
|
||||||
|
@ -42,7 +42,7 @@ static std::string LuaToString(const sol::object Value, size_t Indent = 1, bool
|
|||||||
ss << Value.as<float>();
|
ss << Value.as<float>();
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
case sol::type::nil:
|
case sol::type::lua_nil:
|
||||||
case sol::type::none:
|
case sol::type::none:
|
||||||
return "<nil>";
|
return "<nil>";
|
||||||
case sol::type::boolean:
|
case sol::type::boolean:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "SignalHandling.h"
|
#include "SignalHandling.h"
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
|
||||||
#ifdef __unix
|
#if defined(__unix) || defined(__linux) || defined(__APPLE__)
|
||||||
#include <csignal>
|
#include <csignal>
|
||||||
static void UnixSignalHandler(int sig) {
|
static void UnixSignalHandler(int sig) {
|
||||||
switch (sig) {
|
switch (sig) {
|
||||||
@ -48,7 +48,7 @@ BOOL WINAPI Win32CtrlC_Handler(DWORD CtrlType) {
|
|||||||
|
|
||||||
void SetupSignalHandlers() {
|
void SetupSignalHandlers() {
|
||||||
// signal handlers for unix#include <windows.h>
|
// 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");
|
beammp_trace("registering handlers for signals");
|
||||||
signal(SIGPIPE, UnixSignalHandler);
|
signal(SIGPIPE, UnixSignalHandler);
|
||||||
signal(SIGTERM, UnixSignalHandler);
|
signal(SIGTERM, UnixSignalHandler);
|
||||||
|
@ -281,7 +281,7 @@ sol::table TLuaEngine::StateThreadData::Lua_TriggerGlobalEvent(const std::string
|
|||||||
auto Vector = Self.get<std::vector<std::shared_ptr<TLuaResult>>>("ReturnValueImpl");
|
auto Vector = Self.get<std::vector<std::shared_ptr<TLuaResult>>>("ReturnValueImpl");
|
||||||
for (const auto& Value : Vector) {
|
for (const auto& Value : Vector) {
|
||||||
if (!Value->Ready) {
|
if (!Value->Ready) {
|
||||||
return sol::nil;
|
return sol::lua_nil;
|
||||||
}
|
}
|
||||||
Result.add(Value->Result);
|
Result.add(Value->Result);
|
||||||
}
|
}
|
||||||
@ -313,7 +313,7 @@ sol::table TLuaEngine::StateThreadData::Lua_GetPlayerIdentifiers(int ID) {
|
|||||||
if (MaybeClient && !MaybeClient.value().expired()) {
|
if (MaybeClient && !MaybeClient.value().expired()) {
|
||||||
auto IDs = MaybeClient.value().lock()->GetIdentifiers();
|
auto IDs = MaybeClient.value().lock()->GetIdentifiers();
|
||||||
if (IDs.empty()) {
|
if (IDs.empty()) {
|
||||||
return sol::nil;
|
return sol::lua_nil;
|
||||||
}
|
}
|
||||||
sol::table Result = mStateView.create_table();
|
sol::table Result = mStateView.create_table();
|
||||||
for (const auto& Pair : IDs) {
|
for (const auto& Pair : IDs) {
|
||||||
@ -321,7 +321,7 @@ sol::table TLuaEngine::StateThreadData::Lua_GetPlayerIdentifiers(int ID) {
|
|||||||
}
|
}
|
||||||
return Result;
|
return Result;
|
||||||
} else {
|
} else {
|
||||||
return sol::nil;
|
return sol::lua_nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,7 +356,7 @@ sol::table TLuaEngine::StateThreadData::Lua_GetPlayerVehicles(int ID) {
|
|||||||
VehicleData = *LockedData.VehicleData;
|
VehicleData = *LockedData.VehicleData;
|
||||||
} // End Vehicle Data Lock Scope
|
} // End Vehicle Data Lock Scope
|
||||||
if (VehicleData.empty()) {
|
if (VehicleData.empty()) {
|
||||||
return sol::nil;
|
return sol::lua_nil;
|
||||||
}
|
}
|
||||||
sol::state_view StateView(mState);
|
sol::state_view StateView(mState);
|
||||||
sol::table Result = StateView.create_table();
|
sol::table Result = StateView.create_table();
|
||||||
@ -365,7 +365,7 @@ sol::table TLuaEngine::StateThreadData::Lua_GetPlayerVehicles(int ID) {
|
|||||||
}
|
}
|
||||||
return Result;
|
return Result;
|
||||||
} else
|
} else
|
||||||
return sol::nil;
|
return sol::lua_nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
sol::table TLuaEngine::StateThreadData::Lua_HttpCreateConnection(const std::string& host, uint16_t port) {
|
sol::table TLuaEngine::StateThreadData::Lua_HttpCreateConnection(const std::string& host, uint16_t port) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user