mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 07:15:35 +08:00
Added constexpr specifier where possible in CBuildConfig.
This necessitated moving some function definitions into a .inc file that is included by buildconfig.h, as constexpr functions must be defined in the header. This new file is added to the list of QMAKE_SUBSTITUTES.
This commit is contained in:
@@ -79,3 +79,6 @@ blackconfig {
|
||||
addStaticLibraryDependency(blackconfig)
|
||||
LIBS *= -lblackconfig
|
||||
}
|
||||
|
||||
# to include buildconfig_gen.inc
|
||||
INCLUDEPATH *= $$BuildRoot/generated
|
||||
|
||||
@@ -4,10 +4,15 @@ TARGET = blackconfig
|
||||
TEMPLATE = lib
|
||||
CONFIG += staticlib
|
||||
|
||||
buildconfig_gen.input = buildconfig_gen.cpp.in
|
||||
buildconfig_gen.output = $$BuildRoot/buildconfig_gen.cpp
|
||||
GENERATED_SOURCES += $$BuildRoot/buildconfig_gen.cpp
|
||||
QMAKE_SUBSTITUTES += buildconfig_gen
|
||||
buildconfig_gen.cpp.input = buildconfig_gen.cpp.in
|
||||
buildconfig_gen.cpp.output = $$BuildRoot/generated/buildconfig_gen.cpp
|
||||
|
||||
buildconfig_gen.inc.input = buildconfig_gen.inc.in
|
||||
buildconfig_gen.inc.output = $$BuildRoot/generated/buildconfig_gen.inc
|
||||
|
||||
GENERATED_SOURCES += $$BuildRoot/generated/buildconfig_gen.cpp
|
||||
GENERATED_FILES += $$BuildRoot/generated/buildconfig_gen.inc
|
||||
QMAKE_SUBSTITUTES += buildconfig_gen.cpp buildconfig_gen.inc
|
||||
|
||||
INCLUDEPATH += ..
|
||||
|
||||
@@ -15,7 +20,7 @@ DEFINES += LOG_IN_FILE
|
||||
HEADERS += *.h
|
||||
SOURCES += *.cpp
|
||||
DESTDIR = $$DestRoot/lib
|
||||
OTHER_FILES += buildconfig_gen.cpp.in
|
||||
OTHER_FILES += buildconfig_gen.cpp.in buildconfig_gen.inc.in
|
||||
|
||||
win32: GIT_BIN = $$system($$(SYSTEMROOT)\system32\where git 2> nul)
|
||||
else: GIT_BIN = $$system(which git 2> /dev/null)
|
||||
|
||||
@@ -24,16 +24,6 @@
|
||||
|
||||
namespace BlackConfig
|
||||
{
|
||||
bool CBuildConfig::isCompiledWithMsFlightSimulatorSupport()
|
||||
{
|
||||
return CBuildConfig::isCompiledWithFs9Support() || CBuildConfig::isCompiledWithFsxSupport() || CBuildConfig::isCompiledWithP3DSupport();
|
||||
}
|
||||
|
||||
bool CBuildConfig::isCompiledWithFlightSimulatorSupport()
|
||||
{
|
||||
return CBuildConfig::isCompiledWithFsxSupport() || CBuildConfig::isCompiledWithXPlaneSupport();
|
||||
}
|
||||
|
||||
const QString &CBuildConfig::swiftGuiExecutableName()
|
||||
{
|
||||
static const QString s("swiftguistd");
|
||||
@@ -59,16 +49,6 @@ namespace BlackConfig
|
||||
executable == CBuildConfig::swiftGuiExecutableName();
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
bool CBuildConfig::isRunningOnWindows10()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
@@ -80,29 +60,6 @@ namespace BlackConfig
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CBuildConfig::isRunningOnMacOSPlatform()
|
||||
{
|
||||
#ifdef Q_OS_MACOS
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CBuildConfig::isRunningOnLinuxPlatform()
|
||||
{
|
||||
#ifdef Q_OS_LINUX
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CBuildConfig::isRunningOnUnixPlatform()
|
||||
{
|
||||
return CBuildConfig::isRunningOnMacOSPlatform() || CBuildConfig::isRunningOnLinuxPlatform();
|
||||
}
|
||||
|
||||
const QString &CBuildConfig::getPlatformString()
|
||||
{
|
||||
static const QString p([]
|
||||
@@ -119,24 +76,6 @@ namespace BlackConfig
|
||||
return p;
|
||||
}
|
||||
|
||||
bool CBuildConfig::isDebugBuild()
|
||||
{
|
||||
#ifdef QT_DEBUG
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CBuildConfig::isReleaseBuild()
|
||||
{
|
||||
#ifdef QT_NO_DEBUG
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace Private
|
||||
{
|
||||
bool isLocalDeveloperBuildImpl()
|
||||
|
||||
@@ -24,64 +24,64 @@ namespace BlackConfig
|
||||
{
|
||||
public:
|
||||
//! with BlackCore?
|
||||
static bool isCompiledWithBlackCore(); // defined in buildconfig_gen.cpp.in
|
||||
static constexpr bool isCompiledWithBlackCore(); // defined in buildconfig_gen.inc.in
|
||||
|
||||
//! with BlackSound?
|
||||
static bool isCompiledWithBlackSound(); // defined in buildconfig_gen.cpp.in
|
||||
static constexpr bool isCompiledWithBlackSound(); // defined in buildconfig_gen.inc.in
|
||||
|
||||
//! with BlackInput?
|
||||
static bool isCompiledWithBlackInput(); // defined in buildconfig_gen.cpp.in
|
||||
static constexpr bool isCompiledWithBlackInput(); // defined in buildconfig_gen.inc.in
|
||||
|
||||
//! with FS9 support?
|
||||
static bool isCompiledWithFs9Support(); // defined in buildconfig_gen.cpp.in
|
||||
static constexpr bool isCompiledWithFs9Support(); // defined in buildconfig_gen.inc.in
|
||||
|
||||
//! with FSX support?
|
||||
static bool isCompiledWithFsxSupport(); // defined in buildconfig_gen.cpp.in
|
||||
static constexpr bool isCompiledWithFsxSupport(); // defined in buildconfig_gen.inc.in
|
||||
|
||||
//! with P3D support?
|
||||
static bool isCompiledWithP3DSupport(); // defined in buildconfig_gen.cpp.in
|
||||
static constexpr bool isCompiledWithP3DSupport(); // defined in buildconfig_gen.inc.in
|
||||
|
||||
//! with Fsuipc support?
|
||||
static bool isCompiledWithFsuipcSupport(); // defined in buildconfig_gen.cpp.in
|
||||
static constexpr bool isCompiledWithFsuipcSupport(); // defined in buildconfig_gen.inc.in
|
||||
|
||||
//! Compiled with any MS Flight Simulator support (P3D, FSX, FS9)
|
||||
static bool isCompiledWithMsFlightSimulatorSupport();
|
||||
static constexpr bool isCompiledWithMsFlightSimulatorSupport();
|
||||
|
||||
//! with XPlane support?
|
||||
static bool isCompiledWithXPlaneSupport(); // defined in buildconfig_gen.cpp.in
|
||||
static constexpr bool isCompiledWithXPlaneSupport(); // defined in buildconfig_gen.inc.in
|
||||
|
||||
//! with any simulator libraries
|
||||
static bool isCompiledWithFlightSimulatorSupport();
|
||||
static constexpr bool isCompiledWithFlightSimulatorSupport();
|
||||
|
||||
//! with GUI?
|
||||
static bool isCompiledWithGui(); // defined in buildconfig_gen.cpp.in
|
||||
static constexpr bool isCompiledWithGui(); // defined in buildconfig_gen.inc.in
|
||||
|
||||
//! Debug build?
|
||||
static bool isDebugBuild();
|
||||
static constexpr bool isDebugBuild();
|
||||
|
||||
//! Release build?
|
||||
static bool isReleaseBuild();
|
||||
static constexpr bool isReleaseBuild();
|
||||
|
||||
//! Local build for developers
|
||||
static bool isLocalDeveloperDebugBuild();
|
||||
|
||||
//! Vatsim enabled version?
|
||||
static bool isVatsimVersion(); // defined in buildconfig_gen.cpp.in
|
||||
static constexpr bool isVatsimVersion(); // defined in buildconfig_gen.inc.in
|
||||
|
||||
//! Running on Windows NT platform?
|
||||
static bool isRunningOnWindowsNtPlatform();
|
||||
static constexpr bool isRunningOnWindowsNtPlatform();
|
||||
|
||||
//! Windows 10
|
||||
static bool isRunningOnWindows10();
|
||||
|
||||
//! Running on MacOS platform?
|
||||
static bool isRunningOnMacOSPlatform();
|
||||
static constexpr bool isRunningOnMacOSPlatform();
|
||||
|
||||
//! Running on Linux platform?
|
||||
static bool isRunningOnLinuxPlatform();
|
||||
static constexpr bool isRunningOnLinuxPlatform();
|
||||
|
||||
//! Running on Unix (Linux or Mac OS X) platform
|
||||
static bool isRunningOnUnixPlatform();
|
||||
static constexpr bool isRunningOnUnixPlatform();
|
||||
|
||||
//! Info such as Win32, Win64, MacOs, Linux
|
||||
static const QString &getPlatformString();
|
||||
@@ -149,14 +149,19 @@ namespace BlackConfig
|
||||
|
||||
private:
|
||||
//! Major version
|
||||
static int versionMajor(); // defined in buildconfig_gen.cpp.in
|
||||
static constexpr int versionMajor(); // defined in buildconfig_gen.inc.in
|
||||
|
||||
//! Minor version
|
||||
static int versionMinor(); // defined in buildconfig_gen.cpp.in
|
||||
static constexpr int versionMinor(); // defined in buildconfig_gen.inc.in
|
||||
|
||||
//! Patch version
|
||||
static int versionMicro(); // defined in buildconfig_gen.cpp.in
|
||||
static constexpr int versionMicro(); // defined in buildconfig_gen.inc.in
|
||||
};
|
||||
} // ns
|
||||
|
||||
// inline definitions of constexpr methods
|
||||
#define IN_BUILDCONFIG_H
|
||||
#include "buildconfig.inc"
|
||||
#undef IN_BUILDCONFIG_H
|
||||
|
||||
#endif // guard
|
||||
|
||||
82
src/blackconfig/buildconfig.inc
Normal file
82
src/blackconfig/buildconfig.inc
Normal file
@@ -0,0 +1,82 @@
|
||||
/* Copyright (C) 2018
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef IN_BUILDCONFIG_H
|
||||
#error This file is only to be included by buildconfig.h
|
||||
#endif
|
||||
|
||||
// in-line definitions with qmake substitutions
|
||||
#include "buildconfig_gen.inc"
|
||||
|
||||
//! \cond PRIVATE
|
||||
|
||||
namespace BlackConfig
|
||||
{
|
||||
constexpr bool CBuildConfig::isCompiledWithMsFlightSimulatorSupport()
|
||||
{
|
||||
return CBuildConfig::isCompiledWithFs9Support() || CBuildConfig::isCompiledWithFsxSupport() || CBuildConfig::isCompiledWithP3DSupport();
|
||||
}
|
||||
|
||||
constexpr bool CBuildConfig::isCompiledWithFlightSimulatorSupport()
|
||||
{
|
||||
return CBuildConfig::isCompiledWithFsxSupport() || CBuildConfig::isCompiledWithXPlaneSupport();
|
||||
}
|
||||
|
||||
constexpr bool CBuildConfig::isRunningOnWindowsNtPlatform()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
constexpr bool CBuildConfig::isRunningOnMacOSPlatform()
|
||||
{
|
||||
#ifdef Q_OS_MACOS
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
constexpr bool CBuildConfig::isRunningOnLinuxPlatform()
|
||||
{
|
||||
#ifdef Q_OS_LINUX
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
constexpr bool CBuildConfig::isRunningOnUnixPlatform()
|
||||
{
|
||||
return CBuildConfig::isRunningOnMacOSPlatform() || CBuildConfig::isRunningOnLinuxPlatform();
|
||||
}
|
||||
|
||||
constexpr bool CBuildConfig::isDebugBuild()
|
||||
{
|
||||
#ifdef QT_DEBUG
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
constexpr bool CBuildConfig::isReleaseBuild()
|
||||
{
|
||||
#ifdef QT_NO_DEBUG
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
} // ns
|
||||
|
||||
//! \endcond
|
||||
@@ -11,110 +11,6 @@
|
||||
#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_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
|
||||
|
||||
bool BlackConfig::CBuildConfig::isCompiledWithBlackCore()
|
||||
{
|
||||
#ifdef WITH_BLACKCORE
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool BlackConfig::CBuildConfig::isCompiledWithBlackSound()
|
||||
{
|
||||
#ifdef WITH_BLACKSOUND
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool BlackConfig::CBuildConfig::isCompiledWithBlackInput()
|
||||
{
|
||||
#ifdef WITH_BLACKINPUT
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool BlackConfig::CBuildConfig::isCompiledWithFs9Support()
|
||||
{
|
||||
#ifdef WITH_FS9
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool BlackConfig::CBuildConfig::isCompiledWithP3DSupport()
|
||||
{
|
||||
#ifdef WITH_P3D
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool BlackConfig::CBuildConfig::isCompiledWithFsxSupport()
|
||||
{
|
||||
#ifdef WITH_FSX
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool BlackConfig::CBuildConfig::isCompiledWithFsuipcSupport()
|
||||
{
|
||||
#ifdef WITH_FSUIPC
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool BlackConfig::CBuildConfig::isCompiledWithXPlaneSupport()
|
||||
{
|
||||
#ifdef WITH_XPLANE
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool BlackConfig::CBuildConfig::isCompiledWithGui()
|
||||
{
|
||||
#ifdef WITH_BLACKGUI
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool BlackConfig::CBuildConfig::isVatsimVersion()
|
||||
{
|
||||
#ifdef SWIFT_VATSIM_SUPPORT
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
const QDateTime &BlackConfig::CBuildConfig::getEol()
|
||||
{
|
||||
static const QString eol(\"$$BLACK_EOL\"); // config.pri
|
||||
@@ -156,7 +52,3 @@ const QDateTime &BlackConfig::CBuildConfig::lastCommitTimestamp()
|
||||
static const QDateTime dt = Private::lastCommitTimestampImpl();
|
||||
return dt;
|
||||
}
|
||||
|
||||
int BlackConfig::CBuildConfig::versionMajor() { return $$BLACK_VER_MAJ; }
|
||||
int BlackConfig::CBuildConfig::versionMinor() { return $$BLACK_VER_MIN; }
|
||||
int BlackConfig::CBuildConfig::versionMicro() { return $$BLACK_VER_MIC; }
|
||||
|
||||
120
src/blackconfig/buildconfig_gen.inc.in
Normal file
120
src/blackconfig/buildconfig_gen.inc.in
Normal file
@@ -0,0 +1,120 @@
|
||||
/* Copyright (C) 2018
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef IN_BUILDCONFIG_H
|
||||
#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
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
constexpr bool BlackConfig::CBuildConfig::isCompiledWithBlackSound()
|
||||
{
|
||||
#ifdef WITH_BLACKSOUND
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
constexpr bool BlackConfig::CBuildConfig::isCompiledWithBlackInput()
|
||||
{
|
||||
#ifdef WITH_BLACKINPUT
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
constexpr bool BlackConfig::CBuildConfig::isCompiledWithFs9Support()
|
||||
{
|
||||
#ifdef WITH_FS9
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
constexpr bool BlackConfig::CBuildConfig::isCompiledWithP3DSupport()
|
||||
{
|
||||
#ifdef WITH_P3D
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
constexpr bool BlackConfig::CBuildConfig::isCompiledWithFsxSupport()
|
||||
{
|
||||
#ifdef WITH_FSX
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
constexpr bool BlackConfig::CBuildConfig::isCompiledWithFsuipcSupport()
|
||||
{
|
||||
#ifdef WITH_FSUIPC
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
constexpr bool BlackConfig::CBuildConfig::isCompiledWithXPlaneSupport()
|
||||
{
|
||||
#ifdef WITH_XPLANE
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
constexpr bool BlackConfig::CBuildConfig::isCompiledWithGui()
|
||||
{
|
||||
#ifdef WITH_BLACKGUI
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
constexpr bool BlackConfig::CBuildConfig::isVatsimVersion()
|
||||
{
|
||||
#ifdef SWIFT_VATSIM_SUPPORT
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
constexpr int BlackConfig::CBuildConfig::versionMajor() { return $$BLACK_VER_MAJ; }
|
||||
constexpr int BlackConfig::CBuildConfig::versionMinor() { return $$BLACK_VER_MIN; }
|
||||
constexpr int BlackConfig::CBuildConfig::versionMicro() { return $$BLACK_VER_MIC; }
|
||||
Reference in New Issue
Block a user