mirror of
https://github.com/open-goal/jak-project
synced 2026-07-03 04:53:35 -04:00
macos: don't assume that all macOS major versions are simple numeric values
This commit is contained in:
+7
-2
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "common/log/log.h"
|
||||
#include "common/util/string_util.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <stdio.h>
|
||||
@@ -112,7 +113,7 @@ CpuInfo& get_cpu_info() {
|
||||
return gCpuInfo;
|
||||
}
|
||||
|
||||
std::optional<double> get_macos_version() {
|
||||
std::optional<double> get_macos_major_version() {
|
||||
#ifndef __APPLE__
|
||||
return {};
|
||||
#else
|
||||
@@ -124,7 +125,11 @@ std::optional<double> get_macos_version() {
|
||||
return {};
|
||||
}
|
||||
try {
|
||||
return std::stod(buffer);
|
||||
std::string macos_major_version = buffer;
|
||||
if (str_util::contains(buffer, ".")) {
|
||||
macos_major_version = str_util::split_string(macos_major_version, ".")[0];
|
||||
}
|
||||
return std::stod(macos_major_version);
|
||||
} catch (std::exception& e) {
|
||||
lg::error("Error occured when attempting to convert sysctl value {} to number", buffer);
|
||||
return {};
|
||||
|
||||
+1
-1
@@ -18,4 +18,4 @@ struct CpuInfo {
|
||||
|
||||
CpuInfo& get_cpu_info();
|
||||
|
||||
std::optional<double> get_macos_version();
|
||||
std::optional<double> get_macos_major_version();
|
||||
|
||||
+2
-2
@@ -182,8 +182,8 @@ int main(int argc, char** argv) {
|
||||
// Check if we are on a modern enough version of macOS so that AVX can be
|
||||
// emulated via rosetta
|
||||
#ifdef __APPLE__
|
||||
auto macos_version = get_macos_version();
|
||||
if (macos_version < 15.0) {
|
||||
auto macos_major_version = get_macos_major_version();
|
||||
if (macos_major_version < 15.0) {
|
||||
lg::info(
|
||||
"Your CPU does not support AVX. But the newer version of Rosetta supports it, update to "
|
||||
"atleast Sequoia to run OpenGOAL!");
|
||||
|
||||
Reference in New Issue
Block a user