Rework MultiMC's versioning system

This commit is contained in:
Andrew 2013-12-01 14:27:36 -06:00
parent eff38858ef
commit 2427ad6871
5 changed files with 46 additions and 31 deletions

View File

@ -91,16 +91,29 @@ ENDIF(${BIGENDIAN})
######## Set version numbers ########
SET(MultiMC_VERSION_MAJOR 5)
SET(MultiMC_VERSION_MAJOR 1)
SET(MultiMC_VERSION_MINOR 0)
SET(MultiMC_VERSION_REV 0)
# Build number
SET(MultiMC_VERSION_BUILD 0 CACHE STRING "Build number.")
MESSAGE(STATUS "MultiMC build #${MultiMC_VERSION_BUILD}")
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. Usually corresponds to the buildbot build name. Empty string for no build type.")
SET(MultiMC_VERSION_STRING "${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_BUILD_TYPE STREQUAL "")
SET(MultiMC_VERSION_STRING "${MultiMC_VERSION_STRING}-${MultiMC_VERSION_BUILD_TYPE}")
ENDIF ()
MESSAGE(STATUS "MultiMC 5 version ${MultiMC_VERSION_STRING}")
# Custom target to just print the version.
ADD_CUSTOM_TARGET(version echo "Version: ${MultiMC_VERSION_MAJOR}.${MultiMC_VERSION_MINOR}.${MultiMC_VERSION_REV}.${MultiMC_VERSION_BUILD}")
ADD_CUSTOM_TARGET(version echo "Version: ${MultiMC_VERSION_STRING}")
# Check the current Git commit
execute_process(COMMAND git rev-parse HEAD

View File

@ -31,7 +31,8 @@
#include "config.h"
using namespace Util::Commandline;
MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv)
MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv),
m_version{VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD, VERSION_BUILD_TYPE}
{
setOrganizationName("MultiMC");
setApplicationName("MultiMC5");
@ -105,8 +106,6 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv)
{
std::cout << "Version " << VERSION_STR << std::endl;
std::cout << "Git " << GIT_COMMIT << std::endl;
std::cout << "Tag: " << JENKINS_BUILD_TAG << " " << (ARCH == x64 ? "x86_64" : "x86")
<< std::endl;
m_status = MultiMC::Succeeded;
return;
}

View File

@ -2,7 +2,6 @@
#include <QApplication>
#include "MultiMCVersion.h"
#include "config.h"
#include <memory>
#include "logger/QsLog.h"
#include "logger/QsLogDest.h"
@ -119,5 +118,5 @@ private:
QsLogging::DestinationPtr m_debugDestination;
Status m_status = MultiMC::Failed;
MultiMCVersion m_version = {VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_BUILD};
MultiMCVersion m_version;
};

View File

@ -28,36 +28,43 @@ struct MultiMCVersion
*/
QString toString() const
{
return QString("%1.%2.%3.%4").arg(
QString::number(major),
QString::number(minor),
QString::number(revision),
QString::number(build));
QString vstr = QString("%1.%2").arg(
QString::number(major),
QString::number(minor));
if (build > 0) vstr += QString(".%1").arg(QString::number(build));
if (!buildType.isEmpty()) vstr += QString("-%1").arg(buildType);
return vstr;
}
/*!
* \brief The major version number.
* For MultiMC 5, this will always be 5.
* 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.
*/
int major;
/*!
* \brief The minor version number.
* This number is incremented when major features are added.
* This number is incremented for major features and bug fixes.
*/
int minor;
/*!
* \brief The revision number.
* This number is incremented for bugfixes and small features.
*/
int revision;
/*!
* \brief The build number.
* This number is automatically set by Jenkins. It is incremented every time
* a new build is run.
* 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.
*/
int build;
/*!
* \brief The build type.
* This indicates the type of build that this is. For example, lin64-stable.
* Usually corresponds to this build's buildbot builder name.
*/
QString buildType;
};

View File

@ -1,19 +1,16 @@
#define VERSION_MAJOR @MultiMC_VERSION_MAJOR@
#define VERSION_MINOR @MultiMC_VERSION_MINOR@
#define VERSION_REVISION @MultiMC_VERSION_REV@
#define VERSION_BUILD @MultiMC_VERSION_BUILD@
#define VERSION_BUILD_TYPE "@MultiMC_VERSION_BUILD_TYPE@"
#define GIT_COMMIT "@MultiMC_GIT_COMMIT@"
#define VERSION_STR "@MultiMC_VERSION_MAJOR@.@MultiMC_VERSION_MINOR@.@MultiMC_VERSION_REV@.@MultiMC_VERSION_BUILD@"
#define VERSION_STR "@MultiMC_VERSION_STRING@"
#define x86 1
#define x64 2
#define ARCH @MultiMC_ARCH@
#define JENKINS_BUILD_TAG "@MultiMC_BUILD_TAG@"
#define JENKINS_JOB_URL "@MultiMC_JOB_URL@"
#define USE_HTTPS @MultiMC_USE_HTTPS@