Rework version numbering system.
Again...
This commit is contained in:
parent
28cb66e85c
commit
3202b972f8
@ -128,12 +128,16 @@ SET(MultiMC_NEWS_RSS_URL "http://multimc.org/rss.xml" CACHE STRING "URL to fetch
|
||||
######## Set version numbers ########
|
||||
SET(MultiMC_VERSION_MAJOR 0)
|
||||
SET(MultiMC_VERSION_MINOR 0)
|
||||
SET(MultiMC_VERSION_HOTFIX 0)
|
||||
|
||||
# Build number
|
||||
SET(MultiMC_VERSION_BUILD -1 CACHE STRING "Build number. -1 for no build number.")
|
||||
|
||||
# Build type
|
||||
SET(MultiMC_VERSION_BUILD_TYPE "custombuild" CACHE STRING "Build type. If this is set, it is appended to the end of the version string with a dash (<version string>-<build type>. It is not used for anything other than indicating in the version string what type of build this is (eg 'lin64').")
|
||||
# Version type
|
||||
SET(MultiMC_VERSION_TYPE "Custom" CACHE STRING "MultiMC's version type. This should be one of 'Custom', 'Release', 'ReleaseCandidate', or 'Development', depending on what type of version this is.")
|
||||
|
||||
# Build platform.
|
||||
SET(MultiMC_BUILD_PLATFORM "" CACHE STRING "A short string identifying the platform that this build was built for. Only used by the notification system and to display in the about dialog.")
|
||||
|
||||
# Version channel
|
||||
SET(MultiMC_VERSION_CHANNEL "" CACHE STRING "The current build's channel. Included in the version string.")
|
||||
@ -147,16 +151,20 @@ SET(MultiMC_UPDATER false CACHE BOOL "Whether or not the update system is enable
|
||||
# Notification URL
|
||||
SET(MultiMC_NOTIFICATION_URL "" CACHE STRING "URL for checking for notifications.")
|
||||
|
||||
SET(MultiMC_RELEASE_VERSION_NAME "${MultiMC_VERSION_MAJOR}.${MultiMC_VERSION_MINOR}")
|
||||
IF (MultiMC_VERSION_HOTFIX GREATER 0)
|
||||
SET(MultiMC_RELEASE_VERSION_NAME "${MultiMC_RELEASE_VERSION_NAME}.${MultiMC_VERSION_HOTFIX}")
|
||||
ENDIF()
|
||||
|
||||
# Build a version string to display in the configure logs.
|
||||
SET(MultiMC_VERSION_STRING "5.${MultiMC_VERSION_MAJOR}.${MultiMC_VERSION_MINOR}")
|
||||
IF (MultiMC_VERSION_BUILD GREATER -1)
|
||||
SET(MultiMC_VERSION_STRING "${MultiMC_VERSION_STRING}.${MultiMC_VERSION_BUILD}")
|
||||
ENDIF ()
|
||||
IF (NOT MultiMC_VERSION_CHANNEL STREQUAL "")
|
||||
SET(MultiMC_VERSION_STRING "${MultiMC_VERSION_STRING}-${MultiMC_VERSION_CHANNEL}")
|
||||
ENDIF ()
|
||||
IF (NOT MultiMC_VERSION_BUILD_TYPE STREQUAL "")
|
||||
SET(MultiMC_VERSION_STRING "${MultiMC_VERSION_STRING}-${MultiMC_VERSION_BUILD_TYPE}")
|
||||
IF (MultiMC_VERSION_TYPE STREQUAL "Custom" OR MultiMC_VERSION_TYPE STREQUAL "Release")
|
||||
SET(MultiMC_VERSION_STRING "${MultiMC_RELEASE_VERSION_NAME}")
|
||||
ELSEIF (MultiMC_VERSION_TYPE STREQUAL "ReleaseCandidate")
|
||||
SET(MultiMC_VERSION_STRING "${MultiMC_RELEASE_VERSION_NAME}-rc${MultiMC_VERSION_BUILD}")
|
||||
ELSEIF (MultiMC_VERSION_TYPE STREQUAL "Development")
|
||||
SET(MultiMC_VERSION_STRING "${MultiMC_RELEASE_VERSION_NAME}-dev${MultiMC_VERSION_BUILD}")
|
||||
ELSE ()
|
||||
MESSAGE(ERROR "Invalid build type.")
|
||||
ENDIF ()
|
||||
|
||||
MESSAGE(STATUS "MultiMC 5 version ${MultiMC_VERSION_STRING}")
|
||||
|
@ -38,8 +38,8 @@
|
||||
using namespace Util::Commandline;
|
||||
|
||||
MultiMC::MultiMC(int &argc, char **argv, bool root_override)
|
||||
: QApplication(argc, argv), m_version{VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD,
|
||||
VERSION_CHANNEL, VERSION_BUILD_TYPE}
|
||||
: QApplication(argc, argv), m_version{VERSION_MAJOR, VERSION_MINOR, VERSION_HOTFIX,
|
||||
VERSION_BUILD, MultiMCVersion::VERSION_TYPE, VERSION_CHANNEL, BUILD_PLATFORM}
|
||||
{
|
||||
setOrganizationName("MultiMC");
|
||||
setApplicationName("MultiMC5");
|
||||
|
@ -18,58 +18,63 @@
|
||||
#include <QString>
|
||||
|
||||
/*!
|
||||
* \brief The Version class represents a MultiMC version number.
|
||||
* \brief The Version class represents a MultiMC version.
|
||||
*/
|
||||
struct MultiMCVersion
|
||||
{
|
||||
enum Type
|
||||
{
|
||||
//! Version type for stable release builds.
|
||||
Release,
|
||||
|
||||
//! Version type for release candidates.
|
||||
ReleaseCandidate,
|
||||
|
||||
//! Version type for development builds.
|
||||
Development,
|
||||
|
||||
//! Version type for custom builds. This is the default when no version type is specified.
|
||||
Custom
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Converts the Version to a string.
|
||||
* \return The version number in string format (major.minor.revision.build).
|
||||
*/
|
||||
QString toString() const
|
||||
{
|
||||
QString vstr = QString("5.%1.%2").arg(
|
||||
QString vstr = QString("%1.%2").arg(
|
||||
QString::number(major),
|
||||
QString::number(minor));
|
||||
|
||||
if (build >= 0) vstr += "." + QString::number(build);
|
||||
if (!channel.isEmpty()) vstr += "-" + channel;
|
||||
if (!buildType.isEmpty()) vstr += "-" + buildType;
|
||||
if (hotfix > 0) vstr += "." + QString::number(hotfix);
|
||||
|
||||
// If the build is a development build or release candidate, add that info to the end.
|
||||
if (type == Development) vstr += "-dev" + QString::number(build);
|
||||
else if (type == ReleaseCandidate) vstr += "-rc" + QString::number(build);
|
||||
|
||||
return vstr;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief The major version number.
|
||||
* This is no longer going to always be 5 for MultiMC 5. Doing so is useless.
|
||||
* Instead, we'll be starting major off at 1 and incrementing it with every major feature.
|
||||
*/
|
||||
//! The major version number.
|
||||
int major;
|
||||
|
||||
/*!
|
||||
* \brief The minor version number.
|
||||
* This number is incremented for major features and bug fixes.
|
||||
*/
|
||||
//! The minor version number.
|
||||
int minor;
|
||||
|
||||
/*!
|
||||
* \brief The build number.
|
||||
* This number is automatically set by Buildbot it is set to the build number of the buildbot
|
||||
* build that this build came from.
|
||||
* If this build didn't come from buildbot and no build number was given to CMake, this will default
|
||||
* to -1, causing it to not show in this version's string representation.
|
||||
*/
|
||||
//! The hotfix number.
|
||||
int hotfix;
|
||||
|
||||
//! The build number.
|
||||
int build;
|
||||
|
||||
/*!
|
||||
* \brief This build's channel.
|
||||
*/
|
||||
//! The build type.
|
||||
Type type;
|
||||
|
||||
//! The build channel.
|
||||
QString channel;
|
||||
|
||||
/*!
|
||||
* \brief The build type.
|
||||
* This indicates the type of build that this is. For example, lin64 or custombuild.
|
||||
*/
|
||||
QString buildType;
|
||||
//! A short string identifying the platform that this version is for. For example, lin64 or win32.
|
||||
QString platform;
|
||||
};
|
||||
|
||||
|
12
config.h.in
12
config.h.in
@ -1,13 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
// Minor and major version, used to communicate changes to users.
|
||||
// Version information
|
||||
#define VERSION_MAJOR @MultiMC_VERSION_MAJOR@
|
||||
#define VERSION_MINOR @MultiMC_VERSION_MINOR@
|
||||
|
||||
// Build number, channel, and type -- number and channel are used by the updater, type is purely visual
|
||||
#define VERSION_HOTFIX @MultiMC_VERSION_HOTFIX@
|
||||
#define VERSION_BUILD @MultiMC_VERSION_BUILD@
|
||||
#define VERSION_TYPE @MultiMC_VERSION_TYPE@
|
||||
|
||||
// The version channel. This is used by the updater to determine what channel the current version came from.
|
||||
#define VERSION_CHANNEL "@MultiMC_VERSION_CHANNEL@"
|
||||
#define VERSION_BUILD_TYPE "@MultiMC_VERSION_BUILD_TYPE@"
|
||||
|
||||
// A short string identifying this build's platform. For example, "lin64" or "win32".
|
||||
#define BUILD_PLATFORM "@MultiMC_BUILD_PLATFORM@"
|
||||
|
||||
// URL for the updater's channel
|
||||
#define CHANLIST_URL "@MultiMC_CHANLIST_URL@"
|
||||
|
@ -5,8 +5,8 @@
|
||||
#include <QJsonArray>
|
||||
|
||||
#include "MultiMC.h"
|
||||
#include "MultiMCVersion.h"
|
||||
#include "logic/net/CacheDownload.h"
|
||||
#include "config.h"
|
||||
|
||||
NotificationChecker::NotificationChecker(QObject *parent)
|
||||
: QObject(parent), m_notificationsUrl(QUrl(NOTIFICATION_URL))
|
||||
@ -66,7 +66,7 @@ void NotificationChecker::downloadSucceeded(int)
|
||||
entry.id = obj.value("id").toDouble();
|
||||
entry.message = obj.value("message").toString();
|
||||
entry.channel = obj.value("channel").toString();
|
||||
entry.buildtype = obj.value("buildtype").toString();
|
||||
entry.platform = obj.value("platform").toString();
|
||||
entry.from = obj.value("from").toString();
|
||||
entry.to = obj.value("to").toString();
|
||||
const QString type = obj.value("type").toString("critical");
|
||||
@ -93,13 +93,14 @@ void NotificationChecker::downloadSucceeded(int)
|
||||
|
||||
bool NotificationChecker::NotificationEntry::applies() const
|
||||
{
|
||||
bool channelApplies = channel.isEmpty() || channel == VERSION_CHANNEL;
|
||||
bool buildtypeApplies = buildtype.isEmpty() || buildtype == VERSION_BUILD_TYPE;
|
||||
MultiMCVersion version = MMC->version();
|
||||
bool channelApplies = channel.isEmpty() || channel == version.channel;
|
||||
bool platformApplies = platform.isEmpty() || platform == version.platform;
|
||||
bool fromApplies =
|
||||
from.isEmpty() || from == FULL_VERSION_STR || !versionLessThan(FULL_VERSION_STR, from);
|
||||
bool toApplies =
|
||||
to.isEmpty() || to == FULL_VERSION_STR || !versionLessThan(to, FULL_VERSION_STR);
|
||||
return channelApplies && buildtypeApplies && fromApplies && toApplies;
|
||||
return channelApplies && platformApplies && fromApplies && toApplies;
|
||||
}
|
||||
|
||||
bool NotificationChecker::NotificationEntry::versionLessThan(const QString &v1,
|
||||
|
@ -26,7 +26,7 @@ public:
|
||||
Information
|
||||
} type;
|
||||
QString channel;
|
||||
QString buildtype;
|
||||
QString platform;
|
||||
QString from;
|
||||
QString to;
|
||||
bool applies() const;
|
||||
|
Loading…
Reference in New Issue
Block a user