From 2a927c7033335f7e87564eb24b112323ea9f535b Mon Sep 17 00:00:00 2001 From: Marek Kulik Date: Fri, 30 Aug 2024 01:41:57 +0200 Subject: [PATCH] Add support for Apple Silicon (arm64) --- Server/dbconmy/premake5.lua | 1 + Shared/sdk/SharedUtil.File.hpp | 7 +++++++ Shared/sdk/SharedUtil.Misc.hpp | 7 +++++-- premake5.lua | 6 +++++- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Server/dbconmy/premake5.lua b/Server/dbconmy/premake5.lua index 3bd8cf5eff..125047f906 100644 --- a/Server/dbconmy/premake5.lua +++ b/Server/dbconmy/premake5.lua @@ -41,6 +41,7 @@ project "Dbconmy" includedirs { os.findheader("mysql.h", { "/usr/local/opt/mysql/include/mysql", + "/opt/homebrew/include/mysql", "/opt/osxcross/macports/pkgs/opt/local/include/mysql8/mysql", }) } diff --git a/Shared/sdk/SharedUtil.File.hpp b/Shared/sdk/SharedUtil.File.hpp index 351afa63c3..0a1cf56c7c 100644 --- a/Shared/sdk/SharedUtil.File.hpp +++ b/Shared/sdk/SharedUtil.File.hpp @@ -156,11 +156,18 @@ bool SharedUtil::FileLoad(std::nothrow_t, const SString& filePath, SString& outB CloseHandle(handle); return true; +#else +#ifdef __APPLE__ + struct stat info; + + if (stat(filePath, &info) != 0) + return false; #else struct stat64 info; if (stat64(filePath, &info) != 0) return false; +#endif size_t fileSize = static_cast(info.st_size); diff --git a/Shared/sdk/SharedUtil.Misc.hpp b/Shared/sdk/SharedUtil.Misc.hpp index ed789460d1..1ebf46a599 100644 --- a/Shared/sdk/SharedUtil.Misc.hpp +++ b/Shared/sdk/SharedUtil.Misc.hpp @@ -36,8 +36,8 @@ #endif #endif -#ifdef __APPLE__ - #include "cpuid.h" +#if defined(__APPLE__) && !defined(__aarch64__) + #include #endif CCriticalSection CRefCountable::ms_CS; @@ -1834,6 +1834,8 @@ namespace SharedUtil return FnGetCurrentProcessorNumber(); return _GetCurrentProcessorNumberXP(); +#elif defined(__APPLE__) && defined(__aarch64__) + return -1; #elif defined(__APPLE__) // Hacked from https://stackoverflow.com/a/40398183/1517394 unsigned long cpu; @@ -1851,6 +1853,7 @@ namespace SharedUtil cpu = 0; return cpu; + #endif #else // This should work on Linux return sched_getcpu(); diff --git a/premake5.lua b/premake5.lua index 34dc2e37f4..c3375ad1e0 100644 --- a/premake5.lua +++ b/premake5.lua @@ -26,7 +26,7 @@ workspace "MTASA" configurations {"Debug", "Release", "Nightly"} if os.host() == "macosx" then - platforms { "x64" } + platforms { "x64", "arm64" } elseif os.host() == "windows" then platforms { "x86", "x64", "arm64" } else @@ -103,6 +103,10 @@ workspace "MTASA" defaultplatform "x86" end + filter { "system:macosx", "platforms:arm64" } + includedirs { "/opt/homebrew/include" } + libdirs { "/opt/homebrew/lib" } + filter {"system:windows", "configurations:Nightly", "kind:not StaticLib"} symbolspath "$(SolutionDir)Symbols\\$(Configuration)_$(Platform)\\$(ProjectName).pdb"