From 0343bfb5219059af7d8752aaa22b04fb0946a73a Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 5 Apr 2016 01:16:38 +0200 Subject: [PATCH] refs #625, refs #614 using cpp.in instead of h.in * kept nornmal header buildconfig.h * kept all standard code in buildconfig.cpp * bundled all DEFINE / replaced code in buildconfig.cpp.in (small) --- src/blackmisc/blackmisc.pro | 14 +- src/blackmisc/buildconfig.cpp | 167 +++++------------- src/blackmisc/buildconfig.cpp.in | 136 ++++++++++++++ .../{buildconfig.h.in => buildconfig.h} | 47 +---- 4 files changed, 196 insertions(+), 168 deletions(-) create mode 100644 src/blackmisc/buildconfig.cpp.in rename src/blackmisc/{buildconfig.h.in => buildconfig.h} (72%) diff --git a/src/blackmisc/blackmisc.pro b/src/blackmisc/blackmisc.pro index 2b9a526c4..f9b6b7b5e 100644 --- a/src/blackmisc/blackmisc.pro +++ b/src/blackmisc/blackmisc.pro @@ -10,8 +10,15 @@ contains(BLACK_CONFIG, Static) { CONFIG += staticlib } -buildconfig.input = buildconfig.h.in -buildconfig.output = buildconfig.h +buildconfig.input = buildconfig.cpp.in +CONFIG(debug, debug|release) { + buildconfig.output = $$OUT_PWD/debug/buildconfig_gen.cpp + GENERATED_SOURCES += $$OUT_PWD/debug/buildconfig_gen.cpp + +} else { + buildconfig.output = $$OUT_PWD/release/buildconfig_gen.cpp + GENERATED_SOURCES += $$OUT_PWD/release/buildconfig_gen.cpp +} QMAKE_SUBSTITUTES += buildconfig INCLUDEPATH += .. @@ -31,7 +38,6 @@ TRANSLATIONS += translations/blackmisc_i18n_de.ts \ translations/blackmisc_i18n_en.ts HEADERS += *.h \ - buildconfig.h.in \ $$PWD/pq/*.h \ $$PWD/aviation/*.h \ $$PWD/math/*.h \ @@ -70,7 +76,7 @@ win32 { DESTDIR = $$DestRoot/lib DLLDESTDIR = $$DestRoot/bin -OTHER_FILES += $$TRANSLATIONS readme.txt +OTHER_FILES += $$TRANSLATIONS readme.txt buildconfig.cpp.in win32 { dlltarget.path = $$PREFIX/bin diff --git a/src/blackmisc/buildconfig.cpp b/src/blackmisc/buildconfig.cpp index fe28cc4b4..b56d4f392 100644 --- a/src/blackmisc/buildconfig.cpp +++ b/src/blackmisc/buildconfig.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2013 - * swift Project Community / Contributors + * swift Project Community/Contributors * * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, @@ -21,79 +21,44 @@ namespace BlackMisc { - bool CBuildConfig::isCompiledWithBlackCore() - { -#ifdef WITH_BLACKCORE - return true; -#else - return false; -#endif - } - - bool CBuildConfig::isCompiledWithBlackSound() - { -#ifdef WITH_BLACKSOUND - return true; -#else - return false; -#endif - } - - bool CBuildConfig::isCompiledWithBlackInput() - { -#ifdef WITH_BLACKINPUT - return true; -#else - return false; -#endif - } - - bool CBuildConfig::isCompiledWithFs9Support() - { -#ifdef WITH_FS9 - return true; -#else - return false; -#endif - } - - bool CBuildConfig::isCompiledWithFsxSupport() - { -#ifdef WITH_FSX - return true; -#else - return false; -#endif - } - bool CBuildConfig::isCompiledWithP3DSupport() { - return isCompiledWithFsxSupport(); + return CBuildConfig::isCompiledWithFsxSupport(); } bool CBuildConfig::isCompiledWithMsFlightSimulatorSupport() { - return isCompiledWithFs9Support() || isCompiledWithFsxSupport() || isCompiledWithP3DSupport(); - } - - bool CBuildConfig::isCompiledWithXPlaneSupport() - { -#ifdef WITH_XPLANE - return true; -#else - return false; -#endif + return CBuildConfig::isCompiledWithFs9Support() || CBuildConfig::isCompiledWithFsxSupport() || CBuildConfig::isCompiledWithP3DSupport(); } bool CBuildConfig::isCompiledWithFlightSimulatorSupport() { - return isCompiledWithFsxSupport() || isCompiledWithXPlaneSupport(); + return CBuildConfig::isCompiledWithFsxSupport() || CBuildConfig::isCompiledWithXPlaneSupport(); } - bool CBuildConfig::isCompiledWithGui() + const QString &CBuildConfig::swiftGuiExecutableName() { -#ifdef WITH_BLACKGUI - return true; + static const QString s("swiftguistd"); + return s; + } + + const QString &CBuildConfig::swiftCoreExecutableName() + { + static const QString s("swiftcore"); + return s; + } + + const QString &CBuildConfig::swiftDataExecutableName() + { + static const QString s("swiftdata"); + return s; + } + + bool CBuildConfig::isRunningOnWindowsNtPlatform() + { +#ifdef Q_OS_WIN + // QSysInfo::WindowsVersion only available on Win platforms + return (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based); #else return false; #endif @@ -117,62 +82,11 @@ namespace BlackMisc #endif } - bool CBuildConfig::isBetaTest() - { -#ifdef SWIFT_BETA - return true; -#else - return false; -#endif - } - - bool CBuildConfig::canRunInDeveloperEnvironment() - { - if (isBetaTest()) { return true; } - return !isShippedVersion(); - } - - bool CBuildConfig::isShippedVersion() - { -#ifdef SWIFT_SHIPPED - return true; -#else - return false; -#endif - } - - bool CBuildConfig::isRunningOnWindowsNtPlatform() - { -#ifdef Q_OS_WIN - // QSysInfo::WindowsVersion only available on Win platforms - return (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based); -#else - return false; -#endif - } - - const QString &CBuildConfig::swiftGuiExecutableName() - { - static const QString s("swiftguistd"); - return s; - } - - const QString &CBuildConfig::swiftCoreExecutableName() - { - static const QString s("swiftcore"); - return s; - } - - const QString &CBuildConfig::swiftDataExecutableName() - { - static const QString s("swiftdata"); - return s; - } - const QStringList &CBuildConfig::swiftTeamDefaultServers() { static const QStringList s({ "https://vatsim-germany.org:50443/mapping/public/shared", - "http://ubuntu12/public/bootstrap/shared"}); + "http://ubuntu12/public/bootstrap/shared" + }); return s; } @@ -263,6 +177,12 @@ namespace BlackMisc return s; } + bool CBuildConfig::canRunInDeveloperEnvironment() + { + if (CBuildConfig::isBetaTest()) { return true; } + return !CBuildConfig::isShippedVersion(); + } + QString getDocumentationDirectoryImpl() { QStringList pathes(QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation)); @@ -287,14 +207,14 @@ namespace BlackMisc if (infoShort.isEmpty()) { QStringList sl; - if (isCompiledWithBlackCore()) { sl << "BlackCore"; } - if (isCompiledWithBlackSound()) { sl << "BlackSound"; } - if (isCompiledWithBlackInput()) { sl << "BlackInput"; } - if (isCompiledWithGui()) { sl << "BlackGui"; } - if (isCompiledWithFs9Support()) { sl << "FS9"; } - if (isCompiledWithFsxSupport()) { sl << "FSX"; } - if (isCompiledWithXPlaneSupport()) { sl << "XPlane"; } - if (isCompiledWithP3DSupport()) { sl << "P3D"; } + if (CBuildConfig::isCompiledWithBlackCore()) { sl << "BlackCore"; } + if (CBuildConfig::isCompiledWithBlackSound()) { sl << "BlackSound"; } + if (CBuildConfig::isCompiledWithBlackInput()) { sl << "BlackInput"; } + if (CBuildConfig::isCompiledWithGui()) { sl << "BlackGui"; } + if (CBuildConfig::isCompiledWithFs9Support()) { sl << "FS9"; } + if (CBuildConfig::isCompiledWithFsxSupport()) { sl << "FSX"; } + if (CBuildConfig::isCompiledWithXPlaneSupport()) { sl << "XPlane"; } + if (CBuildConfig::isCompiledWithP3DSupport()) { sl << "P3D"; } infoShort = sl.join(", "); if (infoShort.isEmpty()) { infoShort = ""; } } @@ -335,8 +255,6 @@ namespace BlackMisc return false; } - - QList CVersion::getVersionParts(const QString &versionString) { QStringList parts = versionString.split('.'); @@ -349,7 +267,6 @@ namespace BlackMisc } return partsInt; } - } // ns //! \endcond diff --git a/src/blackmisc/buildconfig.cpp.in b/src/blackmisc/buildconfig.cpp.in new file mode 100644 index 000000000..64680c702 --- /dev/null +++ b/src/blackmisc/buildconfig.cpp.in @@ -0,0 +1,136 @@ +/* Copyright (C) 2016 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#include \"blackmisc/buildconfig.h\" +#include +#include + +$$DEFINE_WITH_BLACKCORE#define WITH_BLACKCORE +$$DEFINE_WITH_BLACKSOUND#define WITH_BLACKSOUND +$$DEFINE_WITH_BLACKINPUT#define WITH_BLACKINPUT +$$DEFINE_WITH_BLACKGUI#define WITH_BLACKGUI +$$DEFINE_WITH_SWIFTDATA#define WITH_SWIFTDATA +$$DEFINE_WITH_SWIFTGUI#define WITH_SWIFTGUI +$$DEFINE_WITH_SWIFTCORE#define WITH_SWIFTCORE +$$DEFINE_WITH_FSX#define WITH_FSX +$$DEFINE_WITH_FS9#define WITH_FS9 +$$DEFINE_WITH_XPLANE#define WITH_XPLANE +$$DEFINE_SWIFT_BETA#define SWIFT_BETA +$$DEFINE_SWIFT_SHIPPED#define SWIFT_SHIPPED + +bool BlackMisc::CBuildConfig::isCompiledWithBlackCore() +{ +#ifdef WITH_BLACKCORE + return true; +#else + return false; +#endif +} + +bool BlackMisc::CBuildConfig::isCompiledWithBlackSound() +{ +#ifdef WITH_BLACKSOUND + return true; +#else + return false; +#endif +} + +bool BlackMisc::CBuildConfig::isCompiledWithBlackInput() +{ +#ifdef WITH_BLACKINPUT + return true; +#else + return false; +#endif +} + +bool BlackMisc::CBuildConfig::isCompiledWithFs9Support() +{ +#ifdef WITH_FS9 + return true; +#else + return false; +#endif +} + +bool BlackMisc::CBuildConfig::isCompiledWithFsxSupport() +{ +#ifdef WITH_FSX + return true; +#else + return false; +#endif +} + +bool BlackMisc::CBuildConfig::isCompiledWithXPlaneSupport() +{ +#ifdef WITH_XPLANE + return true; +#else + return false; +#endif +} + +bool BlackMisc::CBuildConfig::isCompiledWithGui() +{ +#ifdef WITH_BLACKGUI + return true; +#else + return false; +#endif +} + +bool BlackMisc::CBuildConfig::isBetaTest() +{ +#ifdef SWIFT_BETA + return true; +#else + return false; +#endif +} + +bool BlackMisc::CBuildConfig::isShippedVersion() +{ +#ifdef SWIFT_SHIPPED + return true; +#else + return false; +#endif +} + +const QDateTime &BlackMisc::CBuildConfig::getEol() +{ + static const QString eol(\"$$BLACK_EOL\"); + static const QDateTime dt(eol.isEmpty() ? QDateTime() : QDateTime::fromString(eol, \"yyyyMMdd\")); + return dt; +} + +int BlackMisc::CBuildConfig::vatsimClientId() +{ + static const int id { $$VATSIM_CLIENT_ID }; + return id; +} + +const QString &BlackMisc::CBuildConfig::vatsimPrivateKey() +{ + static const auto pk = QString { \"$$VATSIM_CLIENT_PRIVATE_KEY\" }; + return pk; +} + +const QString &BlackMisc::CVersion::version() +{ + static const QString version(\"$$BLACK_VERSION\"); + Q_ASSERT(!version.isEmpty()); + return version; +} + +int BlackMisc::CVersion::versionMajor() { return $$BLACK_VER_MAJ; } +int BlackMisc::CVersion::versionMinor() { return $$BLACK_VER_MIN; } +int BlackMisc::CVersion::versionPatch() { return $$BLACK_VER_PAT; } diff --git a/src/blackmisc/buildconfig.h.in b/src/blackmisc/buildconfig.h similarity index 72% rename from src/blackmisc/buildconfig.h.in rename to src/blackmisc/buildconfig.h index 9d397fe1a..007fec613 100644 --- a/src/blackmisc/buildconfig.h.in +++ b/src/blackmisc/buildconfig.h @@ -12,23 +12,10 @@ #ifndef BLACKMISC_BUILDCONFIG_H #define BLACKMISC_BUILDCONFIG_H -#include \"blackmisc/blackmiscexport.h\" +#include "blackmisc/blackmiscexport.h" #include #include -$$DEFINE_WITH_BLACKCORE#define WITH_BLACKCORE -$$DEFINE_WITH_BLACKSOUND#define WITH_BLACKSOUND -$$DEFINE_WITH_BLACKINPUT#define WITH_BLACKINPUT -$$DEFINE_WITH_BLACKGUI#define WITH_BLACKGUI -$$DEFINE_WITH_SWIFTDATA#define WITH_SWIFTDATA -$$DEFINE_WITH_SWIFTGUI#define WITH_SWIFTGUI -$$DEFINE_WITH_SWIFTCORE#define WITH_SWIFTCORE -$$DEFINE_WITH_FSX#define WITH_FSX -$$DEFINE_WITH_FS9#define WITH_FS9 -$$DEFINE_WITH_XPLANE#define WITH_XPLANE -$$DEFINE_SWIFT_BETA#define SWIFT_BETA -$$DEFINE_SWIFT_SHIPPED#define SWIFT_SHIPPED - namespace BlackMisc { //! Build configuration @@ -118,29 +105,16 @@ namespace BlackMisc static const QStringList &swiftTeamDefaultServers(); //! End of lifetime - static const QDateTime &getEol() - { - static const QString eol(\"$$BLACK_EOL\"); - static const QDateTime dt(eol.isEmpty() ? QDateTime() : QDateTime::fromString(eol, \"yyyyMMdd\")); - return dt; - } + static const QDateTime &getEol(); //! Lifetime ended? static bool isLifetimeExpired(); //! Vatsim client id - static int vatsimClientId() - { - static const int id { $$VATSIM_CLIENT_ID }; - return id; - } + static int vatsimClientId(); //! Vatsim client key - static const QString &vatsimPrivateKey() - { - static const auto pk = QString { \"$$VATSIM_CLIENT_PRIVATE_KEY\" }; - return pk; - } + static const QString &vatsimPrivateKey(); }; //! Version @@ -148,21 +122,16 @@ namespace BlackMisc { public: //! Version info - static const QString &version() - { - static const QString version(\"$$BLACK_VERSION\"); - Q_ASSERT(!version.isEmpty()); - return version; - } + static const QString &version(); //! Version major - static int versionMajor() { return $$BLACK_VER_MAJ; } + static int versionMajor(); //! Version minor - static int versionMinor() { return $$BLACK_VER_MIN; } + static int versionMinor(); //! Version patch - static int versionPatch() { return $$BLACK_VER_PAT; } + static int versionPatch(); //! Is the given string representing a newer version? static bool isNewerVersion(const QString &versionString);