From 9ec1c00887579e97c7b7a190756f6ddae583563f Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Sat, 11 Jun 2022 10:48:56 +0200 Subject: [PATCH 1/6] fix: register JavaRealArchitecture for MinecraftInstance Signed-off-by: Sefa Eyeoglu --- launcher/minecraft/MinecraftInstance.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index 62540c757..8496adeea 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -147,6 +147,7 @@ void MinecraftInstance::loadSpecificSettings() m_settings->registerPassthrough(global_settings->getSetting("JavaTimestamp"), javaOrLocation); m_settings->registerPassthrough(global_settings->getSetting("JavaVersion"), javaOrLocation); m_settings->registerPassthrough(global_settings->getSetting("JavaArchitecture"), javaOrLocation); + m_settings->registerPassthrough(global_settings->getSetting("JavaRealArchitecture"), javaOrLocation); // Window Size auto windowSetting = m_settings->registerSetting("OverrideWindow", false); From 09e85e948cdb361c306a1cccbc3557a464366a21 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Mon, 11 Jul 2022 09:01:07 +0200 Subject: [PATCH 2/6] refactor: introduce RuntimeContext Signed-off-by: Sefa Eyeoglu --- launcher/BaseInstance.cpp | 5 ++ launcher/BaseInstance.h | 8 ++++ launcher/CMakeLists.txt | 3 +- launcher/NullInstance.h | 4 ++ launcher/RuntimeContext.h | 39 ++++++++++++++++ launcher/minecraft/Component.cpp | 2 +- launcher/minecraft/LaunchProfile.cpp | 24 +++++----- launcher/minecraft/LaunchProfile.h | 8 ++-- launcher/minecraft/Library.cpp | 32 ++++++------- launcher/minecraft/Library.h | 16 +++---- launcher/minecraft/MinecraftInstance.cpp | 29 +++++++----- launcher/minecraft/MinecraftInstance.h | 2 + launcher/minecraft/MojangVersionFormat.cpp | 9 ++-- launcher/minecraft/OpSys.cpp | 46 ------------------- launcher/minecraft/OpSys.h | 38 --------------- launcher/minecraft/PackProfile.cpp | 7 ++- launcher/minecraft/PackProfile.h | 3 ++ launcher/minecraft/Rule.cpp | 6 +-- launcher/minecraft/Rule.h | 10 ++-- launcher/minecraft/VersionFile.cpp | 8 ++-- launcher/minecraft/VersionFile.h | 3 +- launcher/minecraft/launch/ModMinecraftJar.cpp | 3 +- launcher/minecraft/launch/ScanModFolders.cpp | 1 - launcher/minecraft/update/LibrariesTask.cpp | 2 +- .../pages/instance/InstanceSettingsPage.cpp | 3 ++ tests/Library_test.cpp | 10 ++-- 26 files changed, 152 insertions(+), 169 deletions(-) create mode 100644 launcher/RuntimeContext.h delete mode 100644 launcher/minecraft/OpSys.cpp delete mode 100644 launcher/minecraft/OpSys.h diff --git a/launcher/BaseInstance.cpp b/launcher/BaseInstance.cpp index e6d4d8e38..944fd4b27 100644 --- a/launcher/BaseInstance.cpp +++ b/launcher/BaseInstance.cpp @@ -358,3 +358,8 @@ shared_qobject_ptr BaseInstance::getLaunchTask() { return m_launchProcess; } + +void BaseInstance::updateRuntimeContext() +{ + // NOOP +} diff --git a/launcher/BaseInstance.h b/launcher/BaseInstance.h index 3af104e9f..b86401d6c 100644 --- a/launcher/BaseInstance.h +++ b/launcher/BaseInstance.h @@ -54,6 +54,7 @@ #include "net/Mode.h" #include "minecraft/launch/MinecraftServerTarget.h" +#include "RuntimeContext.h" class QDir; class Task; @@ -219,6 +220,12 @@ public: virtual QString typeName() const = 0; + void updateRuntimeContext(); + RuntimeContext runtimeContext() const + { + return m_runtimeContext; + } + bool hasVersionBroken() const { return m_hasBrokenVersion; @@ -304,6 +311,7 @@ protected: /* data */ bool m_isRunning = false; shared_qobject_ptr m_launchProcess; QDateTime m_timeStarted; + RuntimeContext m_runtimeContext; private: /* data */ Status m_status = Status::Present; diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index e44b98ebb..f7bcb1d88 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -26,6 +26,7 @@ set(CORE_SOURCES MMCZip.cpp MMCStrings.h MMCStrings.cpp + RuntimeContext.h # Basic instance manipulation tasks (derived from InstanceTask) InstanceCreationTask.h @@ -288,8 +289,6 @@ set(MINECRAFT_SOURCES minecraft/Rule.h minecraft/OneSixVersionFormat.cpp minecraft/OneSixVersionFormat.h - minecraft/OpSys.cpp - minecraft/OpSys.h minecraft/ParseUtils.cpp minecraft/ParseUtils.h minecraft/ProfileUtils.cpp diff --git a/launcher/NullInstance.h b/launcher/NullInstance.h index 53e64a057..628aff5ff 100644 --- a/launcher/NullInstance.h +++ b/launcher/NullInstance.h @@ -84,4 +84,8 @@ public: QString modsRoot() const override { return QString(); } + void updateRuntimeContext() + { + // NOOP + } }; diff --git a/launcher/RuntimeContext.h b/launcher/RuntimeContext.h new file mode 100644 index 000000000..767857285 --- /dev/null +++ b/launcher/RuntimeContext.h @@ -0,0 +1,39 @@ +#pragma once + +#include +#include "settings/SettingsObject.h" + +struct RuntimeContext { + QString javaArchitecture; + QString javaRealArchitecture; + QString javaPath; + + QString mappedJavaRealArchitecture() const { + if (javaRealArchitecture == "aarch64") { + return "arm64"; + } + return javaRealArchitecture; + } + + void updateFromInstanceSettings(SettingsObjectPtr instanceSettings) { + javaArchitecture = instanceSettings->get("JavaArchitecture").toString(); + javaRealArchitecture = instanceSettings->get("JavaRealArchitecture").toString(); + javaPath = instanceSettings->get("JavaPath").toString(); + } + + static QString currentSystem() { +#if defined(Q_OS_LINUX) + return "linux"; +#elif defined(Q_OS_MACOS) + return "osx"; +#elif defined(Q_OS_WINDOWS) + return "windows"; +#elif defined(Q_OS_FREEBSD) + return "freebsd"; +#elif defined(Q_OS_OPENBSD) + return "openbsd"; +#else + return "unknown"; +#endif + } +}; diff --git a/launcher/minecraft/Component.cpp b/launcher/minecraft/Component.cpp index c7dd5e36d..ebe4eac7e 100644 --- a/launcher/minecraft/Component.cpp +++ b/launcher/minecraft/Component.cpp @@ -60,7 +60,7 @@ void Component::applyTo(LaunchProfile* profile) auto vfile = getVersionFile(); if(vfile) { - vfile->applyTo(profile); + vfile->applyTo(profile, m_parent->runtimeContext()); } else { diff --git a/launcher/minecraft/LaunchProfile.cpp b/launcher/minecraft/LaunchProfile.cpp index 39a342ca9..9a6cea11a 100644 --- a/launcher/minecraft/LaunchProfile.cpp +++ b/launcher/minecraft/LaunchProfile.cpp @@ -173,9 +173,9 @@ void LaunchProfile::applyCompatibleJavaMajors(QList& javaMajor) m_compatibleJavaMajors.append(javaMajor); } -void LaunchProfile::applyLibrary(LibraryPtr library) +void LaunchProfile::applyLibrary(LibraryPtr library, const RuntimeContext & runtimeContext) { - if(!library->isActive()) + if(!library->isActive(runtimeContext)) { return; } @@ -205,9 +205,9 @@ void LaunchProfile::applyLibrary(LibraryPtr library) } } -void LaunchProfile::applyMavenFile(LibraryPtr mavenFile) +void LaunchProfile::applyMavenFile(LibraryPtr mavenFile, const RuntimeContext & runtimeContext) { - if(!mavenFile->isActive()) + if(!mavenFile->isActive(runtimeContext)) { return; } @@ -221,10 +221,10 @@ void LaunchProfile::applyMavenFile(LibraryPtr mavenFile) m_mavenFiles.append(Library::limitedCopy(mavenFile)); } -void LaunchProfile::applyAgent(AgentPtr agent) +void LaunchProfile::applyAgent(AgentPtr agent, const RuntimeContext & runtimeContext) { auto lib = agent->library(); - if(!lib->isActive()) + if(!lib->isActive(runtimeContext)) { return; } @@ -354,7 +354,7 @@ const QList & LaunchProfile::getCompatibleJavaMajors() const } void LaunchProfile::getLibraryFiles( - const QString& architecture, + const RuntimeContext & runtimeContext, QStringList& jars, QStringList& nativeJars, const QString& overridePath, @@ -366,7 +366,7 @@ void LaunchProfile::getLibraryFiles( nativeJars.clear(); for (auto lib : getLibraries()) { - lib->getApplicableFiles(currentSystem, jars, nativeJars, native32, native64, overridePath); + lib->getApplicableFiles(runtimeContext, jars, nativeJars, native32, native64, overridePath); } // NOTE: order is important here, add main jar last to the lists if(m_mainJar) @@ -379,18 +379,18 @@ void LaunchProfile::getLibraryFiles( } else { - m_mainJar->getApplicableFiles(currentSystem, jars, nativeJars, native32, native64, overridePath); + m_mainJar->getApplicableFiles(runtimeContext, jars, nativeJars, native32, native64, overridePath); } } for (auto lib : getNativeLibraries()) { - lib->getApplicableFiles(currentSystem, jars, nativeJars, native32, native64, overridePath); + lib->getApplicableFiles(runtimeContext, jars, nativeJars, native32, native64, overridePath); } - if(architecture == "32") + if(runtimeContext.javaArchitecture == "32") { nativeJars.append(native32); } - else if(architecture == "64") + else if(runtimeContext.javaArchitecture == "64") { nativeJars.append(native64); } diff --git a/launcher/minecraft/LaunchProfile.h b/launcher/minecraft/LaunchProfile.h index b55cf6615..49c1217d3 100644 --- a/launcher/minecraft/LaunchProfile.h +++ b/launcher/minecraft/LaunchProfile.h @@ -56,9 +56,9 @@ public: /* application of profile variables from patches */ void applyTweakers(const QStringList &tweakers); void applyJarMods(const QList &jarMods); void applyMods(const QList &jarMods); - void applyLibrary(LibraryPtr library); - void applyMavenFile(LibraryPtr library); - void applyAgent(AgentPtr agent); + void applyLibrary(LibraryPtr library, const RuntimeContext & runtimeContext); + void applyMavenFile(LibraryPtr library, const RuntimeContext & runtimeContext); + void applyAgent(AgentPtr agent, const RuntimeContext & runtimeContext); void applyCompatibleJavaMajors(QList& javaMajor); void applyMainJar(LibraryPtr jar); void applyProblemSeverity(ProblemSeverity severity); @@ -83,7 +83,7 @@ public: /* getters for profile variables */ const QList & getCompatibleJavaMajors() const; const LibraryPtr getMainJar() const; void getLibraryFiles( - const QString & architecture, + const RuntimeContext & runtimeContext, QStringList & jars, QStringList & nativeJars, const QString & overridePath, diff --git a/launcher/minecraft/Library.cpp b/launcher/minecraft/Library.cpp index ba7aed4b5..1689e27c8 100644 --- a/launcher/minecraft/Library.cpp +++ b/launcher/minecraft/Library.cpp @@ -7,7 +7,7 @@ #include -void Library::getApplicableFiles(OpSys system, QStringList& jar, QStringList& native, QStringList& native32, +void Library::getApplicableFiles(const RuntimeContext & runtimeContext, QStringList& jar, QStringList& native, QStringList& native32, QStringList& native64, const QString &overridePath) const { bool local = isLocal(); @@ -21,7 +21,7 @@ void Library::getApplicableFiles(OpSys system, QStringList& jar, QStringList& na } return out.absoluteFilePath(); }; - QString raw_storage = storageSuffix(system); + QString raw_storage = storageSuffix(runtimeContext); if(isNative()) { if (raw_storage.contains("${arch}")) @@ -45,7 +45,7 @@ void Library::getApplicableFiles(OpSys system, QStringList& jar, QStringList& na } QList Library::getDownloads( - OpSys system, + const RuntimeContext & runtimeContext, class HttpMetaCache* cache, QStringList& failedLocalFiles, const QString & overridePath @@ -107,14 +107,14 @@ QList Library::getDownloads( return true; }; - QString raw_storage = storageSuffix(system); + QString raw_storage = storageSuffix(runtimeContext); if(m_mojangDownloads) { if(isNative()) { - if(m_nativeClassifiers.contains(system)) + if(m_nativeClassifiers.contains(runtimeContext.currentSystem())) { - auto nativeClassifier = m_nativeClassifiers[system]; + auto nativeClassifier = m_nativeClassifiers[runtimeContext.currentSystem()]; if(nativeClassifier.contains("${arch}")) { auto nat32Classifier = nativeClassifier; @@ -203,7 +203,7 @@ QList Library::getDownloads( return out; } -bool Library::isActive() const +bool Library::isActive(const RuntimeContext & runtimeContext) const { bool result = true; if (m_rules.empty()) @@ -223,7 +223,7 @@ bool Library::isActive() const } if (isNative()) { - result = result && m_nativeClassifiers.contains(currentSystem); + result = result && m_nativeClassifiers.contains(runtimeContext.currentSystem()); } return result; } @@ -257,7 +257,7 @@ QString Library::storagePrefix() const return m_storagePrefix; } -QString Library::filename(OpSys system) const +QString Library::filename(const RuntimeContext & runtimeContext) const { if(!m_filename.isEmpty()) { @@ -271,9 +271,9 @@ QString Library::filename(OpSys system) const // otherwise native, override classifiers. Mojang HACK! GradleSpecifier nativeSpec = m_name; - if (m_nativeClassifiers.contains(system)) + if (m_nativeClassifiers.contains(runtimeContext.currentSystem())) { - nativeSpec.setClassifier(m_nativeClassifiers[system]); + nativeSpec.setClassifier(m_nativeClassifiers[runtimeContext.currentSystem()]); } else { @@ -282,14 +282,14 @@ QString Library::filename(OpSys system) const return nativeSpec.getFileName(); } -QString Library::displayName(OpSys system) const +QString Library::displayName(const RuntimeContext & runtimeContext) const { if(!m_displayname.isEmpty()) return m_displayname; - return filename(system); + return filename(runtimeContext); } -QString Library::storageSuffix(OpSys system) const +QString Library::storageSuffix(const RuntimeContext & runtimeContext) const { // non-native? use only the gradle specifier if (!isNative()) @@ -299,9 +299,9 @@ QString Library::storageSuffix(OpSys system) const // otherwise native, override classifiers. Mojang HACK! GradleSpecifier nativeSpec = m_name; - if (m_nativeClassifiers.contains(system)) + if (m_nativeClassifiers.contains(runtimeContext.currentSystem())) { - nativeSpec.setClassifier(m_nativeClassifiers[system]); + nativeSpec.setClassifier(m_nativeClassifiers[runtimeContext.currentSystem()]); } else { diff --git a/launcher/minecraft/Library.h b/launcher/minecraft/Library.h index 0740a7ca2..e0432fb85 100644 --- a/launcher/minecraft/Library.h +++ b/launcher/minecraft/Library.h @@ -10,9 +10,9 @@ #include #include "Rule.h" -#include "minecraft/OpSys.h" #include "GradleSpecifier.h" #include "MojangDownloadInfo.h" +#include "RuntimeContext.h" class Library; class MinecraftInstance; @@ -98,7 +98,7 @@ public: /* methods */ m_repositoryURL = base_url; } - void getApplicableFiles(OpSys system, QStringList & jar, QStringList & native, + void getApplicableFiles(const RuntimeContext & runtimeContext, QStringList & jar, QStringList & native, QStringList & native32, QStringList & native64, const QString & overridePath) const; void setAbsoluteUrl(const QString &absolute_url) @@ -112,7 +112,7 @@ public: /* methods */ } /// Get the file name of the library - QString filename(OpSys system) const; + QString filename(const RuntimeContext & runtimeContext) const; // DEPRECATED: set a display name, used by jar mods only void setDisplayName(const QString & displayName) @@ -121,7 +121,7 @@ public: /* methods */ } /// Get the file name of the library - QString displayName(OpSys system) const; + QString displayName(const RuntimeContext & runtimeContext) const; void setMojangDownloadInfo(MojangLibraryDownloadInfo::Ptr info) { @@ -140,7 +140,7 @@ public: /* methods */ } /// Returns true if the library should be loaded (or extracted, in case of natives) - bool isActive() const; + bool isActive(const RuntimeContext & runtimeContext) const; /// Returns true if the library is contained in an instance and false if it is shared bool isLocal() const; @@ -152,7 +152,7 @@ public: /* methods */ bool isForge() const; // Get a list of downloads for this library - QList getDownloads(OpSys system, class HttpMetaCache * cache, + QList getDownloads(const RuntimeContext & runtimeContext, class HttpMetaCache * cache, QStringList & failedLocalFiles, const QString & overridePath) const; private: /* methods */ @@ -163,7 +163,7 @@ private: /* methods */ QString storagePrefix() const; /// Get the relative file path where the library should be saved - QString storageSuffix(OpSys system) const; + QString storageSuffix(const RuntimeContext & runtimeContext) const; QString hint() const { @@ -204,7 +204,7 @@ protected: /* data */ QStringList m_extractExcludes; /// native suffixes per OS - QMap m_nativeClassifiers; + QMap m_nativeClassifiers; /// true if the library had a rules section (even empty) bool applyRules = false; diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index 8496adeea..3a820951b 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -191,6 +191,13 @@ void MinecraftInstance::loadSpecificSettings() qDebug() << "Instance-type specific settings were loaded!"; setSpecificSettingsLoaded(true); + + updateRuntimeContext(); +} + +void MinecraftInstance::updateRuntimeContext() +{ + m_runtimeContext.updateFromInstanceSettings(m_settings); } QString MinecraftInstance::typeName() const @@ -328,9 +335,8 @@ QDir MinecraftInstance::versionsPath() const QStringList MinecraftInstance::getClassPath() { QStringList jars, nativeJars; - auto javaArchitecture = settings()->get("JavaArchitecture").toString(); auto profile = m_components->getProfile(); - profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath(), binRoot()); + profile->getLibraryFiles(runtimeContext(), jars, nativeJars, getLocalLibraryPath(), binRoot()); return jars; } @@ -343,9 +349,8 @@ QString MinecraftInstance::getMainClass() const QStringList MinecraftInstance::getNativeJars() { QStringList jars, nativeJars; - auto javaArchitecture = settings()->get("JavaArchitecture").toString(); auto profile = m_components->getProfile(); - profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath(), binRoot()); + profile->getLibraryFiles(runtimeContext(), jars, nativeJars, getLocalLibraryPath(), binRoot()); return nativeJars; } @@ -369,7 +374,7 @@ QStringList MinecraftInstance::extraArguments() for (auto agent : agents) { QStringList jar, temp1, temp2, temp3; - agent->library()->getApplicableFiles(currentSystem, jar, temp1, temp2, temp3, getLocalLibraryPath()); + agent->library()->getApplicableFiles(runtimeContext(), jar, temp1, temp2, temp3, getLocalLibraryPath()); list.append("-javaagent:"+jar[0]+(agent->argument().isEmpty() ? "" : "="+agent->argument())); } return list; @@ -626,8 +631,7 @@ QString MinecraftInstance::createLaunchScript(AuthSessionPtr session, MinecraftS // libraries and class path. { QStringList jars, nativeJars; - auto javaArchitecture = settings()->get("JavaArchitecture").toString(); - profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath(), binRoot()); + profile->getLibraryFiles(runtimeContext(), jars, nativeJars, getLocalLibraryPath(), binRoot()); for(auto file: jars) { launchScript += "cp " + file + "\n"; @@ -683,8 +687,7 @@ QStringList MinecraftInstance::verboseDescription(AuthSessionPtr session, Minecr { out << "Libraries:"; QStringList jars, nativeJars; - auto javaArchitecture = settings->get("JavaArchitecture").toString(); - profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath(), binRoot()); + profile->getLibraryFiles(runtimeContext(), jars, nativeJars, getLocalLibraryPath(), binRoot()); auto printLibFile = [&](const QString & path) { QFileInfo info(path); @@ -749,8 +752,8 @@ QStringList MinecraftInstance::verboseDescription(AuthSessionPtr session, Minecr out << "Jar Mods:"; for(auto & jarmod: jarMods) { - auto displayname = jarmod->displayName(currentSystem); - auto realname = jarmod->filename(currentSystem); + auto displayname = jarmod->displayName(runtimeContext()); + auto realname = jarmod->filename(runtimeContext()); if(displayname != realname) { out << " " + displayname + " (" + realname + ")"; @@ -912,6 +915,7 @@ QString MinecraftInstance::getStatusbarDescription() Task::Ptr MinecraftInstance::createUpdateTask(Net::Mode mode) { + updateRuntimeContext(); switch (mode) { case Net::Mode::Offline: @@ -928,6 +932,7 @@ Task::Ptr MinecraftInstance::createUpdateTask(Net::Mode mode) shared_qobject_ptr MinecraftInstance::createLaunchTask(AuthSessionPtr session, MinecraftServerTargetPtr serverToJoin) { + updateRuntimeContext(); // FIXME: get rid of shared_from_this ... auto process = LaunchTask::create(std::dynamic_pointer_cast(shared_from_this())); auto pptr = process.get(); @@ -1158,7 +1163,7 @@ QList MinecraftInstance::getJarMods() const for (auto jarmod : profile->getJarMods()) { QStringList jar, temp1, temp2, temp3; - jarmod->getApplicableFiles(currentSystem, jar, temp1, temp2, temp3, jarmodsPath().absolutePath()); + jarmod->getApplicableFiles(runtimeContext(), jar, temp1, temp2, temp3, jarmodsPath().absolutePath()); // QString filePath = jarmodsPath().absoluteFilePath(jarmod->filename(currentSystem)); mods.push_back(new Mod(QFileInfo(jar[0]))); } diff --git a/launcher/minecraft/MinecraftInstance.h b/launcher/minecraft/MinecraftInstance.h index fe39674a6..ef48b286d 100644 --- a/launcher/minecraft/MinecraftInstance.h +++ b/launcher/minecraft/MinecraftInstance.h @@ -72,6 +72,8 @@ public: /** Returns whether the instance, with its version, has support for demo mode. */ [[nodiscard]] bool supportsDemo() const; + void updateRuntimeContext(); + ////// Profile management ////// std::shared_ptr getPackProfile() const; diff --git a/launcher/minecraft/MojangVersionFormat.cpp b/launcher/minecraft/MojangVersionFormat.cpp index 94c586762..e00d2c6ea 100644 --- a/launcher/minecraft/MojangVersionFormat.cpp +++ b/launcher/minecraft/MojangVersionFormat.cpp @@ -362,11 +362,8 @@ LibraryPtr MojangVersionFormat::libraryFromJson(ProblemContainer & problems, con { qWarning() << filename << "contains an invalid native (skipping)"; } - OpSys opSys = OpSys_fromString(it.key()); - if (opSys != Os_Other) - { - out->m_nativeClassifiers[opSys] = it.value().toString(); - } + // FIXME: Skip unknown platforms + out->m_nativeClassifiers[it.key()] = it.value().toString(); } } if (libObj.contains("rules")) @@ -395,7 +392,7 @@ QJsonObject MojangVersionFormat::libraryToJson(Library *library) auto iter = library->m_nativeClassifiers.begin(); while (iter != library->m_nativeClassifiers.end()) { - nativeList.insert(OpSys_toString(iter.key()), iter.value()); + nativeList.insert(iter.key(), iter.value()); iter++; } libRoot.insert("natives", nativeList); diff --git a/launcher/minecraft/OpSys.cpp b/launcher/minecraft/OpSys.cpp deleted file mode 100644 index 093ec4190..000000000 --- a/launcher/minecraft/OpSys.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2013-2021 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "OpSys.h" - -OpSys OpSys_fromString(QString name) -{ - if (name == "freebsd") - return Os_FreeBSD; - if (name == "linux") - return Os_Linux; - if (name == "windows") - return Os_Windows; - if (name == "osx") - return Os_OSX; - return Os_Other; -} - -QString OpSys_toString(OpSys name) -{ - switch (name) - { - case Os_FreeBSD: - return "freebsd"; - case Os_Linux: - return "linux"; - case Os_OSX: - return "osx"; - case Os_Windows: - return "windows"; - default: - return "other"; - } -} \ No newline at end of file diff --git a/launcher/minecraft/OpSys.h b/launcher/minecraft/OpSys.h deleted file mode 100644 index 0936f8174..000000000 --- a/launcher/minecraft/OpSys.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright 2013-2021 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once -#include -enum OpSys -{ - Os_Windows, - Os_FreeBSD, - Os_Linux, - Os_OSX, - Os_Other -}; - -OpSys OpSys_fromString(QString); -QString OpSys_toString(OpSys); - -#ifdef Q_OS_WIN32 - #define currentSystem Os_Windows -#elif defined Q_OS_MAC - #define currentSystem Os_OSX -#elif defined Q_OS_FREEBSD - #define currentSystem Os_FreeBSD -#else - #define currentSystem Os_Linux -#endif diff --git a/launcher/minecraft/PackProfile.cpp b/launcher/minecraft/PackProfile.cpp index 5e76b892a..1618458f5 100644 --- a/launcher/minecraft/PackProfile.cpp +++ b/launcher/minecraft/PackProfile.cpp @@ -273,6 +273,11 @@ void PackProfile::scheduleSave() d->m_saveTimer.start(); } +RuntimeContext PackProfile::runtimeContext() +{ + return d->m_instance->runtimeContext(); +} + QString PackProfile::componentsFilePath() const { return FS::PathCombine(d->m_instance->instanceRoot(), "mmc-pack.json"); @@ -784,7 +789,7 @@ bool PackProfile::removeComponent_internal(ComponentPtr patch) return true; } QStringList jar, temp1, temp2, temp3; - jarMod->getApplicableFiles(currentSystem, jar, temp1, temp2, temp3, d->m_instance->jarmodsPath().absolutePath()); + jarMod->getApplicableFiles(d->m_instance->runtimeContext(), jar, temp1, temp2, temp3, d->m_instance->jarmodsPath().absolutePath()); QFileInfo finfo (jar[0]); if(finfo.exists()) { diff --git a/launcher/minecraft/PackProfile.h b/launcher/minecraft/PackProfile.h index 918e7f7ad..11057a0c7 100644 --- a/launcher/minecraft/PackProfile.h +++ b/launcher/minecraft/PackProfile.h @@ -104,6 +104,9 @@ public: /// if there is a save scheduled, do it now. void saveNow(); + /// helper method, returns RuntimeContext of instance + RuntimeContext runtimeContext(); + signals: void minecraftChanged(); diff --git a/launcher/minecraft/Rule.cpp b/launcher/minecraft/Rule.cpp index af2861e37..2f41e1fb1 100644 --- a/launcher/minecraft/Rule.cpp +++ b/launcher/minecraft/Rule.cpp @@ -60,10 +60,10 @@ QList> rulesFromJsonV4(const QJsonObject &objectWithRules) auto osNameVal = osObj.value("name"); if (!osNameVal.isString()) continue; - OpSys requiredOs = OpSys_fromString(osNameVal.toString()); + QString osName = osNameVal.toString(); QString versionRegex = osObj.value("version").toString(); // add a new OS rule - rules.append(OsRule::create(action, requiredOs, versionRegex)); + rules.append(OsRule::create(action, osName, versionRegex)); } return rules; } @@ -81,7 +81,7 @@ QJsonObject OsRule::toJson() ruleObj.insert("action", m_result == Allow ? QString("allow") : QString("disallow")); QJsonObject osObj; { - osObj.insert("name", OpSys_toString(m_system)); + osObj.insert("name", m_system); if(!m_version_regexp.isEmpty()) { osObj.insert("version", m_version_regexp); diff --git a/launcher/minecraft/Rule.h b/launcher/minecraft/Rule.h index 7aa34d967..2ed49d78c 100644 --- a/launcher/minecraft/Rule.h +++ b/launcher/minecraft/Rule.h @@ -19,7 +19,7 @@ #include #include #include -#include "OpSys.h" +#include "RuntimeContext.h" class Library; class Rule; @@ -58,23 +58,23 @@ class OsRule : public Rule { private: // the OS - OpSys m_system; + QString m_system; // the OS version regexp QString m_version_regexp; protected: virtual bool applies(const Library *) { - return (m_system == currentSystem); + return (m_system == RuntimeContext::currentSystem()); } - OsRule(RuleAction result, OpSys system, QString version_regexp) + OsRule(RuleAction result, QString system, QString version_regexp) : Rule(result), m_system(system), m_version_regexp(version_regexp) { } public: virtual QJsonObject toJson(); - static std::shared_ptr create(RuleAction result, OpSys system, + static std::shared_ptr create(RuleAction result, QString system, QString version_regexp) { return std::shared_ptr(new OsRule(result, system, version_regexp)); diff --git a/launcher/minecraft/VersionFile.cpp b/launcher/minecraft/VersionFile.cpp index a9a0f7f4b..76f41600f 100644 --- a/launcher/minecraft/VersionFile.cpp +++ b/launcher/minecraft/VersionFile.cpp @@ -51,7 +51,7 @@ static bool isMinecraftVersion(const QString &uid) return uid == "net.minecraft"; } -void VersionFile::applyTo(LaunchProfile *profile) +void VersionFile::applyTo(LaunchProfile *profile, const RuntimeContext & runtimeContext) { // Only real Minecraft can set those. Don't let anything override them. if (isMinecraftVersion(uid)) @@ -77,15 +77,15 @@ void VersionFile::applyTo(LaunchProfile *profile) for (auto library : libraries) { - profile->applyLibrary(library); + profile->applyLibrary(library, runtimeContext); } for (auto mavenFile : mavenFiles) { - profile->applyMavenFile(mavenFile); + profile->applyMavenFile(mavenFile, runtimeContext); } for (auto agent : agents) { - profile->applyAgent(agent); + profile->applyAgent(agent, runtimeContext); } profile->applyProblemSeverity(getProblemSeverity()); } diff --git a/launcher/minecraft/VersionFile.h b/launcher/minecraft/VersionFile.h index d4b29719a..e1b62f6a4 100644 --- a/launcher/minecraft/VersionFile.h +++ b/launcher/minecraft/VersionFile.h @@ -41,7 +41,6 @@ #include #include -#include "minecraft/OpSys.h" #include "minecraft/Rule.h" #include "ProblemProvider.h" #include "Library.h" @@ -60,7 +59,7 @@ class VersionFile : public ProblemContainer friend class MojangVersionFormat; friend class OneSixVersionFormat; public: /* methods */ - void applyTo(LaunchProfile* profile); + void applyTo(LaunchProfile* profile, const RuntimeContext & runtimeContext); public: /* data */ /// PolyMC: order hint for this version file if no explicit order is set diff --git a/launcher/minecraft/launch/ModMinecraftJar.cpp b/launcher/minecraft/launch/ModMinecraftJar.cpp index 93de9d59a..8e47e0e55 100644 --- a/launcher/minecraft/launch/ModMinecraftJar.cpp +++ b/launcher/minecraft/launch/ModMinecraftJar.cpp @@ -16,7 +16,6 @@ #include "ModMinecraftJar.h" #include "launch/LaunchTask.h" #include "MMCZip.h" -#include "minecraft/OpSys.h" #include "FileSystem.h" #include "minecraft/MinecraftInstance.h" #include "minecraft/PackProfile.h" @@ -50,7 +49,7 @@ void ModMinecraftJar::executeTask() { auto mainJar = profile->getMainJar(); QStringList jars, temp1, temp2, temp3, temp4; - mainJar->getApplicableFiles(currentSystem, jars, temp1, temp2, temp3, m_inst->getLocalLibraryPath()); + mainJar->getApplicableFiles(m_inst->runtimeContext(), jars, temp1, temp2, temp3, m_inst->getLocalLibraryPath()); auto sourceJarPath = jars[0]; if(!MMCZip::createModdedJar(sourceJarPath, finalJarPath, jarMods)) { diff --git a/launcher/minecraft/launch/ScanModFolders.cpp b/launcher/minecraft/launch/ScanModFolders.cpp index 2a0e21b39..2e817e0ad 100644 --- a/launcher/minecraft/launch/ScanModFolders.cpp +++ b/launcher/minecraft/launch/ScanModFolders.cpp @@ -16,7 +16,6 @@ #include "ScanModFolders.h" #include "launch/LaunchTask.h" #include "MMCZip.h" -#include "minecraft/OpSys.h" #include "FileSystem.h" #include "minecraft/MinecraftInstance.h" #include "minecraft/mod/ModFolderModel.h" diff --git a/launcher/minecraft/update/LibrariesTask.cpp b/launcher/minecraft/update/LibrariesTask.cpp index aa2bf4074..3b129fe11 100644 --- a/launcher/minecraft/update/LibrariesTask.cpp +++ b/launcher/minecraft/update/LibrariesTask.cpp @@ -34,7 +34,7 @@ void LibrariesTask::executeTask() emitFailed(tr("Null jar is specified in the metadata, aborting.")); return false; } - auto dls = lib->getDownloads(currentSystem, metacache.get(), errors, localPath); + auto dls = lib->getDownloads(inst->runtimeContext(), metacache.get(), errors, localPath); for(auto dl : dls) { downloadJob->addNetAction(dl); diff --git a/launcher/ui/pages/instance/InstanceSettingsPage.cpp b/launcher/ui/pages/instance/InstanceSettingsPage.cpp index 03910745f..5da7f19f5 100644 --- a/launcher/ui/pages/instance/InstanceSettingsPage.cpp +++ b/launcher/ui/pages/instance/InstanceSettingsPage.cpp @@ -274,6 +274,9 @@ void InstanceSettingsPage::applySettings() { m_settings->reset("JoinServerOnLaunchAddress"); } + + // FIXME: This should probably be called by a signal instead + m_instance->updateRuntimeContext(); } void InstanceSettingsPage::loadSettings() diff --git a/tests/Library_test.cpp b/tests/Library_test.cpp index 869c76735..a4ca92325 100644 --- a/tests/Library_test.cpp +++ b/tests/Library_test.cpp @@ -87,7 +87,7 @@ slots: void test_legacy_native() { Library test("test.package:testname:testversion"); - test.m_nativeClassifiers[OpSys::Os_Linux]="linux"; + test.m_nativeClassifiers["linux"] = "linux"; QCOMPARE(test.isNative(), true); test.setRepositoryURL("file://foo/bar"); { @@ -108,9 +108,9 @@ slots: void test_legacy_native_arch() { Library test("test.package:testname:testversion"); - test.m_nativeClassifiers[OpSys::Os_Linux]="linux-${arch}"; - test.m_nativeClassifiers[OpSys::Os_OSX]="osx-${arch}"; - test.m_nativeClassifiers[OpSys::Os_Windows]="windows-${arch}"; + test.m_nativeClassifiers["linux"]="linux-${arch}"; + test.m_nativeClassifiers["osx"]="osx-${arch}"; + test.m_nativeClassifiers["windows"]="windows-${arch}"; QCOMPARE(test.isNative(), true); test.setRepositoryURL("file://foo/bar"); { @@ -159,7 +159,7 @@ slots: void test_legacy_native_arch_local_override() { Library test("test.package:testname:testversion"); - test.m_nativeClassifiers[OpSys::Os_Linux]="linux-${arch}"; + test.m_nativeClassifiers["linux"]="linux-${arch}"; test.setHint("local"); QCOMPARE(test.isNative(), true); test.setRepositoryURL("file://foo/bar"); From 7bd8bd13feddded96b087bb142101f87cb0003b8 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Sun, 7 Aug 2022 00:06:32 +0200 Subject: [PATCH 3/6] feat: support multiarch system classifiers Signed-off-by: Sefa Eyeoglu --- launcher/RuntimeContext.h | 23 ++++++++++ launcher/minecraft/Library.cpp | 31 ++++++++++---- launcher/minecraft/Library.h | 3 ++ launcher/minecraft/Rule.h | 12 +++--- tests/Library_test.cpp | 76 +++++++++++++++++++++++----------- 5 files changed, 106 insertions(+), 39 deletions(-) diff --git a/launcher/RuntimeContext.h b/launcher/RuntimeContext.h index 767857285..d98d407f6 100644 --- a/launcher/RuntimeContext.h +++ b/launcher/RuntimeContext.h @@ -1,5 +1,6 @@ #pragma once +#include #include #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 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() { diff --git a/launcher/minecraft/Library.cpp b/launcher/minecraft/Library.cpp index 1689e27c8..42a42d87b 100644 --- a/launcher/minecraft/Library.cpp +++ b/launcher/minecraft/Library.cpp @@ -112,9 +112,9 @@ QList Library::getDownloads( { 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}")) { auto nat32Classifier = nativeClassifier; @@ -215,7 +215,7 @@ bool Library::isActive(const RuntimeContext & runtimeContext) const RuleAction ruleResult = Disallow; for (auto rule : m_rules) { - RuleAction temp = rule->apply(this); + RuleAction temp = rule->apply(this, runtimeContext); if (temp != Defer) ruleResult = temp; } @@ -223,7 +223,7 @@ bool Library::isActive(const RuntimeContext & runtimeContext) const } if (isNative()) { - result = result && m_nativeClassifiers.contains(runtimeContext.currentSystem()); + result = result && !getCompatibleNative(runtimeContext).isNull(); } return result; } @@ -238,6 +238,19 @@ bool Library::isAlwaysStale() const 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) { m_storagePrefix = prefix; @@ -271,9 +284,10 @@ QString Library::filename(const RuntimeContext & runtimeContext) const // otherwise native, override classifiers. Mojang HACK! 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 { @@ -299,9 +313,10 @@ QString Library::storageSuffix(const RuntimeContext & runtimeContext) const // otherwise native, override classifiers. Mojang HACK! 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 { diff --git a/launcher/minecraft/Library.h b/launcher/minecraft/Library.h index e0432fb85..b8fae9eca 100644 --- a/launcher/minecraft/Library.h +++ b/launcher/minecraft/Library.h @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -155,6 +156,8 @@ public: /* methods */ QList getDownloads(const RuntimeContext & runtimeContext, class HttpMetaCache * cache, QStringList & failedLocalFiles, const QString & overridePath) const; + QString getCompatibleNative(const RuntimeContext & runtimeContext) const; + private: /* methods */ /// the default storage prefix used by PolyMC static QString defaultStoragePrefix(); diff --git a/launcher/minecraft/Rule.h b/launcher/minecraft/Rule.h index 2ed49d78c..4c75cee42 100644 --- a/launcher/minecraft/Rule.h +++ b/launcher/minecraft/Rule.h @@ -37,7 +37,7 @@ class Rule { protected: RuleAction m_result; - virtual bool applies(const Library *parent) = 0; + virtual bool applies(const Library *parent, const RuntimeContext & runtimeContext) = 0; public: Rule(RuleAction result) : m_result(result) @@ -45,9 +45,9 @@ public: } virtual ~Rule() {}; 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; else return Defer; @@ -63,9 +63,9 @@ private: QString m_version_regexp; 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) : Rule(result), m_system(system), m_version_regexp(version_regexp) @@ -84,7 +84,7 @@ public: class ImplicitRule : public Rule { protected: - virtual bool applies(const Library *) + virtual bool applies(const Library *, const RuntimeContext & runtimeContext) { return true; } diff --git a/tests/Library_test.cpp b/tests/Library_test.cpp index a4ca92325..b9027e120 100644 --- a/tests/Library_test.cpp +++ b/tests/Library_test.cpp @@ -5,6 +5,7 @@ #include #include #include +#include class LibraryTest : public QObject { @@ -24,6 +25,14 @@ private: { 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 slots: void initTestCase() @@ -34,12 +43,13 @@ slots: } void test_legacy() { + RuntimeContext r = dummyContext(); Library test("test.package:testname:testversion"); QCOMPARE(test.artifactPrefix(), QString("test.package:testname")); QCOMPARE(test.isNative(), false); 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(native, {}); QCOMPARE(native32, {}); @@ -47,10 +57,11 @@ slots: } void test_legacy_url() { + RuntimeContext r = dummyContext(); QStringList failedFiles; Library test("test.package:testname:testversion"); 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(failedFiles, {}); NetAction::Ptr dl = downloads[0]; @@ -58,27 +69,29 @@ slots: } void test_legacy_url_local_broken() { + RuntimeContext r = dummyContext(); Library test("test.package:testname:testversion"); QCOMPARE(test.isNative(), false); QStringList failedFiles; 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(failedFiles, {"testname-testversion.jar"}); } void test_legacy_url_local_override() { + RuntimeContext r = dummyContext(); Library test("com.paulscode:codecwav:20101023"); QCOMPARE(test.isNative(), false); QStringList failedFiles; 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); qDebug() << failedFiles; QCOMPARE(failedFiles.size(), 0); 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(native, {}); QCOMPARE(native32, {}); @@ -86,19 +99,20 @@ slots: } void test_legacy_native() { + RuntimeContext r = dummyContext(); Library test("test.package:testname:testversion"); test.m_nativeClassifiers["linux"] = "linux"; QCOMPARE(test.isNative(), true); test.setRepositoryURL("file://foo/bar"); { 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(native, getStorage("test/package/testname/testversion/testname-testversion-linux.jar")); QCOMPARE(native32, {}); QCOMPARE(native64, {}); 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(failedFiles, {}); auto dl = dls[0]; @@ -107,6 +121,7 @@ slots: } void test_legacy_native_arch() { + RuntimeContext r = dummyContext(); Library test("test.package:testname:testversion"); test.m_nativeClassifiers["linux"]="linux-${arch}"; test.m_nativeClassifiers["osx"]="osx-${arch}"; @@ -115,41 +130,43 @@ slots: test.setRepositoryURL("file://foo/bar"); { 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(native, {}); QCOMPARE(native32, getStorage("test/package/testname/testversion/testname-testversion-linux-32.jar")); QCOMPARE(native64, getStorage("test/package/testname/testversion/testname-testversion-linux-64.jar")); 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(failedFiles, {}); 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")); } + r.system = "windows"; { 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(native, {}); QCOMPARE(native32, getStorage("test/package/testname/testversion/testname-testversion-windows-32.jar")); QCOMPARE(native64, getStorage("test/package/testname/testversion/testname-testversion-windows-64.jar")); 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(failedFiles, {}); 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")); } + r.system = "osx"; { 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(native, {}); QCOMPARE(native32, getStorage("test/package/testname/testversion/testname-testversion-osx-32.jar")); QCOMPARE(native64, getStorage("test/package/testname/testversion/testname-testversion-osx-64.jar")); 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(failedFiles, {}); 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() { + RuntimeContext r = dummyContext(); Library test("test.package:testname:testversion"); test.m_nativeClassifiers["linux"]="linux-${arch}"; test.setHint("local"); @@ -165,96 +183,104 @@ slots: test.setRepositoryURL("file://foo/bar"); { 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(native, {}); QCOMPARE(native32, {QFileInfo(QFINDTESTDATA("testdata/Library/testname-testversion-linux-32.jar")).absoluteFilePath()}); QCOMPARE(native64, {QFileInfo(QFINDTESTDATA("testdata/Library") + "/testname-testversion-linux-64.jar").absoluteFilePath()}); 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(failedFiles, {QFileInfo(QFINDTESTDATA("testdata/Library") + "/testname-testversion-linux-64.jar").absoluteFilePath()}); } } void test_onenine() { + RuntimeContext r = dummyContext("osx"); auto test = readMojangJson(QFINDTESTDATA("testdata/Library/lib-simple.json")); { 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(native, {}); QCOMPARE(native32, {}); QCOMPARE(native64, {}); } + r.system = "linux"; { 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(failedFiles, {}); QCOMPARE(dls[0]->m_url, QUrl("https://libraries.minecraft.net/com/paulscode/codecwav/20101023/codecwav-20101023.jar")); } + r.system = "osx"; test->setHint("local"); { 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(native, {}); QCOMPARE(native32, {}); QCOMPARE(native64, {}); } + r.system = "linux"; { 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(failedFiles, {}); } } void test_onenine_local_override() { + RuntimeContext r = dummyContext("osx"); auto test = readMojangJson(QFINDTESTDATA("testdata/Library/lib-simple.json")); test->setHint("local"); { 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(native, {}); QCOMPARE(native32, {}); QCOMPARE(native64, {}); } + r.system = "linux"; { 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(failedFiles, {}); } } void test_onenine_native() { + RuntimeContext r = dummyContext("osx"); auto test = readMojangJson(QFINDTESTDATA("testdata/Library/lib-native.json")); 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(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(native64, {}); 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(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")); } void test_onenine_native_arch() { + RuntimeContext r = dummyContext("windows"); auto test = readMojangJson(QFINDTESTDATA("testdata/Library/lib-native-arch.json")); 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(native, {}); 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")); 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(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")); From 7e280de361584a70fae4426cf36ca47f694ef61a Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Mon, 8 Aug 2022 19:18:36 +0200 Subject: [PATCH 4/6] refactor: drop 64-bit check Signed-off-by: Sefa Eyeoglu --- launcher/launch/steps/CheckJava.cpp | 20 -------------------- libraries/systeminfo/include/sys.h | 4 ---- libraries/systeminfo/src/sys_apple.cpp | 12 ------------ libraries/systeminfo/src/sys_unix.cpp | 11 ----------- libraries/systeminfo/src/sys_win32.cpp | 22 ---------------------- 5 files changed, 69 deletions(-) diff --git a/launcher/launch/steps/CheckJava.cpp b/launcher/launch/steps/CheckJava.cpp index db56b652c..7aeb61bf7 100644 --- a/launcher/launch/steps/CheckJava.cpp +++ b/launcher/launch/steps/CheckJava.cpp @@ -121,7 +121,6 @@ void CheckJava::checkJavaFinished(JavaCheckResult result) emit logLine(QString("Could not start java:"), MessageLevel::Error); emit logLines(result.errorLog.split('\n'), MessageLevel::Error); emit logLine(QString("\nCheck your Java settings."), MessageLevel::Launcher); - printSystemInfo(false, false); emitFailed(QString("Could not start java!")); return; } @@ -130,7 +129,6 @@ void CheckJava::checkJavaFinished(JavaCheckResult result) emit logLine(QString("Java checker returned some invalid data we don't understand:"), MessageLevel::Error); emit logLines(result.outLog.split('\n'), MessageLevel::Warning); emit logLine("\nMinecraft might not start properly.", MessageLevel::Launcher); - printSystemInfo(false, false); emitSucceeded(); return; } @@ -138,7 +136,6 @@ void CheckJava::checkJavaFinished(JavaCheckResult result) { auto instance = m_parent->instance(); printJavaInfo(result.javaVersion.toString(), result.mojangPlatform, result.realPlatform, result.javaVendor); - printSystemInfo(true, result.is_64bit); instance->settings()->set("JavaVersion", result.javaVersion.toString()); instance->settings()->set("JavaArchitecture", result.mojangPlatform); instance->settings()->set("JavaRealArchitecture", result.realPlatform); @@ -155,20 +152,3 @@ void CheckJava::printJavaInfo(const QString& version, const QString& architectur emit logLine(QString("Java is version %1, using %2 (%3) architecture, from %4.\n\n") .arg(version, architecture, realArchitecture, vendor), MessageLevel::Launcher); } - -void CheckJava::printSystemInfo(bool javaIsKnown, bool javaIs64bit) -{ - auto cpu64 = Sys::isCPU64bit(); - auto system64 = Sys::isSystem64bit(); - if(cpu64 != system64) - { - emit logLine(QString("Your CPU architecture is not matching your system architecture. You might want to install a 64bit Operating System.\n\n"), MessageLevel::Error); - } - if(javaIsKnown) - { - if(javaIs64bit != system64) - { - emit logLine(QString("Your Java architecture is not matching your system architecture. You might want to install a 64bit Java version.\n\n"), MessageLevel::Error); - } - } -} diff --git a/libraries/systeminfo/include/sys.h b/libraries/systeminfo/include/sys.h index bd6e2486a..6a6a7c82f 100644 --- a/libraries/systeminfo/include/sys.h +++ b/libraries/systeminfo/include/sys.h @@ -56,8 +56,4 @@ struct DistributionInfo DistributionInfo getDistributionInfo(); uint64_t getSystemRam(); - -bool isSystem64bit(); - -bool isCPU64bit(); } diff --git a/libraries/systeminfo/src/sys_apple.cpp b/libraries/systeminfo/src/sys_apple.cpp index 6353b747b..b6d62c1ae 100644 --- a/libraries/systeminfo/src/sys_apple.cpp +++ b/libraries/systeminfo/src/sys_apple.cpp @@ -55,18 +55,6 @@ uint64_t Sys::getSystemRam() } } -bool Sys::isCPU64bit() -{ - // not even going to pretend I'm going to support anything else - return true; -} - -bool Sys::isSystem64bit() -{ - // yep. maybe when we have 128bit CPUs on consumer devices. - return true; -} - Sys::DistributionInfo Sys::getDistributionInfo() { DistributionInfo result; diff --git a/libraries/systeminfo/src/sys_unix.cpp b/libraries/systeminfo/src/sys_unix.cpp index b30985226..3c63e73a4 100644 --- a/libraries/systeminfo/src/sys_unix.cpp +++ b/libraries/systeminfo/src/sys_unix.cpp @@ -82,17 +82,6 @@ uint64_t Sys::getSystemRam() return 0; // nothing found } -bool Sys::isCPU64bit() -{ - return isSystem64bit(); -} - -bool Sys::isSystem64bit() -{ - // kernel build arch on linux - return QSysInfo::currentCpuArchitecture() == "x86_64"; -} - Sys::DistributionInfo Sys::getDistributionInfo() { DistributionInfo systemd_info = read_os_release(); diff --git a/libraries/systeminfo/src/sys_win32.cpp b/libraries/systeminfo/src/sys_win32.cpp index 430b87e47..5bf510cf8 100644 --- a/libraries/systeminfo/src/sys_win32.cpp +++ b/libraries/systeminfo/src/sys_win32.cpp @@ -27,28 +27,6 @@ uint64_t Sys::getSystemRam() return (uint64_t)status.ullTotalPhys; } -bool Sys::isSystem64bit() -{ -#if defined(_WIN64) - return true; -#elif defined(_WIN32) - BOOL f64 = false; - return IsWow64Process(GetCurrentProcess(), &f64) && f64; -#else - // it's some other kind of system... - return false; -#endif -} - -bool Sys::isCPU64bit() -{ - SYSTEM_INFO info; - ZeroMemory(&info, sizeof(SYSTEM_INFO)); - GetNativeSystemInfo(&info); - auto arch = info.wProcessorArchitecture; - return arch == PROCESSOR_ARCHITECTURE_AMD64 || arch == PROCESSOR_ARCHITECTURE_IA64; -} - Sys::DistributionInfo Sys::getDistributionInfo() { DistributionInfo result; From 98b6f901721aaeac3ba377729ef95272eba09410 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Wed, 10 Aug 2022 17:33:55 +0200 Subject: [PATCH 5/6] fix: add more legacy architectures Signed-off-by: Sefa Eyeoglu --- launcher/RuntimeContext.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/RuntimeContext.h b/launcher/RuntimeContext.h index d98d407f6..6090897cd 100644 --- a/launcher/RuntimeContext.h +++ b/launcher/RuntimeContext.h @@ -30,7 +30,7 @@ struct RuntimeContext { // "Legacy" refers to the fact that Mojang assumed that these are the only two architectures bool isLegacyArch() const { - QSet legacyArchitectures{"amd64", "x86_64", "i686"}; + QSet legacyArchitectures{"amd64", "x86_64", "i386", "i686", "x86"}; return legacyArchitectures.contains(mappedJavaRealArchitecture()); } From 3111e6a7212ae914041fce6d851d7662975dc1be Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Sat, 8 Oct 2022 20:09:53 +0200 Subject: [PATCH 6/6] chore: add missing license headers Signed-off-by: Sefa Eyeoglu --- launcher/NullInstance.h | 35 ++++++++++++++++ launcher/RuntimeContext.h | 18 +++++++++ launcher/minecraft/Component.cpp | 35 ++++++++++++++++ launcher/minecraft/Library.cpp | 35 ++++++++++++++++ launcher/minecraft/Library.h | 35 ++++++++++++++++ launcher/minecraft/MinecraftInstance.h | 35 ++++++++++++++++ launcher/minecraft/PackProfile.h | 40 ++++++++++++++----- launcher/minecraft/Rule.cpp | 40 ++++++++++++++----- launcher/minecraft/Rule.h | 40 ++++++++++++++----- launcher/minecraft/launch/ModMinecraftJar.cpp | 40 ++++++++++++++----- launcher/minecraft/launch/ScanModFolders.cpp | 40 ++++++++++++++----- launcher/minecraft/update/FoldersTask.cpp | 35 ++++++++++++++++ tests/Library_test.cpp | 35 ++++++++++++++++ 13 files changed, 413 insertions(+), 50 deletions(-) diff --git a/launcher/NullInstance.h b/launcher/NullInstance.h index 628aff5ff..53edfa0b8 100644 --- a/launcher/NullInstance.h +++ b/launcher/NullInstance.h @@ -1,3 +1,38 @@ +// SPDX-License-Identifier: GPL-3.0-only +/* + * PolyMC - Minecraft Launcher + * Copyright (C) 2022 Sefa Eyeoglu + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * Copyright 2013-2021 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include "BaseInstance.h" #include "launch/LaunchTask.h" diff --git a/launcher/RuntimeContext.h b/launcher/RuntimeContext.h index 6090897cd..c1b713187 100644 --- a/launcher/RuntimeContext.h +++ b/launcher/RuntimeContext.h @@ -1,3 +1,21 @@ +// SPDX-License-Identifier: GPL-3.0-only +/* + * PolyMC - Minecraft Launcher + * Copyright (C) 2022 Sefa Eyeoglu + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #pragma once #include diff --git a/launcher/minecraft/Component.cpp b/launcher/minecraft/Component.cpp index ebe4eac7e..7e5b60589 100644 --- a/launcher/minecraft/Component.cpp +++ b/launcher/minecraft/Component.cpp @@ -1,3 +1,38 @@ +// SPDX-License-Identifier: GPL-3.0-only +/* + * PolyMC - Minecraft Launcher + * Copyright (C) 2022 Sefa Eyeoglu + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * Copyright 2013-2021 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include #include #include "Component.h" diff --git a/launcher/minecraft/Library.cpp b/launcher/minecraft/Library.cpp index 42a42d87b..cb2b5254d 100644 --- a/launcher/minecraft/Library.cpp +++ b/launcher/minecraft/Library.cpp @@ -1,3 +1,38 @@ +// SPDX-License-Identifier: GPL-3.0-only +/* + * PolyMC - Minecraft Launcher + * Copyright (C) 2022 Sefa Eyeoglu + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * Copyright 2013-2021 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "Library.h" #include "MinecraftInstance.h" diff --git a/launcher/minecraft/Library.h b/launcher/minecraft/Library.h index b8fae9eca..950aec9d7 100644 --- a/launcher/minecraft/Library.h +++ b/launcher/minecraft/Library.h @@ -1,3 +1,38 @@ +// SPDX-License-Identifier: GPL-3.0-only +/* + * PolyMC - Minecraft Launcher + * Copyright (C) 2022 Sefa Eyeoglu + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * Copyright 2013-2021 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include #include diff --git a/launcher/minecraft/MinecraftInstance.h b/launcher/minecraft/MinecraftInstance.h index ef48b286d..1895d1879 100644 --- a/launcher/minecraft/MinecraftInstance.h +++ b/launcher/minecraft/MinecraftInstance.h @@ -1,3 +1,38 @@ +// SPDX-License-Identifier: GPL-3.0-only +/* + * PolyMC - Minecraft Launcher + * Copyright (C) 2022 Sefa Eyeoglu + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * Copyright 2013-2021 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include "BaseInstance.h" #include diff --git a/launcher/minecraft/PackProfile.h b/launcher/minecraft/PackProfile.h index 11057a0c7..807511a26 100644 --- a/launcher/minecraft/PackProfile.h +++ b/launcher/minecraft/PackProfile.h @@ -1,16 +1,36 @@ -/* Copyright 2013-2021 MultiMC Contributors +// SPDX-License-Identifier: GPL-3.0-only +/* + * PolyMC - Minecraft Launcher + * Copyright (C) 2022 Sefa Eyeoglu * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * Copyright 2013-2021 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #pragma once diff --git a/launcher/minecraft/Rule.cpp b/launcher/minecraft/Rule.cpp index 2f41e1fb1..ff3d75f2e 100644 --- a/launcher/minecraft/Rule.cpp +++ b/launcher/minecraft/Rule.cpp @@ -1,16 +1,36 @@ -/* Copyright 2013-2021 MultiMC Contributors +// SPDX-License-Identifier: GPL-3.0-only +/* + * PolyMC - Minecraft Launcher + * Copyright (C) 2022 Sefa Eyeoglu * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * Copyright 2013-2021 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include diff --git a/launcher/minecraft/Rule.h b/launcher/minecraft/Rule.h index 4c75cee42..236f9a878 100644 --- a/launcher/minecraft/Rule.h +++ b/launcher/minecraft/Rule.h @@ -1,16 +1,36 @@ -/* Copyright 2013-2021 MultiMC Contributors +// SPDX-License-Identifier: GPL-3.0-only +/* + * PolyMC - Minecraft Launcher + * Copyright (C) 2022 Sefa Eyeoglu * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * Copyright 2013-2021 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #pragma once diff --git a/launcher/minecraft/launch/ModMinecraftJar.cpp b/launcher/minecraft/launch/ModMinecraftJar.cpp index 8e47e0e55..1d6eecf2d 100644 --- a/launcher/minecraft/launch/ModMinecraftJar.cpp +++ b/launcher/minecraft/launch/ModMinecraftJar.cpp @@ -1,16 +1,36 @@ -/* Copyright 2013-2021 MultiMC Contributors +// SPDX-License-Identifier: GPL-3.0-only +/* + * PolyMC - Minecraft Launcher + * Copyright (C) 2022 Sefa Eyeoglu * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * Copyright 2013-2021 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include "ModMinecraftJar.h" diff --git a/launcher/minecraft/launch/ScanModFolders.cpp b/launcher/minecraft/launch/ScanModFolders.cpp index 2e817e0ad..bdffeaddd 100644 --- a/launcher/minecraft/launch/ScanModFolders.cpp +++ b/launcher/minecraft/launch/ScanModFolders.cpp @@ -1,16 +1,36 @@ -/* Copyright 2013-2021 MultiMC Contributors +// SPDX-License-Identifier: GPL-3.0-only +/* + * PolyMC - Minecraft Launcher + * Copyright (C) 2022 Sefa Eyeoglu * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * Copyright 2013-2021 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include "ScanModFolders.h" diff --git a/launcher/minecraft/update/FoldersTask.cpp b/launcher/minecraft/update/FoldersTask.cpp index 22768bd97..b9ee9d980 100644 --- a/launcher/minecraft/update/FoldersTask.cpp +++ b/launcher/minecraft/update/FoldersTask.cpp @@ -1,3 +1,38 @@ +// SPDX-License-Identifier: GPL-3.0-only +/* + * PolyMC - Minecraft Launcher + * Copyright (C) 2022 Sefa Eyeoglu + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * Copyright 2013-2021 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "FoldersTask.h" #include "minecraft/MinecraftInstance.h" #include diff --git a/tests/Library_test.cpp b/tests/Library_test.cpp index b9027e120..db8380c7f 100644 --- a/tests/Library_test.cpp +++ b/tests/Library_test.cpp @@ -1,3 +1,38 @@ +// SPDX-License-Identifier: GPL-3.0-only +/* + * PolyMC - Minecraft Launcher + * Copyright (C) 2022 Sefa Eyeoglu + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * Copyright 2013-2021 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include #include