Skip to content

Commit 2a927c7

Browse files
committed
Add support for Apple Silicon (arm64)
1 parent 631afc4 commit 2a927c7

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

Server/dbconmy/premake5.lua

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ project "Dbconmy"
4141
includedirs {
4242
os.findheader("mysql.h", {
4343
"/usr/local/opt/mysql/include/mysql",
44+
"/opt/homebrew/include/mysql",
4445
"/opt/osxcross/macports/pkgs/opt/local/include/mysql8/mysql",
4546
})
4647
}

Shared/sdk/SharedUtil.File.hpp

+7
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,18 @@ bool SharedUtil::FileLoad(std::nothrow_t, const SString& filePath, SString& outB
156156

157157
CloseHandle(handle);
158158
return true;
159+
#else
160+
#ifdef __APPLE__
161+
struct stat info;
162+
163+
if (stat(filePath, &info) != 0)
164+
return false;
159165
#else
160166
struct stat64 info;
161167

162168
if (stat64(filePath, &info) != 0)
163169
return false;
170+
#endif
164171

165172
size_t fileSize = static_cast<size_t>(info.st_size);
166173

Shared/sdk/SharedUtil.Misc.hpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
#endif
3737
#endif
3838

39-
#ifdef __APPLE__
40-
#include "cpuid.h"
39+
#if defined(__APPLE__) && !defined(__aarch64__)
40+
#include <cpuid.h>
4141
#endif
4242

4343
CCriticalSection CRefCountable::ms_CS;
@@ -1834,6 +1834,8 @@ namespace SharedUtil
18341834
return FnGetCurrentProcessorNumber();
18351835

18361836
return _GetCurrentProcessorNumberXP();
1837+
#elif defined(__APPLE__) && defined(__aarch64__)
1838+
return -1;
18371839
#elif defined(__APPLE__)
18381840
// Hacked from https://stackoverflow.com/a/40398183/1517394
18391841
unsigned long cpu;
@@ -1851,6 +1853,7 @@ namespace SharedUtil
18511853
cpu = 0;
18521854

18531855
return cpu;
1856+
#endif
18541857
#else
18551858
// This should work on Linux
18561859
return sched_getcpu();

premake5.lua

+5-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ workspace "MTASA"
2626
configurations {"Debug", "Release", "Nightly"}
2727

2828
if os.host() == "macosx" then
29-
platforms { "x64" }
29+
platforms { "x64", "arm64" }
3030
elseif os.host() == "windows" then
3131
platforms { "x86", "x64", "arm64" }
3232
else
@@ -103,6 +103,10 @@ workspace "MTASA"
103103
defaultplatform "x86"
104104
end
105105

106+
filter { "system:macosx", "platforms:arm64" }
107+
includedirs { "/opt/homebrew/include" }
108+
libdirs { "/opt/homebrew/lib" }
109+
106110
filter {"system:windows", "configurations:Nightly", "kind:not StaticLib"}
107111
symbolspath "$(SolutionDir)Symbols\\$(Configuration)_$(Platform)\\$(ProjectName).pdb"
108112

0 commit comments

Comments
 (0)