Skip to content

Commit c7779e1

Browse files
committed
refactor: Clean up build config
1 parent fa4c0ba commit c7779e1

File tree

8 files changed

+34
-116
lines changed

8 files changed

+34
-116
lines changed

CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ option(SWIFT_BUILD_EMULATED_PLUGIN "Build Emulated plugin" ON)
4646
cmake_dependent_option(SWIFT_BUILD_MSFS_PLUGIN "Build MSFS plugin" ON WIN32 OFF)
4747
option(SWIFT_MINIFY_DEBUG_SYMBOLS "Minify debug symbols" OFF)
4848

49-
option(SWIFT_BUILD_CORE "Build Core" ON)
50-
option(SWIFT_BUILD_SOUND "Build Sound" ON)
51-
option(SWIFT_BUILD_INPUT "Build Input" ON)
52-
option(SWIFT_BUILD_GUI "Build GUI" ON)
53-
5449
option(SWIFT_USE_CRASHPAD "Use crashpad" OFF)
5550

5651
# VATSIM related options

src/config/buildconfig.cpp

Lines changed: 26 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,8 @@
66
#include "buildconfig.h"
77

88
#include <QCoreApplication>
9-
#include <QDateTime>
10-
#include <QDir>
11-
#include <QFile>
12-
#include <QFileInfo>
139
#include <QLocale>
1410
#include <QOperatingSystemVersion>
15-
#include <QStandardPaths>
16-
#include <QStringBuilder>
1711
#include <QStringList>
1812
#include <QSysInfo>
1913
#include <QtGlobal>
@@ -38,25 +32,12 @@ namespace swift::config
3832
return s;
3933
}
4034

