Replace qmake variable BLACK_CONFIG with a system based on json files.

The config is loaded from json files by qmake, and we define the qmake
function `swiftConfig` for checking whether a feature is enabled.
This function can be directly used in `buildconfig_gen.cpp.in`,
so the trick with C++ comment tokens in variables is not needed.
This commit is contained in:
Mat Sutcliffe
2018-11-04 17:13:27 +00:00
parent 188d3d914e
commit 82679a3010
25 changed files with 232 additions and 160 deletions

View File

@@ -13,20 +13,20 @@
const QDateTime &BlackConfig::CBuildConfig::getEol()
{
static const QString eol(\"$$BLACK_EOL\"); // config.pri
static const QString eol(\"$$swiftConfig(endOfLife)\"); // config.pri
static const QDateTime dt(eol.isEmpty() ? QDateTime() : QDateTime::fromString(eol, \"yyyyMMdd\"));
return dt;
}
int BlackConfig::CBuildConfig::vatsimClientId()
{
static const int id { $$VATSIM_CLIENT_ID };
static const int id { $$swiftConfig(vatsim.id) };
return id;
}
const QString &BlackConfig::CBuildConfig::vatsimPrivateKey()
{
static const auto pk = QString { \"$$VATSIM_CLIENT_PRIVATE_KEY\" };
static const auto pk = QString { \"$$swiftConfig(vatsim.key)\" };
return pk;
}

View File

@@ -11,108 +11,94 @@
#error This file is only to be included by buildconfig.inc
#endif
$$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_P3D#define WITH_P3D
$$DEFINE_WITH_FS9#define WITH_FS9
$$DEFINE_WITH_FSUIPC#define WITH_FSUIPC
$$DEFINE_WITH_XPLANE#define WITH_XPLANE
$$DEFINE_SWIFT_VATSIM_SUPPORT#define SWIFT_VATSIM_SUPPORT
constexpr bool BlackConfig::CBuildConfig::isCompiledWithBlackCore()
{
#ifdef WITH_BLACKCORE
!!IF swiftConfig(libs.blackcore)
return true;
#else
!!ELSE
return false;
#endif
!!ENDIF
}
constexpr bool BlackConfig::CBuildConfig::isCompiledWithBlackSound()
{
#ifdef WITH_BLACKSOUND
!!IF swiftConfig(libs.blacksound)
return true;
#else
!!ELSE
return false;
#endif
!!ENDIF
}
constexpr bool BlackConfig::CBuildConfig::isCompiledWithBlackInput()
{
#ifdef WITH_BLACKINPUT
!!IF swiftConfig(libs.blackinput)
return true;
#else
!!ELSE
return false;
#endif
!!ENDIF
}
constexpr bool BlackConfig::CBuildConfig::isCompiledWithFs9Support()
{
#ifdef WITH_FS9
!!IF swiftConfig(sims.fs9)
return true;
#else
!!ELSE
return false;
#endif
!!ENDIF
}
constexpr bool BlackConfig::CBuildConfig::isCompiledWithP3DSupport()
{
#ifdef WITH_P3D
!!IF swiftConfig(sims.p3d)
return true;
#else
!!ELSE
return false;
#endif
!!ENDIF
}
constexpr bool BlackConfig::CBuildConfig::isCompiledWithFsxSupport()
{
#ifdef WITH_FSX
!!IF swiftConfig(sims.fsx)
return true;
#else
!!ELSE
return false;
#endif
!!ENDIF
}
constexpr bool BlackConfig::CBuildConfig::isCompiledWithFsuipcSupport()
{
#ifdef WITH_FSUIPC
!!IF swiftConfig(sims.fsuipc)
return true;
#else
!!ELSE
return false;
#endif
!!ENDIF
}
constexpr bool BlackConfig::CBuildConfig::isCompiledWithXPlaneSupport()
{
#ifdef WITH_XPLANE
!!IF swiftConfig(sims.xplane)
return true;
#else
!!ELSE
return false;
#endif
!!ENDIF
}
constexpr bool BlackConfig::CBuildConfig::isCompiledWithGui()
{
#ifdef WITH_BLACKGUI
!!IF swiftConfig(libs.blackgui)
return true;
#else
!!ELSE
return false;
#endif
!!ENDIF
}
constexpr bool BlackConfig::CBuildConfig::isVatsimVersion()
{
#ifdef SWIFT_VATSIM_SUPPORT
!!IF swiftConfig(vatsimSupport)
return true;
#else
!!ELSE
return false;
#endif
!!ENDIF
}
constexpr int BlackConfig::CBuildConfig::versionMajor() { return $$BLACK_VER_MAJ; }