refactor: Clean up build config

This commit is contained in:
Lars Toenning
2024-11-16 12:00:49 +01:00
parent fa4c0bacbf
commit c7779e1461
8 changed files with 33 additions and 115 deletions

View File

@@ -46,11 +46,6 @@ option(SWIFT_BUILD_EMULATED_PLUGIN "Build Emulated plugin" ON)
cmake_dependent_option(SWIFT_BUILD_MSFS_PLUGIN "Build MSFS plugin" ON WIN32 OFF) cmake_dependent_option(SWIFT_BUILD_MSFS_PLUGIN "Build MSFS plugin" ON WIN32 OFF)
option(SWIFT_MINIFY_DEBUG_SYMBOLS "Minify debug symbols" OFF) option(SWIFT_MINIFY_DEBUG_SYMBOLS "Minify debug symbols" OFF)
option(SWIFT_BUILD_CORE "Build Core" ON)
option(SWIFT_BUILD_SOUND "Build Sound" ON)
option(SWIFT_BUILD_INPUT "Build Input" ON)
option(SWIFT_BUILD_GUI "Build GUI" ON)
option(SWIFT_USE_CRASHPAD "Use crashpad" OFF) option(SWIFT_USE_CRASHPAD "Use crashpad" OFF)
# VATSIM related options # VATSIM related options

View File

