Skip to content

Commit

Permalink
Add support for Apple Silicon (arm64)
Browse files Browse the repository at this point in the history
  • Loading branch information
botder committed Aug 29, 2024
1 parent 631afc4 commit 2a927c7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions Server/dbconmy/premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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",
})
}
Expand Down
7 changes: 7 additions & 0 deletions Shared/sdk/SharedUtil.File.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<size_t>(info.st_size);

Expand Down
7 changes: 5 additions & 2 deletions Shared/sdk/SharedUtil.Misc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
#endif
#endif

#ifdef __APPLE__
#include "cpuid.h"
#if defined(__APPLE__) && !defined(__aarch64__)
#include <cpuid.h>
#endif

CCriticalSection CRefCountable::ms_CS;
Expand Down Expand Up @@ -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;
Expand All @@ -1851,6 +1853,7 @@ namespace SharedUtil
cpu = 0;

return cpu;
#endif
#else
// This should work on Linux
return sched_getcpu();
Expand Down
6 changes: 5 additions & 1 deletion premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"

Expand Down

0 comments on commit 2a927c7

Please sign in to comment.