41-
bool CBuildConfig::isKnownExecutableName(const QString &executable)
42-
{
43-
return executable == CBuildConfig::swiftCoreExecutableName() ||
44-
executable == CBuildConfig::swiftDataExecutableName() ||
45-
executable == CBuildConfig::swiftGuiExecutableName();
46-
}
47-
48-
bool CBuildConfig::isRunningOnWindows10()
49-
{
50-
if (!CBuildConfig::isRunningOnWindowsNtPlatform()) { return false; }
51-
return (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows10);
52-
}
53-
5435
const QString &CBuildConfig::getPlatformString()
5536
{
5637
static const QString p([] {
57-
if (CBuildConfig::isRunningOnLinuxPlatform()) return QString("Linux");
58-
if (CBuildConfig::isRunningOnMacOSPlatform()) return QString("MacOS");
59-
if (CBuildConfig::isRunningOnWindowsNtPlatform())
38+
if constexpr (CBuildConfig::isRunningOnLinuxPlatform()) return QString("Linux");
39+
if constexpr (CBuildConfig::isRunningOnMacOSPlatform()) return QString("MacOS");
40+
if constexpr (CBuildConfig::isRunningOnWindowsNtPlatform())
6041
{
6142
if (CBuildConfig::buildWordSize() == 32) return QString("Win32");
6243
if (CBuildConfig::buildWordSize() == 64) return QString("Win64");
@@ -70,7 +51,7 @@ namespace swift::config
7051
{
7152
bool isLocalDeveloperBuildImpl()
7253
{
73-
if (!CBuildConfig::isDebugBuild()) { return false; }
54+
if constexpr (!CBuildConfig::isDebugBuild()) { return false; }
7455
const QString p = QCoreApplication::applicationDirPath().toLower();
7556

7657
// guessing, feel free to add path checks
@@ -91,46 +72,29 @@ namespace swift::config
9172
return v ? QStringLiteral("yes") : QStringLiteral("no");
9273
}
9374

94-
const QString &CBuildConfig::compiledWithInfo(bool shortVersion)
75+
const QString &CBuildConfig::compiledWithInfoShort()
9576
{
96-
if (shortVersion)
97-
{
98-
static QString infoShort;
99-
if (infoShort.isEmpty())
100-
{
101-
QStringList sl;
102-
if (CBuildConfig::isCompiledWithCore()) { sl << "Core"; }
103-
if (CBuildConfig::isCompiledWithSound()) { sl << "Sound"; }
104-
if (CBuildConfig::isCompiledWithInput()) { sl << "Input"; }
105-
if (CBuildConfig::isCompiledWithGui()) { sl << "Gui"; }
106-
if (CBuildConfig::isCompiledWithFs9Support()) { sl << "FS9"; }
107-
if (CBuildConfig::isCompiledWithFsxSupport()) { sl << "FSX"; }
108-
if (CBuildConfig::isCompiledWithXPlaneSupport()) { sl << "XPlane"; }
109-
if (CBuildConfig::isCompiledWithP3DSupport()) { sl << "P3D"; }
110-
if (CBuildConfig::isCompiledWithFGSupport()) { sl << "FG"; }
111-
infoShort = sl.join(", ");
112-
if (infoShort.isEmpty()) { infoShort = "<none>"; }
113-
}
114-
return infoShort;
115-
}
116-
else
117-
{
118-
static QString infoLong;
119-
if (infoLong.isEmpty())
120-
{
121-
infoLong = infoLong.append("Core: ").append(boolToYesNo(isCompiledWithCore()));
122-
infoLong = infoLong.append(" Input: ").append(boolToYesNo(isCompiledWithInput()));
123-
infoLong = infoLong.append(" Sound: ").append(boolToYesNo(isCompiledWithSound()));
124-
infoLong = infoLong.append(" GUI: ").append(boolToYesNo(isCompiledWithGui()));
125-
126-
infoLong = infoLong.append(" FS9: ").append(boolToYesNo(isCompiledWithFs9Support()));
127-
infoLong = infoLong.append(" FSX: ").append(boolToYesNo(isCompiledWithFsxSupport()));
128-
infoLong = infoLong.append(" P3D: ").append(boolToYesNo(isCompiledWithP3DSupport()));
129-
infoLong = infoLong.append(" XPlane: ").append(boolToYesNo(isCompiledWithXPlaneSupport()));
130-
infoLong = infoLong.append(" FG: ").append(boolToYesNo(isCompiledWithFGSupport()));
131-
}
132-
return infoLong;
133-
}
77+
static QString infoShort;
78+
QStringList sl;
79+
if constexpr (CBuildConfig::isCompiledWithFs9Support()) { sl << "FS9"; }
80+
if constexpr (CBuildConfig::isCompiledWithFsxSupport()) { sl << "FSX"; }
81+
if constexpr (CBuildConfig::isCompiledWithXPlaneSupport()) { sl << "XPlane"; }
82+
if constexpr (CBuildConfig::isCompiledWithP3DSupport()) { sl << "P3D"; }
83+
if constexpr (CBuildConfig::isCompiledWithFGSupport()) { sl << "FG"; }
84+
infoShort = sl.join(", ");
85+
if (infoShort.isEmpty()) { infoShort = "<none>"; }
86+
return infoShort;
87+
}
88+
89+
const QString &CBuildConfig::compiledWithInfoLong()
90+
{
91+
static QString infoLong;
92+
infoLong = infoLong.append(" FS9: ").append(boolToYesNo(isCompiledWithFs9Support()));
93+
infoLong = infoLong.append(" FSX: ").append(boolToYesNo(isCompiledWithFsxSupport()));
94+
infoLong = infoLong.append(" P3D: ").append(boolToYesNo(isCompiledWithP3DSupport()));
95+
infoLong = infoLong.append(" XPlane: ").append(boolToYesNo(isCompiledWithXPlaneSupport()));
96+
infoLong = infoLong.append(" FG: ").append(boolToYesNo(isCompiledWithFGSupport()));
97+
return infoLong;
13498
}
13599

136100
const QString &CBuildConfig::gitHubRepoUrl()

src/config/buildconfig.h

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
#ifndef SWIFT_CONFIG_BUILDCONFIG_H
77
#define SWIFT_CONFIG_BUILDCONFIG_H
88

9-
#include <QDateTime>
10-
#include <QList>
119
#include <QStringList>
1210
#include <QVersionNumber>
1311

@@ -17,15 +15,6 @@ namespace swift::config
1715
class CBuildConfig
1816
{
1917
public:
20-
//! with Core?
21-
static constexpr bool isCompiledWithCore(); // defined in buildconfig_gen.inc.in
22-
23-
//! with Sound?
24-
static constexpr bool isCompiledWithSound(); // defined in buildconfig_gen.inc.in
25-
26-
//! with Input?
27-
static constexpr bool isCompiledWithInput(); // defined in buildconfig_gen.inc.in
28-
2918
//! with FS9 support?
3019
static constexpr bool isCompiledWithFs9Support(); // defined in buildconfig_gen.inc.in
3120

@@ -53,9 +42,6 @@ namespace swift::config
5342
//! with any simulator libraries
5443
static constexpr bool isCompiledWithFlightSimulatorSupport();
5544

56-
//! with GUI?
57-
static constexpr bool isCompiledWithGui(); // defined in buildconfig_gen.inc.in
58-
5945
//! Debug build?
6046
static constexpr bool isDebugBuild();
6147

@@ -68,9 +54,6 @@ namespace swift::config
6854
//! Running on Windows NT platform?
6955
static constexpr bool isRunningOnWindowsNtPlatform();
7056

71-
//! Windows 10
72-
static bool isRunningOnWindows10();
73-
7457
//! Running on MacOS platform?
7558
static constexpr bool isRunningOnMacOSPlatform();
7659

@@ -83,8 +66,11 @@ namespace swift::config
8366
//! Info such as Win32, Win64, MacOs, Linux
8467
static const QString &getPlatformString();
8568

86-
//! Info string about compilation
87-
static const QString &compiledWithInfo(bool shortVersion = true);
69+
//! Info string about compilation (short version)
70+
static const QString &compiledWithInfoShort();
71+
72+
//! Info string about compilation (long version)
73+
static const QString &compiledWithInfoLong();
8874

8975
//! Executable name for swift GUI, no(!) appendix
9076
static const QString &swiftGuiExecutableName();
@@ -95,9 +81,6 @@ namespace swift::config
9581
//! Executable name for swift data, no(!) appendix
9682
static const QString &swiftDataExecutableName();
9783

98-
//! Known executable
99-
static bool isKnownExecutableName(const QString &executable);
100-
10184
#ifdef SWIFT_VATSIM_SUPPORT
10285
//! VATSIM client id
10386
static int vatsimClientId(); // defined in buildconfig_gen.cpp.in
@@ -157,4 +140,4 @@ namespace swift::config
157140
#include "buildconfig.inc"
158141
#undef IN_BUILDCONFIG_H
159142

160-
#endif // guard
143+
#endif // SWIFT_CONFIG_BUILDCONFIG_H

src/config/buildconfig_gen.inc.in

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,6 @@
88
#define SWIFTCONFIG_ON true
99
#define SWIFTCONFIG_OFF false
1010

11-
constexpr bool swift::config::CBuildConfig::isCompiledWithCore()
12-
{
13-
return SWIFTCONFIG_${SWIFT_BUILD_CORE};
14-
}
15-
16-
constexpr bool swift::config::CBuildConfig::isCompiledWithSound()
17-
{
18-
return SWIFTCONFIG_${SWIFT_BUILD_SOUND};
19-
}
20-
21-
constexpr bool swift::config::CBuildConfig::isCompiledWithInput()
22-
{
23-
return SWIFTCONFIG_${SWIFT_BUILD_INPUT};
24-
}
25-
2611
constexpr bool swift::config::CBuildConfig::isCompiledWithFs9Support()
2712
{
2813
return SWIFTCONFIG_${SWIFT_BUILD_FS9_PLUGIN};
@@ -58,11 +43,6 @@ constexpr bool swift::config::CBuildConfig::isCompiledWithMSFSSupport()
5843
return SWIFTCONFIG_${SWIFT_BUILD_MSFS_PLUGIN};
5944
}
6045

61-
constexpr bool swift::config::CBuildConfig::isCompiledWithGui()
62-
{
63-
return SWIFTCONFIG_${SWIFT_BUILD_GUI};
64-
}
65-
6646
constexpr int swift::config::CBuildConfig::versionMajor() { return ${SWIFT_VERSION_MAJOR}; }
6747
constexpr int swift::config::CBuildConfig::versionMinor() { return ${SWIFT_VERSION_MINOR}; }
6848

src/core/application.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,6 @@ namespace swift::core
521521
separator %
522522
u"Windows NT: " %
523523
boolToYesNo(CBuildConfig::isRunningOnWindowsNtPlatform()) %
524-
u" Windows 10: " %
525-
boolToYesNo(CBuildConfig::isRunningOnWindows10()) %
526524
separator %
527525
u"Linux: " %
528526
boolToYesNo(CBuildConfig::isRunningOnLinuxPlatform()) %
@@ -538,7 +536,7 @@ namespace swift::core
538536
u"Build CPU: " %
539537
QSysInfo::buildCpuArchitecture() %
540538
separator %
541-
CBuildConfig::compiledWithInfo(false);
539+
CBuildConfig::compiledWithInfoLong();
542540

543541
if (this->supportsContexts())
544542
{

src/misc/applicationinfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace swift::misc
2020
m_wordSize(CBuildConfig::buildWordSize()),
2121
m_exePath(QCoreApplication::applicationDirPath()),
2222
m_version(CBuildConfig::getVersionString()),
23-
m_compileInfo(CBuildConfig::compiledWithInfo()),
23+
m_compileInfo(CBuildConfig::compiledWithInfoShort()),
2424
m_platform(CBuildConfig::getPlatformString()),
2525
m_process(CProcessInfo::currentProcess())
2626
{

src/misc/swiftdirectories.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ namespace swift::misc
6969
QString CSwiftDirectories::executableFilePath(const QString &executable)
7070
{
7171
Q_ASSERT_X(!executable.isEmpty(), Q_FUNC_INFO, "Missing executable file path");
72-
Q_ASSERT_X(CBuildConfig::isKnownExecutableName(executable), Q_FUNC_INFO, "Unknown exectuable");
7372

7473
QString s = CFileUtils::appendFilePaths(binDirectory(), executable);
7574
if (CBuildConfig::isRunningOnMacOSPlatform())

src/sound/audioutilities.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ namespace swift::sound
219219

220220
void occupyAudioInputDevice()
221221
{
222-
if (!CBuildConfig::isRunningOnWindows10()) { return; }
223222
static const QAudioInput input(QMediaDevices::defaultAudioInput());
224223
}
225224

0 commit comments

Comments
 (0)