mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
refactor: Clean up build config
This commit is contained in:
@@ -6,14 +6,8 @@
|
||||
#include "buildconfig.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDateTime>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QLocale>
|
||||
#include <QOperatingSystemVersion>
|
||||
#include <QStandardPaths>
|
||||
#include <QStringBuilder>
|
||||
#include <QStringList>
|
||||
#include <QSysInfo>
|
||||
#include <QtGlobal>
|
||||
@@ -38,25 +32,12 @@ namespace swift::config
|
||||
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()
|
||||
{
|
||||
static const QString p([] {
|
||||
if (CBuildConfig::isRunningOnLinuxPlatform()) return QString("Linux");
|
||||
if (CBuildConfig::isRunningOnMacOSPlatform()) return QString("MacOS");
|
||||
if (CBuildConfig::isRunningOnWindowsNtPlatform())
|
||||
if constexpr (CBuildConfig::isRunningOnLinuxPlatform()) return QString("Linux");
|
||||
if constexpr (CBuildConfig::isRunningOnMacOSPlatform()) return QString("MacOS");
|
||||
if constexpr (CBuildConfig::isRunningOnWindowsNtPlatform())
|
||||
{
|
||||
if (CBuildConfig::buildWordSize() == 32) return QString("Win32");
|
||||
if (CBuildConfig::buildWordSize() == 64) return QString("Win64");
|
||||
@@ -70,7 +51,7 @@ namespace swift::config
|
||||
{
|
||||
bool isLocalDeveloperBuildImpl()
|
||||
{
|
||||
if (!CBuildConfig::isDebugBuild()) { return false; }
|
||||
if constexpr (!CBuildConfig::isDebugBuild()) { return false; }
|
||||
const QString p = QCoreApplication::applicationDirPath().toLower();
|
||||
|
||||
// guessing, feel free to add path checks
|
||||
@@ -91,46 +72,29 @@ namespace swift::config
|
||||
return v ? QStringLiteral("yes") : QStringLiteral("no");
|
||||
}
|
||||
|
||||
const QString &CBuildConfig::compiledWithInfo(bool shortVersion)
|
||||
const QString &CBuildConfig::compiledWithInfoShort()
|
||||
{
|
||||
if (shortVersion)
|
||||
{
|
||||
static QString infoShort;
|
||||
if (infoShort.isEmpty())
|
||||
{
|
||||
QStringList sl;
|
||||
if (CBuildConfig::isCompiledWithCore()) { sl << "Core"; }
|
||||
if (CBuildConfig::isCompiledWithSound()) { sl << "Sound"; }
|
||||
if (CBuildConfig::isCompiledWithInput()) { sl << "Input"; }
|
||||
if (CBuildConfig::isCompiledWithGui()) { sl << "Gui"; }
|
||||
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()));
|
||||
static QString infoShort;
|
||||
QStringList sl;
|
||||
if constexpr (CBuildConfig::isCompiledWithFs9Support()) { sl << "FS9"; }
|
||||
if constexpr (CBuildConfig::isCompiledWithFsxSupport()) { sl << "FSX"; }
|
||||
if constexpr (CBuildConfig::isCompiledWithXPlaneSupport()) { sl << "XPlane"; }
|
||||
if constexpr (CBuildConfig::isCompiledWithP3DSupport()) { sl << "P3D"; }
|
||||
if constexpr (CBuildConfig::isCompiledWithFGSupport()) { sl << "FG"; }
|
||||
infoShort = sl.join(", ");
|
||||
if (infoShort.isEmpty()) { infoShort = "<none>"; }
|
||||
return infoShort;
|
||||
}
|
||||
|
||||
infoLong = infoLong.append(" FS9: ").append(boolToYesNo(isCompiledWithFs9Support()));
|
||||
infoLong = infoLong.append(" FSX: ").append(boolToYesNo(isCompiledWithFsxSupport()));
|
||||
infoLong = infoLong.append(" P3D: ").append(boolToYesNo(isCompiledWithP3DSupport()));
|
||||
infoLong = infoLong.append(" XPlane: ").append(boolToYesNo(isCompiledWithXPlaneSupport()));
|
||||
infoLong = infoLong.append(" FG: ").append(boolToYesNo(isCompiledWithFGSupport()));
|
||||
}
|
||||
return infoLong;
|
||||
}
|
||||
const QString &CBuildConfig::compiledWithInfoLong()
|
||||
{
|
||||
static QString infoLong;
|
||||
infoLong = infoLong.append(" FS9: ").append(boolToYesNo(isCompiledWithFs9Support()));
|
||||
infoLong = infoLong.append(" FSX: ").append(boolToYesNo(isCompiledWithFsxSupport()));
|
||||
infoLong = infoLong.append(" P3D: ").append(boolToYesNo(isCompiledWithP3DSupport()));
|
||||
infoLong = infoLong.append(" XPlane: ").append(boolToYesNo(isCompiledWithXPlaneSupport()));
|
||||
infoLong = infoLong.append(" FG: ").append(boolToYesNo(isCompiledWithFGSupport()));
|
||||
return infoLong;
|
||||
}
|
||||
|
||||
const QString &CBuildConfig::gitHubRepoUrl()
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
#ifndef SWIFT_CONFIG_BUILDCONFIG_H
|
||||
#define SWIFT_CONFIG_BUILDCONFIG_H
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QList>
|
||||
#include <QStringList>
|
||||
#include <QVersionNumber>
|
||||
|
||||
@@ -17,15 +15,6 @@ namespace swift::config
|
||||
class CBuildConfig
|
||||
{
|
||||
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?
|
||||
static constexpr bool isCompiledWithFs9Support(); // defined in buildconfig_gen.inc.in
|
||||
|
||||
@@ -53,9 +42,6 @@ namespace swift::config
|
||||
//! with any simulator libraries
|
||||
static constexpr bool isCompiledWithFlightSimulatorSupport();
|
||||
|
||||
//! with GUI?
|
||||
static constexpr bool isCompiledWithGui(); // defined in buildconfig_gen.inc.in
|
||||
|
||||
//! Debug build?
|
||||
static constexpr bool isDebugBuild();
|
||||
|
||||
@@ -68,9 +54,6 @@ namespace swift::config
|
||||
//! Running on Windows NT platform?
|
||||
static constexpr bool isRunningOnWindowsNtPlatform();
|
||||
|
||||
//! Windows 10
|
||||
static bool isRunningOnWindows10();
|
||||
|
||||
//! Running on MacOS platform?
|
||||
static constexpr bool isRunningOnMacOSPlatform();
|
||||
|
||||
@@ -83,8 +66,11 @@ namespace swift::config
|
||||
//! Info such as Win32, Win64, MacOs, Linux
|
||||
static const QString &getPlatformString();
|
||||
|
||||
//! Info string about compilation
|
||||
static const QString &compiledWithInfo(bool shortVersion = true);
|
||||
//! Info string about compilation (short version)
|
||||
static const QString &compiledWithInfoShort();
|
||||
|
||||
//! Info string about compilation (long version)
|
||||
static const QString &compiledWithInfoLong();
|
||||
|
||||
//! Executable name for swift GUI, no(!) appendix
|
||||
static const QString &swiftGuiExecutableName();
|
||||
@@ -95,9 +81,6 @@ namespace swift::config
|
||||
//! Executable name for swift data, no(!) appendix
|
||||
static const QString &swiftDataExecutableName();
|
||||
|
||||
//! Known executable
|
||||
static bool isKnownExecutableName(const QString &executable);
|
||||
|
||||
#ifdef SWIFT_VATSIM_SUPPORT
|
||||
//! VATSIM client id
|
||||
static int vatsimClientId(); // defined in buildconfig_gen.cpp.in
|
||||
@@ -157,4 +140,4 @@ namespace swift::config
|
||||
#include "buildconfig.inc"
|
||||
#undef IN_BUILDCONFIG_H
|
||||
|
||||
#endif // guard
|
||||
#endif // SWIFT_CONFIG_BUILDCONFIG_H
|
||||
|
||||
@@ -8,21 +8,6 @@
|
||||
#define SWIFTCONFIG_ON true
|
||||
#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()
|
||||
{
|
||||
return SWIFTCONFIG_${SWIFT_BUILD_FS9_PLUGIN};
|
||||
@@ -58,11 +43,6 @@ constexpr bool swift::config::CBuildConfig::isCompiledWithMSFSSupport()
|
||||
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::versionMinor() { return ${SWIFT_VERSION_MINOR}; }
|
||||
|
||||
|
||||
@@ -521,8 +521,6 @@ namespace swift::core
|
||||
separator %
|
||||
u"Windows NT: " %
|
||||
boolToYesNo(CBuildConfig::isRunningOnWindowsNtPlatform()) %
|
||||
u" Windows 10: " %
|
||||
boolToYesNo(CBuildConfig::isRunningOnWindows10()) %
|
||||
separator %
|
||||
u"Linux: " %
|
||||
boolToYesNo(CBuildConfig::isRunningOnLinuxPlatform()) %
|
||||
@@ -538,7 +536,7 @@ namespace swift::core
|
||||
u"Build CPU: " %
|
||||
QSysInfo::buildCpuArchitecture() %
|
||||
separator %
|
||||
CBuildConfig::compiledWithInfo(false);
|
||||
CBuildConfig::compiledWithInfoLong();
|
||||
|
||||
if (this->supportsContexts())
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace swift::misc
|
||||
m_wordSize(CBuildConfig::buildWordSize()),
|
||||
m_exePath(QCoreApplication::applicationDirPath()),
|
||||
m_version(CBuildConfig::getVersionString()),
|
||||
m_compileInfo(CBuildConfig::compiledWithInfo()),
|
||||
m_compileInfo(CBuildConfig::compiledWithInfoShort()),
|
||||
m_platform(CBuildConfig::getPlatformString()),
|
||||
m_process(CProcessInfo::currentProcess())
|
||||
{
|
||||
|
||||
@@ -69,7 +69,6 @@ namespace swift::misc
|
||||
QString CSwiftDirectories::executableFilePath(const QString &executable)
|
||||
{
|
||||
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);
|
||||
if (CBuildConfig::isRunningOnMacOSPlatform())
|
||||
|
||||
@@ -219,7 +219,6 @@ namespace swift::sound
|
||||
|
||||
void occupyAudioInputDevice()
|
||||
{
|
||||
if (!CBuildConfig::isRunningOnWindows10()) { return; }
|
||||
static const QAudioInput input(QMediaDevices::defaultAudioInput());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user