feat: support multiarch system classifiers

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
Sefa Eyeoglu
2022-08-07 00:06:32 +02:00
parent 09e85e948c
commit 7bd8bd13fe
5 changed files with 106 additions and 39 deletions

View File

@ -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() {