@@ -6,14 +6,8 @@
#include "buildconfig.h" #include "buildconfig.h"
#include <QCoreApplication> #include <QCoreApplication>
#include <QDateTime>
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <QLocale> #include <QLocale>
#include <QOperatingSystemVersion> #include <QOperatingSystemVersion>
#include <QStandardPaths>
#include <QStringBuilder>
#include <QStringList> #include <QStringList>
#include <QSysInfo> #include <QSysInfo>
#include <QtGlobal> #include <QtGlobal>
@@ -38,25 +32,12 @@ namespace swift::config
return s; return s;
} }
bool CBuildConfig::isKnownExecutableName(const QString &executable)
{
return executable == CBuildConfig::swiftCoreExecutableName() ||
executable == CBuildConfig::swiftDataExecutableName() ||
executable == CBuildConfig::swiftGuiExecutableName();
}
bool CBuildConfig::isRunningOnWindows10()
{
if (!CBuildConfig::isRunningOnWindowsNtPlatform()) { return false; }
return (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows10);
}
const QString &CBuildConfig::getPlatformString() const QString &CBuildConfig::getPlatformString()
{ {
static const QString p([] { static const QString p([] {
if (CBuildConfig::isRunningOnLinuxPlatform()) return QString("Linux"); if constexpr (CBuildConfig::isRunningOnLinuxPlatform()) return QString("Linux");
if (CBuildConfig::isRunningOnMacOSPlatform()) return QString("MacOS"); if constexpr (CBuildConfig::isRunningOnMacOSPlatform()) return QString("MacOS");
if (CBuildConfig::isRunningOnWindowsNtPlatform()) if constexpr (CBuildConfig::isRunningOnWindowsNtPlatform())
{ {
if (CBuildConfig::buildWordSize() == 32) return QString("Win32"); if (CBuildConfig::buildWordSize() == 32) return QString("Win32");
if (CBuildConfig::buildWordSize() == 64) return QString("Win64"); if (CBuildConfig::buildWordSize() == 64) return QString("Win64");
@@ -70,7 +51,7 @@ namespace swift::config
{ {
bool isLocalDeveloperBuildImpl() bool isLocalDeveloperBuildImpl()
{ {
if (!CBuildConfig::isDebugBuild()) { return false; } if constexpr (!CBuildConfig::isDebugBuild()) { return false; }
const QString p = QCoreApplication::applicationDirPath().toLower(); const QString p = QCoreApplication::applicationDirPath().toLower();
// guessing, feel free to add path checks // guessing, feel free to add path checks
@@ -91,46 +72,29 @@ namespace swift::config
return v ? QStringLiteral("yes") : QStringLiteral("no"); return v ? QStringLiteral("yes") : QStringLiteral("no");
} }
const QString &CBuildConfig::compiledWithInfo(bool shortVersion) const QString &CBuildConfig::compiledWithInfoShort()
{ {
if (shortVersion) static QString infoShort;
{ QStringList sl;
static QString infoShort; if constexpr (CBuildConfig::isCompiledWithFs9Support()) { sl << "FS9"; }
if (infoShort.isEmpty()) if constexpr (CBuildConfig::isCompiledWithFsxSupport()) { sl << "FSX"; }
{ if constexpr (CBuildConfig::isCompiledWithXPlaneSupport()) { sl << "XPlane"; }
QStringList sl; if constexpr (CBuildConfig::isCompiledWithP3DSupport()) { sl << "P3D"; }
if (CBuildConfig::isCompiledWithCore()) { sl << "Core"; } if constexpr (CBuildConfig::isCompiledWithFGSupport()) { sl << "FG"; }
if (CBuildConfig::isCompiledWithSound()) { sl << "Sound"; } infoShort = sl.join(", ");
if (CBuildConfig::isCompiledWithInput()) { sl << "Input"; } if (infoShort.isEmpty()) { infoShort = "<none>"; }
if (CBuildConfig::isCompiledWithGui()) { sl << "Gui"; } return infoShort;
if (CBuildConfig::isCompiledWithFs9Support()) { sl << "FS9"; } }
if (CBuildConfig::isCompiledWithFsxSupport()) { sl << "FSX"; }
if (CBuildConfig::isCompiledWithXPlaneSupport()) { sl << "XPlane"; }
if (CBuildConfig::isCompiledWithP3DSupport()) { sl << "P3D"; }
if (CBuildConfig::isCompiledWithFGSupport()) { sl << "FG"; }
infoShort = sl.join(", ");
if (infoShort.isEmpty()) { infoShort = "<none>"; }
}
return infoShort;
}
else
{
static QString infoLong;
if (infoLong.isEmpty())
{
infoLong = infoLong.append("Core: ").append(boolToYesNo(isCompiledWithCore()));
infoLong = infoLong.append(" Input: ").append(boolToYesNo(isCompiledWithInput()));
infoLong = infoLong.append(" Sound: ").append(boolToYesNo(isCompiledWithSound()));
infoLong = infoLong.append(" GUI: ").append(boolToYesNo(isCompiledWithGui()));
infoLong = infoLong.append(" FS9: ").append(boolToYesNo(isCompiledWithFs9Support())); const QString &CBuildConfig::compiledWithInfoLong()
infoLong = infoLong.append(" FSX: ").append(boolToYesNo(isCompiledWithFsxSupport())); {
infoLong = infoLong.append(" P3D: ").append(boolToYesNo(isCompiledWithP3DSupport())); static QString infoLong;
infoLong = infoLong.append(" XPlane: ").append(boolToYesNo(isCompiledWithXPlaneSupport())); infoLong = infoLong.append(" FS9: ").append(boolToYesNo(isCompiledWithFs9Support()));
infoLong = infoLong.append(" FG: ").append(boolToYesNo(isCompiledWithFGSupport())); infoLong = infoLong.append(" FSX: ").append(boolToYesNo(isCompiledWithFsxSupport()));
} infoLong = infoLong.append(" P3D: ").append(boolToYesNo(isCompiledWithP3DSupport()));
return infoLong; infoLong = infoLong.append(" XPlane: ").append(boolToYesNo(isCompiledWithXPlaneSupport()));
} infoLong = infoLong.append(" FG: ").append(boolToYesNo(isCompiledWithFGSupport()));
return infoLong;
} }
const QString &CBuildConfig::gitHubRepoUrl() const QString &CBuildConfig::gitHubRepoUrl()

View File

@@ -6,8 +6,6 @@
#ifndef SWIFT_CONFIG_BUILDCONFIG_H #ifndef SWIFT_CONFIG_BUILDCONFIG_H
#define SWIFT_CONFIG_BUILDCONFIG_H #define SWIFT_CONFIG_BUILDCONFIG_H
#include <QDateTime>
#include <QList>
#include <QStringList> #include <QStringList>
#include <QVersionNumber> #include <QVersionNumber>
@@ -17,15 +15,6 @@ namespace swift::config
class CBuildConfig class CBuildConfig
{ {
public: public:
//! with Core?
static constexpr bool isCompiledWithCore(); // defined in buildconfig_gen.inc.in
//! with Sound?
static constexpr bool isCompiledWithSound(); // defined in buildconfig_gen.inc.in
//! with Input?
static constexpr bool isCompiledWithInput(); // defined in buildconfig_gen.inc.in
//! with FS9 support? //! with FS9 support?
static constexpr bool isCompiledWithFs9Support(); // defined in buildconfig_gen.inc.in static constexpr bool isCompiledWithFs9Support(); // defined in buildconfig_gen.inc.in
@@ -53,9 +42,6 @@ namespace swift::config
//! with any simulator libraries //! with any simulator libraries
static constexpr bool isCompiledWithFlightSimulatorSupport(); static constexpr bool isCompiledWithFlightSimulatorSupport();
//! with GUI?
static constexpr bool isCompiledWithGui(); // defined in buildconfig_gen.inc.in
//! Debug build? //! Debug build?
static constexpr bool isDebugBuild(); static constexpr bool isDebugBuild();
@@ -68,9 +54,6 @@ namespace swift::config
//! Running on Windows NT platform? //! Running on Windows NT platform?
static constexpr bool isRunningOnWindowsNtPlatform(); static constexpr bool isRunningOnWindowsNtPlatform();
//! Windows 10
static bool isRunningOnWindows10();
//! Running on MacOS platform? //! Running on MacOS platform?
static constexpr bool isRunningOnMacOSPlatform(); static constexpr bool isRunningOnMacOSPlatform();
@@ -83,8 +66,11 @@ namespace swift::config
//! Info such as Win32, Win64, MacOs, Linux //! Info such as Win32, Win64, MacOs, Linux
static const QString &getPlatformString(); static const QString &getPlatformString();
//! Info string about compilation //! Info string about compilation (short version)
static const QString &compiledWithInfo(bool shortVersion = true); static const QString &compiledWithInfoShort();
//! Info string about compilation (long version)
static const QString &compiledWithInfoLong();
//! Executable name for swift GUI, no(!) appendix //! Executable name for swift GUI, no(!) appendix
static const QString &swiftGuiExecutableName(); static const QString &swiftGuiExecutableName();
@@ -95,9 +81,6 @@ namespace swift::config
//! Executable name for swift data, no(!) appendix //! Executable name for swift data, no(!) appendix
static const QString &swiftDataExecutableName(); static const QString &swiftDataExecutableName();
//! Known executable
static bool isKnownExecutableName(const QString &executable);
#ifdef SWIFT_VATSIM_SUPPORT #ifdef SWIFT_VATSIM_SUPPORT
//! VATSIM client id //! VATSIM client id
static int vatsimClientId(); // defined in buildconfig_gen.cpp.in static int vatsimClientId(); // defined in buildconfig_gen.cpp.in
@@ -157,4 +140,4 @@ namespace swift::config
#include "buildconfig.inc" #include "buildconfig.inc"
#undef IN_BUILDCONFIG_H #undef IN_BUILDCONFIG_H
#endif // guard #endif // SWIFT_CONFIG_BUILDCONFIG_H

View File

@@ -8,21 +8,6 @@
#define SWIFTCONFIG_ON true #define SWIFTCONFIG_ON true
#define SWIFTCONFIG_OFF false #define SWIFTCONFIG_OFF false
constexpr bool swift::config::CBuildConfig::isCompiledWithCore()
{
return SWIFTCONFIG_${SWIFT_BUILD_CORE};
}
constexpr bool swift::config::CBuildConfig::isCompiledWithSound()
{
return SWIFTCONFIG_${SWIFT_BUILD_SOUND};
}
constexpr bool swift::config::CBuildConfig::isCompiledWithInput()
{
return SWIFTCONFIG_${SWIFT_BUILD_INPUT};
}
constexpr bool swift::config::CBuildConfig::isCompiledWithFs9Support() constexpr bool swift::config::CBuildConfig::isCompiledWithFs9Support()
{ {
return SWIFTCONFIG_${SWIFT_BUILD_FS9_PLUGIN}; return SWIFTCONFIG_${SWIFT_BUILD_FS9_PLUGIN};
@@ -58,11 +43,6 @@ constexpr bool swift::config::CBuildConfig::isCompiledWithMSFSSupport()
return SWIFTCONFIG_${SWIFT_BUILD_MSFS_PLUGIN}; return SWIFTCONFIG_${SWIFT_BUILD_MSFS_PLUGIN};
} }
constexpr bool swift::config::CBuildConfig::isCompiledWithGui()
{
return SWIFTCONFIG_${SWIFT_BUILD_GUI};
}
constexpr int swift::config::CBuildConfig::versionMajor() { return ${SWIFT_VERSION_MAJOR}; } constexpr int swift::config::CBuildConfig::versionMajor() { return ${SWIFT_VERSION_MAJOR}; }
constexpr int swift::config::CBuildConfig::versionMinor() { return ${SWIFT_VERSION_MINOR}; } constexpr int swift::config::CBuildConfig::versionMinor() { return ${SWIFT_VERSION_MINOR}; }

View File

@@ -521,8 +521,6 @@ namespace swift::core
separator % separator %
u"Windows NT: " % u"Windows NT: " %
boolToYesNo(CBuildConfig::isRunningOnWindowsNtPlatform()) % boolToYesNo(CBuildConfig::isRunningOnWindowsNtPlatform()) %
u" Windows 10: " %
boolToYesNo(CBuildConfig::isRunningOnWindows10()) %
separator % separator %
u"Linux: " % u"Linux: " %
boolToYesNo(CBuildConfig::isRunningOnLinuxPlatform()) % boolToYesNo(CBuildConfig::isRunningOnLinuxPlatform()) %
@@ -538,7 +536,7 @@ namespace swift::core
u"Build CPU: " % u"Build CPU: " %
QSysInfo::buildCpuArchitecture() % QSysInfo::buildCpuArchitecture() %
separator % separator %
CBuildConfig::compiledWithInfo(false); CBuildConfig::compiledWithInfoLong();
if (this->supportsContexts()) if (this->supportsContexts())
{ {

View File

@@ -20,7 +20,7 @@ namespace swift::misc
m_wordSize(CBuildConfig::buildWordSize()), m_wordSize(CBuildConfig::buildWordSize()),
m_exePath(QCoreApplication::applicationDirPath()), m_exePath(QCoreApplication::applicationDirPath()),
m_version(CBuildConfig::getVersionString()), m_version(CBuildConfig::getVersionString()),
m_compileInfo(CBuildConfig::compiledWithInfo()), m_compileInfo(CBuildConfig::compiledWithInfoShort()),
m_platform(CBuildConfig::getPlatformString()), m_platform(CBuildConfig::getPlatformString()),
m_process(CProcessInfo::currentProcess()) m_process(CProcessInfo::currentProcess())
{ {

View File

@@ -69,7 +69,6 @@ namespace swift::misc
QString CSwiftDirectories::executableFilePath(const QString &executable) QString CSwiftDirectories::executableFilePath(const QString &executable)
{ {
Q_ASSERT_X(!executable.isEmpty(), Q_FUNC_INFO, "Missing executable file path"); Q_ASSERT_X(!executable.isEmpty(), Q_FUNC_INFO, "Missing executable file path");
Q_ASSERT_X(CBuildConfig::isKnownExecutableName(executable), Q_FUNC_INFO, "Unknown exectuable");
QString s = CFileUtils::appendFilePaths(binDirectory(), executable); QString s = CFileUtils::appendFilePaths(binDirectory(), executable);
if (CBuildConfig::isRunningOnMacOSPlatform()) if (CBuildConfig::isRunningOnMacOSPlatform())

View File

@@ -219,7 +219,6 @@ namespace swift::sound
void occupyAudioInputDevice() void occupyAudioInputDevice()
{ {
if (!CBuildConfig::isRunningOnWindows10()) { return; }
static const QAudioInput input(QMediaDevices::defaultAudioInput()); static const QAudioInput input(QMediaDevices::defaultAudioInput());
} }