feat: support multiarch system classifiers
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
parent
09e85e948c
commit
7bd8bd13fe
@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <QSet>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include "settings/SettingsObject.h"
|
#include "settings/SettingsObject.h"
|
||||||
|
|
||||||
@ -7,6 +8,7 @@ struct RuntimeContext {
|
|||||||
QString javaArchitecture;
|
QString javaArchitecture;
|
||||||
QString javaRealArchitecture;
|
QString javaRealArchitecture;
|
||||||
QString javaPath;
|
QString javaPath;
|
||||||
|
QString system;
|
||||||
|
|
||||||
QString mappedJavaRealArchitecture() const {
|
QString mappedJavaRealArchitecture() const {
|
||||||
if (javaRealArchitecture == "aarch64") {
|
if (javaRealArchitecture == "aarch64") {
|
||||||
@ -19,6 +21,27 @@ struct RuntimeContext {
|
|||||||
javaArchitecture = instanceSettings->get("JavaArchitecture").toString();
|
javaArchitecture = instanceSettings->get("JavaArchitecture").toString();
|
||||||
javaRealArchitecture = instanceSettings->get("JavaRealArchitecture").toString();
|
javaRealArchitecture = instanceSettings->get("JavaRealArchitecture").toString();
|
||||||
javaPath = instanceSettings->get("JavaPath").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() {
|
static QString currentSystem() {
|
||||||
|
@ -112,9 +112,9 @@ QList<NetAction::Ptr> Library::getDownloads(
|
|||||||
{
|
{
|
||||||
if(isNative())
|
if(isNative())
|
||||||
{
|
{
|
||||||
if(m_nativeClassifiers.contains(runtimeContext.currentSystem()))
|
auto nativeClassifier = getCompatibleNative(runtimeContext);
|
||||||
|
if(!nativeClassifier.isNull())
|
||||||
{
|
{
|
||||||
auto nativeClassifier = m_nativeClassifiers[runtimeContext.currentSystem()];
|
|
||||||
if(nativeClassifier.contains("${arch}"))
|
if(nativeClassifier.contains("${arch}"))
|
||||||
{
|
{
|
||||||
auto nat32Classifier = nativeClassifier;
|
auto nat32Classifier = nativeClassifier;
|
||||||
@ -215,7 +215,7 @@ bool Library::isActive(const RuntimeContext & runtimeContext) const
|
|||||||
RuleAction ruleResult = Disallow;
|
RuleAction ruleResult = Disallow;
|
||||||
for (auto rule : m_rules)
|
for (auto rule : m_rules)
|
||||||
{
|
{
|
||||||
RuleAction temp = rule->apply(this);
|
RuleAction temp = rule->apply(this, runtimeContext);
|
||||||
if (temp != Defer)
|
if (temp != Defer)
|
||||||
ruleResult = temp;
|
ruleResult = temp;
|
||||||
}
|
}
|
||||||
@ -223,7 +223,7 @@ bool Library::isActive(const RuntimeContext & runtimeContext) const
|
|||||||
}
|
}
|
||||||
if (isNative())
|
if (isNative())
|
||||||
{
|
{
|
||||||
result = result && m_nativeClassifiers.contains(runtimeContext.currentSystem());
|
result = result && !getCompatibleNative(runtimeContext).isNull();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -238,6 +238,19 @@ bool Library::isAlwaysStale() const
|
|||||||
return m_hint == "always-stale";
|
return m_hint == "always-stale";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Library::getCompatibleNative(const RuntimeContext & runtimeContext) const {
|
||||||
|
// try to match precise classifier "[os]-[arch]"
|
||||||
|
auto entry = m_nativeClassifiers.constFind(runtimeContext.getClassifier());
|
||||||
|
// try to match imprecise classifier on legacy architectures "[os]"
|
||||||
|
if (entry == m_nativeClassifiers.constEnd() && runtimeContext.isLegacyArch())
|
||||||
|
entry = m_nativeClassifiers.constFind(runtimeContext.system);
|
||||||
|
|
||||||
|
if (entry == m_nativeClassifiers.constEnd())
|
||||||
|
return QString();
|
||||||
|
|
||||||
|
return entry.value();
|
||||||
|
}
|
||||||
|
|
||||||
void Library::setStoragePrefix(QString prefix)
|
void Library::setStoragePrefix(QString prefix)
|
||||||
{
|
{
|
||||||
m_storagePrefix = prefix;
|
m_storagePrefix = prefix;
|
||||||
@ -271,9 +284,10 @@ QString Library::filename(const RuntimeContext & runtimeContext) const
|
|||||||
|
|
||||||
// otherwise native, override classifiers. Mojang HACK!
|
// otherwise native, override classifiers. Mojang HACK!
|
||||||
GradleSpecifier nativeSpec = m_name;
|
GradleSpecifier nativeSpec = m_name;
|
||||||
if (m_nativeClassifiers.contains(runtimeContext.currentSystem()))
|
QString nativeClassifier = getCompatibleNative(runtimeContext);
|
||||||
|
if (!nativeClassifier.isNull())
|
||||||
{
|
{
|
||||||
nativeSpec.setClassifier(m_nativeClassifiers[runtimeContext.currentSystem()]);
|
nativeSpec.setClassifier(nativeClassifier);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -299,9 +313,10 @@ QString Library::storageSuffix(const RuntimeContext & runtimeContext) const
|
|||||||
|
|
||||||
// otherwise native, override classifiers. Mojang HACK!
|
// otherwise native, override classifiers. Mojang HACK!
|
||||||
GradleSpecifier nativeSpec = m_name;
|
GradleSpecifier nativeSpec = m_name;
|
||||||
if (m_nativeClassifiers.contains(runtimeContext.currentSystem()))
|
QString nativeClassifier = getCompatibleNative(runtimeContext);
|
||||||
|
if (!nativeClassifier.isNull())
|
||||||
{
|
{
|
||||||
nativeSpec.setClassifier(m_nativeClassifiers[runtimeContext.currentSystem()]);
|
nativeSpec.setClassifier(nativeClassifier);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <net/NetAction.h>
|
#include <net/NetAction.h>
|
||||||
#include <QPair>
|
#include <QPair>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
@ -155,6 +156,8 @@ public: /* methods */
|
|||||||
QList<NetAction::Ptr> getDownloads(const RuntimeContext & runtimeContext, class HttpMetaCache * cache,
|
QList<NetAction::Ptr> getDownloads(const RuntimeContext & runtimeContext, class HttpMetaCache * cache,
|
||||||
QStringList & failedLocalFiles, const QString & overridePath) const;
|
QStringList & failedLocalFiles, const QString & overridePath) const;
|
||||||
|
|
||||||
|
QString getCompatibleNative(const RuntimeContext & runtimeContext) const;
|
||||||
|
|
||||||
private: /* methods */
|
private: /* methods */
|
||||||
/// the default storage prefix used by PolyMC
|
/// the default storage prefix used by PolyMC
|
||||||
static QString defaultStoragePrefix();
|
static QString defaultStoragePrefix();
|
||||||
|
@ -37,7 +37,7 @@ class Rule
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
RuleAction m_result;
|
RuleAction m_result;
|
||||||
virtual bool applies(const Library *parent) = 0;
|
virtual bool applies(const Library *parent, const RuntimeContext & runtimeContext) = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Rule(RuleAction result) : m_result(result)
|
Rule(RuleAction result) : m_result(result)
|
||||||
@ -45,9 +45,9 @@ public:
|
|||||||
}
|
}
|
||||||
virtual ~Rule() {};
|
virtual ~Rule() {};
|
||||||
virtual QJsonObject toJson() = 0;
|
virtual QJsonObject toJson() = 0;
|
||||||
RuleAction apply(const Library *parent)
|
RuleAction apply(const Library *parent, const RuntimeContext & runtimeContext)
|
||||||
{
|
{
|
||||||
if (applies(parent))
|
if (applies(parent, runtimeContext))
|
||||||
return m_result;
|
return m_result;
|
||||||
else
|
else
|
||||||
return Defer;
|
return Defer;
|
||||||
@ -63,9 +63,9 @@ private:
|
|||||||
QString m_version_regexp;
|
QString m_version_regexp;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool applies(const Library *)
|
virtual bool applies(const Library *, const RuntimeContext & runtimeContext)
|
||||||
{
|
{
|
||||||
return (m_system == RuntimeContext::currentSystem());
|
return runtimeContext.classifierMatches(m_system);
|
||||||
}
|
}
|
||||||
OsRule(RuleAction result, QString system, QString version_regexp)
|
OsRule(RuleAction result, QString system, QString version_regexp)
|
||||||
: Rule(result), m_system(system), m_version_regexp(version_regexp)
|
: Rule(result), m_system(system), m_version_regexp(version_regexp)
|
||||||
@ -84,7 +84,7 @@ public:
|
|||||||
class ImplicitRule : public Rule
|
class ImplicitRule : public Rule
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
virtual bool applies(const Library *)
|
virtual bool applies(const Library *, const RuntimeContext & runtimeContext)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <minecraft/Library.h>
|
#include <minecraft/Library.h>
|
||||||
#include <net/HttpMetaCache.h>
|
#include <net/HttpMetaCache.h>
|
||||||
#include <FileSystem.h>
|
#include <FileSystem.h>
|
||||||
|
#include <RuntimeContext.h>
|
||||||
|
|
||||||
class LibraryTest : public QObject
|
class LibraryTest : public QObject
|
||||||
{
|
{
|
||||||
@ -24,6 +25,14 @@ private:
|
|||||||
{
|
{
|
||||||
return {FS::PathCombine(cache->getBasePath("libraries"), relative)};
|
return {FS::PathCombine(cache->getBasePath("libraries"), relative)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RuntimeContext dummyContext(QString system = "linux", QString arch = "64", QString realArch = "amd64") {
|
||||||
|
RuntimeContext r;
|
||||||
|
r.javaArchitecture = arch;
|
||||||
|
r.javaRealArchitecture = realArch;
|
||||||
|
r.system = system;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
private
|
private
|
||||||
slots:
|
slots:
|
||||||
void initTestCase()
|
void initTestCase()
|
||||||
@ -34,12 +43,13 @@ slots:
|
|||||||
}
|
}
|
||||||
void test_legacy()
|
void test_legacy()
|
||||||
{
|
{
|
||||||
|
RuntimeContext r = dummyContext();
|
||||||
Library test("test.package:testname:testversion");
|
Library test("test.package:testname:testversion");
|
||||||
QCOMPARE(test.artifactPrefix(), QString("test.package:testname"));
|
QCOMPARE(test.artifactPrefix(), QString("test.package:testname"));
|
||||||
QCOMPARE(test.isNative(), false);
|
QCOMPARE(test.isNative(), false);
|
||||||
|
|
||||||
QStringList jar, native, native32, native64;
|
QStringList jar, native, native32, native64;
|
||||||
test.getApplicableFiles(currentSystem, jar, native, native32, native64, QString());
|
test.getApplicableFiles(r, jar, native, native32, native64, QString());
|
||||||
QCOMPARE(jar, getStorage("test/package/testname/testversion/testname-testversion.jar"));
|
QCOMPARE(jar, getStorage("test/package/testname/testversion/testname-testversion.jar"));
|
||||||
QCOMPARE(native, {});
|
QCOMPARE(native, {});
|
||||||
QCOMPARE(native32, {});
|
QCOMPARE(native32, {});
|
||||||
@ -47,10 +57,11 @@ slots:
|
|||||||
}
|
}
|
||||||
void test_legacy_url()
|
void test_legacy_url()
|
||||||
{
|
{
|
||||||
|
RuntimeContext r = dummyContext();
|
||||||
QStringList failedFiles;
|
QStringList failedFiles;
|
||||||
Library test("test.package:testname:testversion");
|
Library test("test.package:testname:testversion");
|
||||||
test.setRepositoryURL("file://foo/bar");
|
test.setRepositoryURL("file://foo/bar");
|
||||||
auto downloads = test.getDownloads(currentSystem, cache.get(), failedFiles, QString());
|
auto downloads = test.getDownloads(r, cache.get(), failedFiles, QString());
|
||||||
QCOMPARE(downloads.size(), 1);
|
QCOMPARE(downloads.size(), 1);
|
||||||
QCOMPARE(failedFiles, {});
|
QCOMPARE(failedFiles, {});
|
||||||
NetAction::Ptr dl = downloads[0];
|
NetAction::Ptr dl = downloads[0];
|
||||||
@ -58,27 +69,29 @@ slots:
|
|||||||
}
|
}
|
||||||
void test_legacy_url_local_broken()
|
void test_legacy_url_local_broken()
|
||||||
{
|
{
|
||||||
|
RuntimeContext r = dummyContext();
|
||||||
Library test("test.package:testname:testversion");
|
Library test("test.package:testname:testversion");
|
||||||
QCOMPARE(test.isNative(), false);
|
QCOMPARE(test.isNative(), false);
|
||||||
QStringList failedFiles;
|
QStringList failedFiles;
|
||||||
test.setHint("local");
|
test.setHint("local");
|
||||||
auto downloads = test.getDownloads(currentSystem, cache.get(), failedFiles, QString());
|
auto downloads = test.getDownloads(r, cache.get(), failedFiles, QString());
|
||||||
QCOMPARE(downloads.size(), 0);
|
QCOMPARE(downloads.size(), 0);
|
||||||
QCOMPARE(failedFiles, {"testname-testversion.jar"});
|
QCOMPARE(failedFiles, {"testname-testversion.jar"});
|
||||||
}
|
}
|
||||||
void test_legacy_url_local_override()
|
void test_legacy_url_local_override()
|
||||||
{
|
{
|
||||||
|
RuntimeContext r = dummyContext();
|
||||||
Library test("com.paulscode:codecwav:20101023");
|
Library test("com.paulscode:codecwav:20101023");
|
||||||
QCOMPARE(test.isNative(), false);
|
QCOMPARE(test.isNative(), false);
|
||||||
QStringList failedFiles;
|
QStringList failedFiles;
|
||||||
test.setHint("local");
|
test.setHint("local");
|
||||||
auto downloads = test.getDownloads(currentSystem, cache.get(), failedFiles, QFINDTESTDATA("testdata/Library"));
|
auto downloads = test.getDownloads(r, cache.get(), failedFiles, QFINDTESTDATA("testdata/Library"));
|
||||||
QCOMPARE(downloads.size(), 0);
|
QCOMPARE(downloads.size(), 0);
|
||||||
qDebug() << failedFiles;
|
qDebug() << failedFiles;
|
||||||
QCOMPARE(failedFiles.size(), 0);
|
QCOMPARE(failedFiles.size(), 0);
|
||||||
|
|
||||||
QStringList jar, native, native32, native64;
|
QStringList jar, native, native32, native64;
|
||||||
test.getApplicableFiles(currentSystem, jar, native, native32, native64, QFINDTESTDATA("testdata/Library"));
|
test.getApplicableFiles(r, jar, native, native32, native64, QFINDTESTDATA("testdata/Library"));
|
||||||
QCOMPARE(jar, {QFileInfo(QFINDTESTDATA("testdata/Library/codecwav-20101023.jar")).absoluteFilePath()});
|
QCOMPARE(jar, {QFileInfo(QFINDTESTDATA("testdata/Library/codecwav-20101023.jar")).absoluteFilePath()});
|
||||||
QCOMPARE(native, {});
|
QCOMPARE(native, {});
|
||||||
QCOMPARE(native32, {});
|
QCOMPARE(native32, {});
|
||||||
@ -86,19 +99,20 @@ slots:
|
|||||||
}
|
}
|
||||||
void test_legacy_native()
|
void test_legacy_native()
|
||||||
{
|
{
|
||||||
|
RuntimeContext r = dummyContext();
|
||||||
Library test("test.package:testname:testversion");
|
Library test("test.package:testname:testversion");
|
||||||
test.m_nativeClassifiers["linux"] = "linux";
|
test.m_nativeClassifiers["linux"] = "linux";
|
||||||
QCOMPARE(test.isNative(), true);
|
QCOMPARE(test.isNative(), true);
|
||||||
test.setRepositoryURL("file://foo/bar");
|
test.setRepositoryURL("file://foo/bar");
|
||||||
{
|
{
|
||||||
QStringList jar, native, native32, native64;
|
QStringList jar, native, native32, native64;
|
||||||
test.getApplicableFiles(Os_Linux, jar, native, native32, native64, QString());
|
test.getApplicableFiles(r, jar, native, native32, native64, QString());
|
||||||
QCOMPARE(jar, {});
|
QCOMPARE(jar, {});
|
||||||
QCOMPARE(native, getStorage("test/package/testname/testversion/testname-testversion-linux.jar"));
|
QCOMPARE(native, getStorage("test/package/testname/testversion/testname-testversion-linux.jar"));
|
||||||
QCOMPARE(native32, {});
|
QCOMPARE(native32, {});
|
||||||
QCOMPARE(native64, {});
|
QCOMPARE(native64, {});
|
||||||
QStringList failedFiles;
|
QStringList failedFiles;
|
||||||
auto dls = test.getDownloads(Os_Linux, cache.get(), failedFiles, QString());
|
auto dls = test.getDownloads(r, cache.get(), failedFiles, QString());
|
||||||
QCOMPARE(dls.size(), 1);
|
QCOMPARE(dls.size(), 1);
|
||||||
QCOMPARE(failedFiles, {});
|
QCOMPARE(failedFiles, {});
|
||||||
auto dl = dls[0];
|
auto dl = dls[0];
|
||||||
@ -107,6 +121,7 @@ slots:
|
|||||||
}
|
}
|
||||||
void test_legacy_native_arch()
|
void test_legacy_native_arch()
|
||||||
{
|
{
|
||||||
|
RuntimeContext r = dummyContext();
|
||||||
Library test("test.package:testname:testversion");
|
Library test("test.package:testname:testversion");
|
||||||
test.m_nativeClassifiers["linux"]="linux-${arch}";
|
test.m_nativeClassifiers["linux"]="linux-${arch}";
|
||||||
test.m_nativeClassifiers["osx"]="osx-${arch}";
|
test.m_nativeClassifiers["osx"]="osx-${arch}";
|
||||||
@ -115,41 +130,43 @@ slots:
|
|||||||
test.setRepositoryURL("file://foo/bar");
|
test.setRepositoryURL("file://foo/bar");
|
||||||
{
|
{
|
||||||
QStringList jar, native, native32, native64;
|
QStringList jar, native, native32, native64;
|
||||||
test.getApplicableFiles(Os_Linux, jar, native, native32, native64, QString());
|
test.getApplicableFiles(r, jar, native, native32, native64, QString());
|
||||||
QCOMPARE(jar, {});
|
QCOMPARE(jar, {});
|
||||||
QCOMPARE(native, {});
|
QCOMPARE(native, {});
|
||||||
QCOMPARE(native32, getStorage("test/package/testname/testversion/testname-testversion-linux-32.jar"));
|
QCOMPARE(native32, getStorage("test/package/testname/testversion/testname-testversion-linux-32.jar"));
|
||||||
QCOMPARE(native64, getStorage("test/package/testname/testversion/testname-testversion-linux-64.jar"));
|
QCOMPARE(native64, getStorage("test/package/testname/testversion/testname-testversion-linux-64.jar"));
|
||||||
QStringList failedFiles;
|
QStringList failedFiles;
|
||||||
auto dls = test.getDownloads(Os_Linux, cache.get(), failedFiles, QString());
|
auto dls = test.getDownloads(r, cache.get(), failedFiles, QString());
|
||||||
QCOMPARE(dls.size(), 2);
|
QCOMPARE(dls.size(), 2);
|
||||||
QCOMPARE(failedFiles, {});
|
QCOMPARE(failedFiles, {});
|
||||||
QCOMPARE(dls[0]->m_url, QUrl("file://foo/bar/test/package/testname/testversion/testname-testversion-linux-32.jar"));
|
QCOMPARE(dls[0]->m_url, QUrl("file://foo/bar/test/package/testname/testversion/testname-testversion-linux-32.jar"));
|
||||||
QCOMPARE(dls[1]->m_url, QUrl("file://foo/bar/test/package/testname/testversion/testname-testversion-linux-64.jar"));
|
QCOMPARE(dls[1]->m_url, QUrl("file://foo/bar/test/package/testname/testversion/testname-testversion-linux-64.jar"));
|
||||||
}
|
}
|
||||||
|
r.system = "windows";
|
||||||
{
|
{
|
||||||
QStringList jar, native, native32, native64;
|
QStringList jar, native, native32, native64;
|
||||||
test.getApplicableFiles(Os_Windows, jar, native, native32, native64, QString());
|
test.getApplicableFiles(r, jar, native, native32, native64, QString());
|
||||||
QCOMPARE(jar, {});
|
QCOMPARE(jar, {});
|
||||||
QCOMPARE(native, {});
|
QCOMPARE(native, {});
|
||||||
QCOMPARE(native32, getStorage("test/package/testname/testversion/testname-testversion-windows-32.jar"));
|
QCOMPARE(native32, getStorage("test/package/testname/testversion/testname-testversion-windows-32.jar"));
|
||||||
QCOMPARE(native64, getStorage("test/package/testname/testversion/testname-testversion-windows-64.jar"));
|
QCOMPARE(native64, getStorage("test/package/testname/testversion/testname-testversion-windows-64.jar"));
|
||||||
QStringList failedFiles;
|
QStringList failedFiles;
|
||||||
auto dls = test.getDownloads(Os_Windows, cache.get(), failedFiles, QString());
|
auto dls = test.getDownloads(r, cache.get(), failedFiles, QString());
|
||||||
QCOMPARE(dls.size(), 2);
|
QCOMPARE(dls.size(), 2);
|
||||||
QCOMPARE(failedFiles, {});
|
QCOMPARE(failedFiles, {});
|
||||||
QCOMPARE(dls[0]->m_url, QUrl("file://foo/bar/test/package/testname/testversion/testname-testversion-windows-32.jar"));
|
QCOMPARE(dls[0]->m_url, QUrl("file://foo/bar/test/package/testname/testversion/testname-testversion-windows-32.jar"));
|
||||||
QCOMPARE(dls[1]->m_url, QUrl("file://foo/bar/test/package/testname/testversion/testname-testversion-windows-64.jar"));
|
QCOMPARE(dls[1]->m_url, QUrl("file://foo/bar/test/package/testname/testversion/testname-testversion-windows-64.jar"));
|
||||||
}
|
}
|
||||||
|
r.system = "osx";
|
||||||
{
|
{
|
||||||
QStringList jar, native, native32, native64;
|
QStringList jar, native, native32, native64;
|
||||||
test.getApplicableFiles(Os_OSX, jar, native, native32, native64, QString());
|
test.getApplicableFiles(r, jar, native, native32, native64, QString());
|
||||||
QCOMPARE(jar, {});
|
QCOMPARE(jar, {});
|
||||||
QCOMPARE(native, {});
|
QCOMPARE(native, {});
|
||||||
QCOMPARE(native32, getStorage("test/package/testname/testversion/testname-testversion-osx-32.jar"));
|
QCOMPARE(native32, getStorage("test/package/testname/testversion/testname-testversion-osx-32.jar"));
|
||||||
QCOMPARE(native64, getStorage("test/package/testname/testversion/testname-testversion-osx-64.jar"));
|
QCOMPARE(native64, getStorage("test/package/testname/testversion/testname-testversion-osx-64.jar"));
|
||||||
QStringList failedFiles;
|
QStringList failedFiles;
|
||||||
auto dls = test.getDownloads(Os_OSX, cache.get(), failedFiles, QString());
|
auto dls = test.getDownloads(r, cache.get(), failedFiles, QString());
|
||||||
QCOMPARE(dls.size(), 2);
|
QCOMPARE(dls.size(), 2);
|
||||||
QCOMPARE(failedFiles, {});
|
QCOMPARE(failedFiles, {});
|
||||||
QCOMPARE(dls[0]->m_url, QUrl("file://foo/bar/test/package/testname/testversion/testname-testversion-osx-32.jar"));
|
QCOMPARE(dls[0]->m_url, QUrl("file://foo/bar/test/package/testname/testversion/testname-testversion-osx-32.jar"));
|
||||||
@ -158,6 +175,7 @@ slots:
|
|||||||
}
|
}
|
||||||
void test_legacy_native_arch_local_override()
|
void test_legacy_native_arch_local_override()
|
||||||
{
|
{
|
||||||
|
RuntimeContext r = dummyContext();
|
||||||
Library test("test.package:testname:testversion");
|
Library test("test.package:testname:testversion");
|
||||||
test.m_nativeClassifiers["linux"]="linux-${arch}";
|
test.m_nativeClassifiers["linux"]="linux-${arch}";
|
||||||
test.setHint("local");
|
test.setHint("local");
|
||||||
@ -165,96 +183,104 @@ slots:
|
|||||||
test.setRepositoryURL("file://foo/bar");
|
test.setRepositoryURL("file://foo/bar");
|
||||||
{
|
{
|
||||||
QStringList jar, native, native32, native64;
|
QStringList jar, native, native32, native64;
|
||||||
test.getApplicableFiles(Os_Linux, jar, native, native32, native64, QFINDTESTDATA("testdata/Library"));
|
test.getApplicableFiles(r, jar, native, native32, native64, QFINDTESTDATA("testdata/Library"));
|
||||||
QCOMPARE(jar, {});
|
QCOMPARE(jar, {});
|
||||||
QCOMPARE(native, {});
|
QCOMPARE(native, {});
|
||||||
QCOMPARE(native32, {QFileInfo(QFINDTESTDATA("testdata/Library/testname-testversion-linux-32.jar")).absoluteFilePath()});
|
QCOMPARE(native32, {QFileInfo(QFINDTESTDATA("testdata/Library/testname-testversion-linux-32.jar")).absoluteFilePath()});
|
||||||
QCOMPARE(native64, {QFileInfo(QFINDTESTDATA("testdata/Library") + "/testname-testversion-linux-64.jar").absoluteFilePath()});
|
QCOMPARE(native64, {QFileInfo(QFINDTESTDATA("testdata/Library") + "/testname-testversion-linux-64.jar").absoluteFilePath()});
|
||||||
QStringList failedFiles;
|
QStringList failedFiles;
|
||||||
auto dls = test.getDownloads(Os_Linux, cache.get(), failedFiles, QFINDTESTDATA("testdata/Library"));
|
auto dls = test.getDownloads(r, cache.get(), failedFiles, QFINDTESTDATA("testdata/Library"));
|
||||||
QCOMPARE(dls.size(), 0);
|
QCOMPARE(dls.size(), 0);
|
||||||
QCOMPARE(failedFiles, {QFileInfo(QFINDTESTDATA("testdata/Library") + "/testname-testversion-linux-64.jar").absoluteFilePath()});
|
QCOMPARE(failedFiles, {QFileInfo(QFINDTESTDATA("testdata/Library") + "/testname-testversion-linux-64.jar").absoluteFilePath()});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void test_onenine()
|
void test_onenine()
|
||||||
{
|
{
|
||||||
|
RuntimeContext r = dummyContext("osx");
|
||||||
auto test = readMojangJson(QFINDTESTDATA("testdata/Library/lib-simple.json"));
|
auto test = readMojangJson(QFINDTESTDATA("testdata/Library/lib-simple.json"));
|
||||||
{
|
{
|
||||||
QStringList jar, native, native32, native64;
|
QStringList jar, native, native32, native64;
|
||||||
test->getApplicableFiles(Os_OSX, jar, native, native32, native64, QString());
|
test->getApplicableFiles(r, jar, native, native32, native64, QString());
|
||||||
QCOMPARE(jar, getStorage("com/paulscode/codecwav/20101023/codecwav-20101023.jar"));
|
QCOMPARE(jar, getStorage("com/paulscode/codecwav/20101023/codecwav-20101023.jar"));
|
||||||
QCOMPARE(native, {});
|
QCOMPARE(native, {});
|
||||||
QCOMPARE(native32, {});
|
QCOMPARE(native32, {});
|
||||||
QCOMPARE(native64, {});
|
QCOMPARE(native64, {});
|
||||||
}
|
}
|
||||||
|
r.system = "linux";
|
||||||
{
|
{
|
||||||
QStringList failedFiles;
|
QStringList failedFiles;
|
||||||
auto dls = test->getDownloads(Os_Linux, cache.get(), failedFiles, QString());
|
auto dls = test->getDownloads(r, cache.get(), failedFiles, QString());
|
||||||
QCOMPARE(dls.size(), 1);
|
QCOMPARE(dls.size(), 1);
|
||||||
QCOMPARE(failedFiles, {});
|
QCOMPARE(failedFiles, {});
|
||||||
QCOMPARE(dls[0]->m_url, QUrl("https://libraries.minecraft.net/com/paulscode/codecwav/20101023/codecwav-20101023.jar"));
|
QCOMPARE(dls[0]->m_url, QUrl("https://libraries.minecraft.net/com/paulscode/codecwav/20101023/codecwav-20101023.jar"));
|
||||||
}
|
}
|
||||||
|
r.system = "osx";
|
||||||
test->setHint("local");
|
test->setHint("local");
|
||||||
{
|
{
|
||||||
QStringList jar, native, native32, native64;
|
QStringList jar, native, native32, native64;
|
||||||
test->getApplicableFiles(Os_OSX, jar, native, native32, native64, QFINDTESTDATA("testdata/Library"));
|
test->getApplicableFiles(r, jar, native, native32, native64, QFINDTESTDATA("testdata/Library"));
|
||||||
QCOMPARE(jar, {QFileInfo(QFINDTESTDATA("testdata/Library/codecwav-20101023.jar")).absoluteFilePath()});
|
QCOMPARE(jar, {QFileInfo(QFINDTESTDATA("testdata/Library/codecwav-20101023.jar")).absoluteFilePath()});
|
||||||
QCOMPARE(native, {});
|
QCOMPARE(native, {});
|
||||||
QCOMPARE(native32, {});
|
QCOMPARE(native32, {});
|
||||||
QCOMPARE(native64, {});
|
QCOMPARE(native64, {});
|
||||||
}
|
}
|
||||||
|
r.system = "linux";
|
||||||
{
|
{
|
||||||
QStringList failedFiles;
|
QStringList failedFiles;
|
||||||
auto dls = test->getDownloads(Os_Linux, cache.get(), failedFiles, QFINDTESTDATA("testdata/Library"));
|
auto dls = test->getDownloads(r, cache.get(), failedFiles, QFINDTESTDATA("testdata/Library"));
|
||||||
QCOMPARE(dls.size(), 0);
|
QCOMPARE(dls.size(), 0);
|
||||||
QCOMPARE(failedFiles, {});
|
QCOMPARE(failedFiles, {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void test_onenine_local_override()
|
void test_onenine_local_override()
|
||||||
{
|
{
|
||||||
|
RuntimeContext r = dummyContext("osx");
|
||||||
auto test = readMojangJson(QFINDTESTDATA("testdata/Library/lib-simple.json"));
|
auto test = readMojangJson(QFINDTESTDATA("testdata/Library/lib-simple.json"));
|
||||||
test->setHint("local");
|
test->setHint("local");
|
||||||
{
|
{
|
||||||
QStringList jar, native, native32, native64;
|
QStringList jar, native, native32, native64;
|
||||||
test->getApplicableFiles(Os_OSX, jar, native, native32, native64, QFINDTESTDATA("testdata/Library"));
|
test->getApplicableFiles(r, jar, native, native32, native64, QFINDTESTDATA("testdata/Library"));
|
||||||
QCOMPARE(jar, {QFileInfo(QFINDTESTDATA("testdata/Library/codecwav-20101023.jar")).absoluteFilePath()});
|
QCOMPARE(jar, {QFileInfo(QFINDTESTDATA("testdata/Library/codecwav-20101023.jar")).absoluteFilePath()});
|
||||||
QCOMPARE(native, {});
|
QCOMPARE(native, {});
|
||||||
QCOMPARE(native32, {});
|
QCOMPARE(native32, {});
|
||||||
QCOMPARE(native64, {});
|
QCOMPARE(native64, {});
|
||||||
}
|
}
|
||||||
|
r.system = "linux";
|
||||||
{
|
{
|
||||||
QStringList failedFiles;
|
QStringList failedFiles;
|
||||||
auto dls = test->getDownloads(Os_Linux, cache.get(), failedFiles, QFINDTESTDATA("testdata/Library"));
|
auto dls = test->getDownloads(r, cache.get(), failedFiles, QFINDTESTDATA("testdata/Library"));
|
||||||
QCOMPARE(dls.size(), 0);
|
QCOMPARE(dls.size(), 0);
|
||||||
QCOMPARE(failedFiles, {});
|
QCOMPARE(failedFiles, {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void test_onenine_native()
|
void test_onenine_native()
|
||||||
{
|
{
|
||||||
|
RuntimeContext r = dummyContext("osx");
|
||||||
auto test = readMojangJson(QFINDTESTDATA("testdata/Library/lib-native.json"));
|
auto test = readMojangJson(QFINDTESTDATA("testdata/Library/lib-native.json"));
|
||||||
QStringList jar, native, native32, native64;
|
QStringList jar, native, native32, native64;
|
||||||
test->getApplicableFiles(Os_OSX, jar, native, native32, native64, QString());
|
test->getApplicableFiles(r, jar, native, native32, native64, QString());
|
||||||
QCOMPARE(jar, QStringList());
|
QCOMPARE(jar, QStringList());
|
||||||
QCOMPARE(native, getStorage("org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar"));
|
QCOMPARE(native, getStorage("org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar"));
|
||||||
QCOMPARE(native32, {});
|
QCOMPARE(native32, {});
|
||||||
QCOMPARE(native64, {});
|
QCOMPARE(native64, {});
|
||||||
QStringList failedFiles;
|
QStringList failedFiles;
|
||||||
auto dls = test->getDownloads(Os_OSX, cache.get(), failedFiles, QString());
|
auto dls = test->getDownloads(r, cache.get(), failedFiles, QString());
|
||||||
QCOMPARE(dls.size(), 1);
|
QCOMPARE(dls.size(), 1);
|
||||||
QCOMPARE(failedFiles, {});
|
QCOMPARE(failedFiles, {});
|
||||||
QCOMPARE(dls[0]->m_url, QUrl("https://libraries.minecraft.net/org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar"));
|
QCOMPARE(dls[0]->m_url, QUrl("https://libraries.minecraft.net/org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar"));
|
||||||
}
|
}
|
||||||
void test_onenine_native_arch()
|
void test_onenine_native_arch()
|
||||||
{
|
{
|
||||||
|
RuntimeContext r = dummyContext("windows");
|
||||||
auto test = readMojangJson(QFINDTESTDATA("testdata/Library/lib-native-arch.json"));
|
auto test = readMojangJson(QFINDTESTDATA("testdata/Library/lib-native-arch.json"));
|
||||||
QStringList jar, native, native32, native64;
|
QStringList jar, native, native32, native64;
|
||||||
test->getApplicableFiles(Os_Windows, jar, native, native32, native64, QString());
|
test->getApplicableFiles(r, jar, native, native32, native64, QString());
|
||||||
QCOMPARE(jar, {});
|
QCOMPARE(jar, {});
|
||||||
QCOMPARE(native, {});
|
QCOMPARE(native, {});
|
||||||
QCOMPARE(native32, getStorage("tv/twitch/twitch-platform/5.16/twitch-platform-5.16-natives-windows-32.jar"));
|
QCOMPARE(native32, getStorage("tv/twitch/twitch-platform/5.16/twitch-platform-5.16-natives-windows-32.jar"));
|
||||||
QCOMPARE(native64, getStorage("tv/twitch/twitch-platform/5.16/twitch-platform-5.16-natives-windows-64.jar"));
|
QCOMPARE(native64, getStorage("tv/twitch/twitch-platform/5.16/twitch-platform-5.16-natives-windows-64.jar"));
|
||||||
QStringList failedFiles;
|
QStringList failedFiles;
|
||||||
auto dls = test->getDownloads(Os_Windows, cache.get(), failedFiles, QString());
|
auto dls = test->getDownloads(r, cache.get(), failedFiles, QString());
|
||||||
QCOMPARE(dls.size(), 2);
|
QCOMPARE(dls.size(), 2);
|
||||||
QCOMPARE(failedFiles, {});
|
QCOMPARE(failedFiles, {});
|
||||||
QCOMPARE(dls[0]->m_url, QUrl("https://libraries.minecraft.net/tv/twitch/twitch-platform/5.16/twitch-platform-5.16-natives-windows-32.jar"));
|
QCOMPARE(dls[0]->m_url, QUrl("https://libraries.minecraft.net/tv/twitch/twitch-platform/5.16/twitch-platform-5.16-natives-windows-32.jar"));
|
||||||
|
Loading…
Reference in New Issue
Block a user