diff options
author | Sefa Eyeoglu <contact@scrumplex.net> | 2022-08-07 00:06:32 +0200 |
---|---|---|
committer | Sefa Eyeoglu <contact@scrumplex.net> | 2022-09-20 16:01:06 +0200 |
commit | 7bd8bd13feddded96b087bb142101f87cb0003b8 (patch) | |
tree | ba79d0606877c85d9768a5549d32ef20b3700cd1 /launcher/RuntimeContext.h | |
parent | 09e85e948cdb361c306a1cccbc3557a464366a21 (diff) | |
download | PrismLauncher-7bd8bd13feddded96b087bb142101f87cb0003b8.tar.gz PrismLauncher-7bd8bd13feddded96b087bb142101f87cb0003b8.tar.bz2 PrismLauncher-7bd8bd13feddded96b087bb142101f87cb0003b8.zip |
feat: support multiarch system classifiers
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
Diffstat (limited to 'launcher/RuntimeContext.h')
-rw-r--r-- | launcher/RuntimeContext.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/launcher/RuntimeContext.h b/launcher/RuntimeContext.h index 76785728..d98d407f 100644 --- a/launcher/RuntimeContext.h +++ b/launcher/RuntimeContext.h @@ -1,5 +1,6 @@ #pragma once +#include <QSet> #include <QString> #include "settings/SettingsObject.h" @@ -7,6 +8,7 @@ struct RuntimeContext { QString javaArchitecture; QString javaRealArchitecture; QString javaPath; + QString system; QString mappedJavaRealArchitecture() const { if (javaRealArchitecture == "aarch64") { @@ -19,6 +21,27 @@ struct RuntimeContext { javaArchitecture = instanceSettings->get("JavaArchitecture").toString(); javaRealArchitecture = instanceSettings->get("JavaRealArchitecture").toString(); javaPath = instanceSettings->get("JavaPath").toString(); + system = currentSystem(); + } + + QString getClassifier() const { + return system + "-" + mappedJavaRealArchitecture(); + } + + // "Legacy" refers to the fact that Mojang assumed that these are the only two architectures + bool isLegacyArch() const { + QSet<QString> legacyArchitectures{"amd64", "x86_64", "i686"}; + return legacyArchitectures.contains(mappedJavaRealArchitecture()); + } + + bool classifierMatches(QString target) const { + // try to match precise classifier "[os]-[arch]" + bool x = target == getClassifier(); + // try to match imprecise classifier on legacy architectures "[os]" + if (!x && isLegacyArch()) + x = target == system; + + return x; } static QString currentSystem() { |