From 482ad250a4454d993a98488edfe01d7f9dc35de7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 6 Apr 2014 03:59:37 +0200 Subject: Workaround for dirty build folders. My disgust just turned into barely contained rage :< --- BuildConfig.cpp.in | 63 +++++++++++++++++++++++++ BuildConfig.h | 86 +++++++++++++++++++++++++++++++++++ CMakeLists.txt | 6 +-- Config.cpp.in | 63 ------------------------- Config.h | 86 ----------------------------------- MultiMC.cpp | 2 +- gui/MainWindow.cpp | 2 +- gui/dialogs/AboutDialog.cpp | 2 +- logic/MinecraftProcess.cpp | 2 +- logic/updater/DownloadUpdateTask.cpp | 2 +- logic/updater/NotificationChecker.cpp | 2 +- logic/updater/UpdateChecker.cpp | 2 +- tests/tst_UpdateChecker.cpp | 2 +- 13 files changed, 160 insertions(+), 160 deletions(-) create mode 100644 BuildConfig.cpp.in create mode 100644 BuildConfig.h delete mode 100644 Config.cpp.in delete mode 100644 Config.h diff --git a/BuildConfig.cpp.in b/BuildConfig.cpp.in new file mode 100644 index 00000000..1ea07374 --- /dev/null +++ b/BuildConfig.cpp.in @@ -0,0 +1,63 @@ +#include "BuildConfig.h" + +Config BuildConfig; + +Config::Config() +{ + // Version information + VERSION_MAJOR = @MultiMC_VERSION_MAJOR@; + VERSION_MINOR = @MultiMC_VERSION_MINOR@; + VERSION_HOTFIX = @MultiMC_VERSION_HOTFIX@; + VERSION_BUILD = @MultiMC_VERSION_BUILD@; + VERSION_TYPE = "@MultiMC_VERSION_TYPE@"; + + if(VERSION_TYPE == "Release") + versionTypeEnum = Release; + else if(VERSION_TYPE == "ReleaseCandidate") + versionTypeEnum = ReleaseCandidate; + else if(VERSION_TYPE == "Development") + versionTypeEnum = Development; + else + versionTypeEnum = Custom; + VERSION_CHANNEL = "@MultiMC_VERSION_CHANNEL@"; + BUILD_PLATFORM = "@MultiMC_BUILD_PLATFORM@"; + CHANLIST_URL = "@MultiMC_CHANLIST_URL@"; + NOTIFICATION_URL = "@MultiMC_NOTIFICATION_URL@"; + FULL_VERSION_STR = "@MultiMC_VERSION_MAJOR@.@MultiMC_VERSION_MINOR@.@MultiMC_VERSION_BUILD@"; + + UPDATER_DRY_RUN = @MultiMC_UPDATER_DRY_RUN_value@; + UPDATER_FORCE_LOCAL = @MultiMC_UPDATER_FORCE_LOCAL_value@; + + GIT_COMMIT = "@MultiMC_GIT_COMMIT@"; + VERSION_STR = "@MultiMC_VERSION_STRING@"; + NEWS_RSS_URL = "@MultiMC_NEWS_RSS_URL@"; +} + +QString Config::versionTypeName() const +{ + switch (versionTypeEnum) + { + case Release: + return "Stable Release"; + case ReleaseCandidate: + return "Release Candidate"; + case Development: + return "Development"; + case Custom: + default: + return "Custom"; + } +} + +QString Config::printableVersionString() const +{ + QString vstr = QString("%1.%2").arg(QString::number(VERSION_MAJOR), QString::number(VERSION_MINOR)); + + if (VERSION_HOTFIX > 0) vstr += "." + QString::number(VERSION_HOTFIX); + + // If the build is a development build or release candidate, add that info to the end. + if (versionTypeEnum == Development) vstr += "-dev" + QString::number(VERSION_BUILD); + else if (versionTypeEnum == ReleaseCandidate) vstr += "-rc" + QString::number(VERSION_BUILD); + + return vstr; +} diff --git a/BuildConfig.h b/BuildConfig.h new file mode 100644 index 00000000..baf2ad6d --- /dev/null +++ b/BuildConfig.h @@ -0,0 +1,86 @@ +#pragma once +#include + +/** + * \brief The Config class holds all the build-time information passed from the build system. + */ +class Config +{ +public: + Config(); + /// The major version number. + int VERSION_MAJOR; + /// The minor version number. + int VERSION_MINOR; + /// The hotfix number. + int VERSION_HOTFIX; + /// The build number. + int VERSION_BUILD; + /// The build type, as specified at build time. + QString VERSION_TYPE; + + /// The build type, transformed. + 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 + } versionTypeEnum; + + /** + * The version channel + * This is used by the updater to determine what channel the current version came from. + */ + QString VERSION_CHANNEL; + + /// A short string identifying this build's platform. For example, "lin64" or "win32". + QString BUILD_PLATFORM; + + /// URL for the updater's channel + QString CHANLIST_URL; + + /// URL for notifications + QString NOTIFICATION_URL; + + /// Used for matching notifications + QString FULL_VERSION_STR; + + /// enabled for updater dry run + bool UPDATER_DRY_RUN; + + /// enabled for updater dry run + bool UPDATER_FORCE_LOCAL; + + /// The commit hash of this build + QString GIT_COMMIT; + + /// This is printed on start to standard output + QString VERSION_STR; + + /** + * This is used to fetch the news RSS feed. + * It defaults in CMakeLists.txt to "http://multimc.org/rss.xml" + */ + QString NEWS_RSS_URL; + + /** + * \brief Converts the Version to a string. + * \return The version number in string format (major.minor.revision.build). + */ + QString printableVersionString() const; + + /** + * returns a string representation of the version channel type, suitable for printing. + */ + QString versionTypeName() const; +}; + +extern Config BuildConfig; diff --git a/CMakeLists.txt b/CMakeLists.txt index f71e1156..d804e730 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -204,7 +204,7 @@ IF(MultiMC_CODE_COVERAGE) ENDIF(MultiMC_CODE_COVERAGE) ######## Configure header ######## -configure_file("${PROJECT_SOURCE_DIR}/Config.cpp.in" "${PROJECT_BINARY_DIR}/Config.cpp") +configure_file("${PROJECT_SOURCE_DIR}/BuildConfig.cpp.in" "${PROJECT_BINARY_DIR}/BuildConfig.cpp") ######## Packaging/install paths setup ######## @@ -279,8 +279,8 @@ SET(MULTIMC_SOURCES MultiMC.h MultiMC.cpp MMCError.h -Config.h -${PROJECT_BINARY_DIR}/Config.cpp +BuildConfig.h +${PROJECT_BINARY_DIR}/BuildConfig.cpp # Logging logger/QsDebugOutput.cpp diff --git a/Config.cpp.in b/Config.cpp.in deleted file mode 100644 index 8051e1b4..00000000 --- a/Config.cpp.in +++ /dev/null @@ -1,63 +0,0 @@ -#include "Config.h" - -Config BuildConfig; - -Config::Config() -{ - // Version information - VERSION_MAJOR = @MultiMC_VERSION_MAJOR@; - VERSION_MINOR = @MultiMC_VERSION_MINOR@; - VERSION_HOTFIX = @MultiMC_VERSION_HOTFIX@; - VERSION_BUILD = @MultiMC_VERSION_BUILD@; - VERSION_TYPE = "@MultiMC_VERSION_TYPE@"; - - if(VERSION_TYPE == "Release") - versionTypeEnum = Release; - else if(VERSION_TYPE == "ReleaseCandidate") - versionTypeEnum = ReleaseCandidate; - else if(VERSION_TYPE == "Development") - versionTypeEnum = Development; - else - versionTypeEnum = Custom; - VERSION_CHANNEL = "@MultiMC_VERSION_CHANNEL@"; - BUILD_PLATFORM = "@MultiMC_BUILD_PLATFORM@"; - CHANLIST_URL = "@MultiMC_CHANLIST_URL@"; - NOTIFICATION_URL = "@MultiMC_NOTIFICATION_URL@"; - FULL_VERSION_STR = "@MultiMC_VERSION_MAJOR@.@MultiMC_VERSION_MINOR@.@MultiMC_VERSION_BUILD@"; - - UPDATER_DRY_RUN = @MultiMC_UPDATER_DRY_RUN_value@; - UPDATER_FORCE_LOCAL = @MultiMC_UPDATER_FORCE_LOCAL_value@; - - GIT_COMMIT = "@MultiMC_GIT_COMMIT@"; - VERSION_STR = "@MultiMC_VERSION_STRING@"; - NEWS_RSS_URL = "@MultiMC_NEWS_RSS_URL@"; -} - -QString Config::versionTypeName() const -{ - switch (versionTypeEnum) - { - case Release: - return "Stable Release"; - case ReleaseCandidate: - return "Release Candidate"; - case Development: - return "Development"; - case Custom: - default: - return "Custom"; - } -} - -QString Config::printableVersionString() const -{ - QString vstr = QString("%1.%2").arg(QString::number(VERSION_MAJOR), QString::number(VERSION_MINOR)); - - if (VERSION_HOTFIX > 0) vstr += "." + QString::number(VERSION_HOTFIX); - - // If the build is a development build or release candidate, add that info to the end. - if (versionTypeEnum == Development) vstr += "-dev" + QString::number(VERSION_BUILD); - else if (versionTypeEnum == ReleaseCandidate) vstr += "-rc" + QString::number(VERSION_BUILD); - - return vstr; -} diff --git a/Config.h b/Config.h deleted file mode 100644 index baf2ad6d..00000000 --- a/Config.h +++ /dev/null @@ -1,86 +0,0 @@ -#pragma once -#include - -/** - * \brief The Config class holds all the build-time information passed from the build system. - */ -class Config -{ -public: - Config(); - /// The major version number. - int VERSION_MAJOR; - /// The minor version number. - int VERSION_MINOR; - /// The hotfix number. - int VERSION_HOTFIX; - /// The build number. - int VERSION_BUILD; - /// The build type, as specified at build time. - QString VERSION_TYPE; - - /// The build type, transformed. - 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 - } versionTypeEnum; - - /** - * The version channel - * This is used by the updater to determine what channel the current version came from. - */ - QString VERSION_CHANNEL; - - /// A short string identifying this build's platform. For example, "lin64" or "win32". - QString BUILD_PLATFORM; - - /// URL for the updater's channel - QString CHANLIST_URL; - - /// URL for notifications - QString NOTIFICATION_URL; - - /// Used for matching notifications - QString FULL_VERSION_STR; - - /// enabled for updater dry run - bool UPDATER_DRY_RUN; - - /// enabled for updater dry run - bool UPDATER_FORCE_LOCAL; - - /// The commit hash of this build - QString GIT_COMMIT; - - /// This is printed on start to standard output - QString VERSION_STR; - - /** - * This is used to fetch the news RSS feed. - * It defaults in CMakeLists.txt to "http://multimc.org/rss.xml" - */ - QString NEWS_RSS_URL; - - /** - * \brief Converts the Version to a string. - * \return The version number in string format (major.minor.revision.build). - */ - QString printableVersionString() const; - - /** - * returns a string representation of the version channel type, suitable for printing. - */ - QString versionTypeName() const; -}; - -extern Config BuildConfig; diff --git a/MultiMC.cpp b/MultiMC.cpp index 50a01f91..ddc1fca7 100644 --- a/MultiMC.cpp +++ b/MultiMC.cpp @@ -1,5 +1,5 @@ #include "MultiMC.h" -#include "Config.h" +#include "BuildConfig.h" #include #include diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp index e4d28ca3..ce09c42d 100644 --- a/gui/MainWindow.cpp +++ b/gui/MainWindow.cpp @@ -17,7 +17,7 @@ * limitations under the License. */ #include "MultiMC.h" -#include "Config.h" +#include "BuildConfig.h" #include "MainWindow.h" #include "ui_MainWindow.h" diff --git a/gui/dialogs/AboutDialog.cpp b/gui/dialogs/AboutDialog.cpp index 944a61c8..9883aafb 100644 --- a/gui/dialogs/AboutDialog.cpp +++ b/gui/dialogs/AboutDialog.cpp @@ -18,7 +18,7 @@ #include #include "MultiMC.h" #include "gui/Platform.h" -#include "Config.h" +#include "BuildConfig.h" AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent), ui(new Ui::AboutDialog) { diff --git a/logic/MinecraftProcess.cpp b/logic/MinecraftProcess.cpp index 7b97b717..e43e5830 100644 --- a/logic/MinecraftProcess.cpp +++ b/logic/MinecraftProcess.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ #include "MultiMC.h" -#include "Config.h" +#include "BuildConfig.h" #include "MinecraftProcess.h" diff --git a/logic/updater/DownloadUpdateTask.cpp b/logic/updater/DownloadUpdateTask.cpp index b7144539..e4cad73f 100644 --- a/logic/updater/DownloadUpdateTask.cpp +++ b/logic/updater/DownloadUpdateTask.cpp @@ -16,7 +16,7 @@ #include "DownloadUpdateTask.h" #include "MultiMC.h" -#include "Config.h" +#include "BuildConfig.h" #include "logic/updater/UpdateChecker.h" #include "logic/net/NetJob.h" diff --git a/logic/updater/NotificationChecker.cpp b/logic/updater/NotificationChecker.cpp index 39da362b..5b458ddd 100644 --- a/logic/updater/NotificationChecker.cpp +++ b/logic/updater/NotificationChecker.cpp @@ -5,7 +5,7 @@ #include #include "MultiMC.h" -#include "Config.h" +#include "BuildConfig.h" #include "logic/net/CacheDownload.h" NotificationChecker::NotificationChecker(QObject *parent) diff --git a/logic/updater/UpdateChecker.cpp b/logic/updater/UpdateChecker.cpp index 57ddfb0b..e47e1c4c 100644 --- a/logic/updater/UpdateChecker.cpp +++ b/logic/updater/UpdateChecker.cpp @@ -16,7 +16,7 @@ #include "UpdateChecker.h" #include "MultiMC.h" -#include "Config.h" +#include "BuildConfig.h" #include "logger/QsLog.h" diff --git a/tests/tst_UpdateChecker.cpp b/tests/tst_UpdateChecker.cpp index 40232afe..ae6fc193 100644 --- a/tests/tst_UpdateChecker.cpp +++ b/tests/tst_UpdateChecker.cpp @@ -4,7 +4,7 @@ #include "depends/settings/settingsobject.h" #include "depends/settings/setting.h" -#include "Config.h" +#include "BuildConfig.h" #include "TestUtil.h" #include "logic/updater/UpdateChecker.h" -- cgit v1.2.3