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)
This commit is contained in:
Klaus Basan
2016-04-05 01:16:38 +02:00
parent 17ce1eef34
commit 0343bfb521
4 changed files with 196 additions and 168 deletions

View File

@@ -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

View File

@@ -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 = "<none>"; }
}
@@ -335,8 +255,6 @@ namespace BlackMisc
return false;
}
QList<int> CVersion::getVersionParts(const QString &versionString)
{
QStringList parts = versionString.split('.');
@@ -349,7 +267,6 @@ namespace BlackMisc
}
return partsInt;
}
} // ns
//! \endcond

View File

@@ -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 <QString>
#include <QDateTime>
$$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; }

View File

@@ -12,23 +12,10 @@
#ifndef BLACKMISC_BUILDCONFIG_H
#define BLACKMISC_BUILDCONFIG_H
#include \"blackmisc/blackmiscexport.h\"
#include "blackmisc/blackmiscexport.h"
#include <QString>
#include <QDateTime>
$$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);