Code spaghetti and more chaos

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97 2024-01-27 22:47:28 +02:00
parent 4cd236ed80
commit 7317105e4d
No known key found for this signature in database
GPG key ID: 55EF5DA53DB36318
21 changed files with 613 additions and 391 deletions

View file

@ -17,13 +17,7 @@ bool rosettaDetect()
if (sysctlbyname("sysctl.proc_translated", &ret, &size, NULL, 0) == -1) {
return false;
}
if (ret == 0) {
return false;
}
if (ret == 1) {
return true;
}
return false;
return ret == 1;
}
#endif
@ -47,7 +41,6 @@ QString currentSystem()
QString useQTForArch()
{
auto qtArch = QSysInfo::currentCpuArchitecture();
#if defined(Q_OS_MACOS) && !defined(Q_PROCESSOR_ARM)
if (rosettaDetect()) {
return "arm64";
@ -55,7 +48,7 @@ QString useQTForArch()
return "x86_64";
}
#endif
return qtArch;
return QSysInfo::currentCpuArchitecture();
}
int suitableMaxMem()
@ -71,4 +64,36 @@ int suitableMaxMem()
return maxMemoryAlloc;
}
QString getSupportedJavaArchitecture()
{
auto sys = currentSystem();
auto arch = useQTForArch();
if (sys == "windows") {
if (arch == "x86_64")
return "windows-x64";
if (arch == "i386")
return "windows-x86";
// Unknown, maybe arm, appending arch
return "windows-" + arch;
}
if (sys == "osx") {
if (arch == "arm64")
return "mac-os-arm64";
if (arch.contains("64"))
return "mac-os-64";
if (arch.contains("86"))
return "mac-os-86";
// Unknown, maybe something new, appending arch
return "mac-os-" + arch;
} else if (sys == "linux") {
if (arch == "x86_64")
return "linux-x64";
if (arch == "i386")
return "linux-x86";
// will work for arm32 arm(64)
return "linux-" + arch;
}
return {};
}
} // namespace SysInfo