From 82679a30101ca5c5da957db1cc0f7de7e5858694 Mon Sep 17 00:00:00 2001 From: Mat Sutcliffe Date: Sun, 4 Nov 2018 17:13:27 +0000 Subject: [PATCH] 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. --- Jenkinsfile | 16 +- default.json | 37 +++++ mkspecs/features/common_pre.prf | 10 +- mkspecs/features/config.pri | 155 ++++++++++++------ mkspecs/features/templight.pri | 2 +- mkspecs/features/touch.prf | 2 +- mkspecs/features/vatsim.pri | 11 -- mkspecs/features/warnings.pri | 4 +- scripts/jenkins.py | 17 +- src/blackconfig/buildconfig_gen.cpp.in | 6 +- src/blackconfig/buildconfig_gen.inc.in | 74 ++++----- src/blackcore/blackcore.pro | 2 +- src/blackgui/blackgui.pro | 2 +- src/blackinput/blackinput.pro | 2 +- src/blackmisc/blackmisc.pro | 2 +- src/blacksound/blacksound.pro | 2 +- src/plugins/simulator/fscommon/fscommon.pro | 2 +- src/plugins/simulator/fsx/fsx.pro | 2 +- src/plugins/simulator/fsxconfig/fsxconfig.pro | 2 +- src/plugins/simulator/p3d/p3d.pro | 2 +- src/plugins/simulator/p3dconfig/p3dconfig.pro | 2 +- src/plugins/simulator/simulator.pro | 12 +- src/src.pro | 18 +- swift.pro | 6 +- tests/tests.pro | 2 +- 25 files changed, 232 insertions(+), 160 deletions(-) create mode 100644 default.json delete mode 100644 mkspecs/features/vatsim.pri diff --git a/Jenkinsfile b/Jenkinsfile index 42bf9b300..f26daacf4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -15,8 +15,8 @@ builders['Build swift Linux'] = { def eolInMonth = 6 withEnv(['BITROCK_BUILDER=/opt/installbuilder/bin/builder', 'BITROCK_CUSTOMIZE=/opt/installbuilder/autoupdate/bin/customize.run']) { sh ''' - cp ~/vatsim.pri.official mkspecs/features/vatsim.pri - python3 -u scripts/jenkins.py -w 64 -t gcc -d -j 2 -e ''' + getEolInMonth() + ''' + cp ~/vatsim.json . + python3 -u scripts/jenkins.py -w 64 -t gcc -d -j 2 -e ''' + getEolInMonth() + ''' -q SWIFT_CONFIG_JSON+=vatsim.json ''' } @@ -62,8 +62,8 @@ builders['Build swift MacOS'] = { stage('MacOS Build') { withEnv(['PATH+LOCAL=/usr/local/bin', 'BITROCK_BUILDER=/Applications/BitRockInstallBuilderQt/bin/builder', 'BITROCK_CUSTOMIZE=/Applications/BitRockInstallBuilderQt/autoupdate/bin/customize.sh']) { sh ''' - cp ~/vatsim.pri.official mkspecs/features/vatsim.pri - python -u scripts/jenkins.py -w 64 -t clang -d -j2 -e ''' + getEolInMonth() + ''' + cp ~/vatsim.json . + python -u scripts/jenkins.py -w 64 -t clang -d -j2 -e ''' + getEolInMonth() + ''' -q SWIFT_CONFIG_JSON+=vatsim.json ''' } @@ -101,8 +101,8 @@ builders['Build swift Win32'] = { stage('Win32 Build') { bat ''' - copy /Y c:\\var\\vatsim.pri.official mkspecs\\features\\vatsim.pri - python -u scripts/jenkins.py -w 32 -t msvc -d -e ''' + getEolInMonth() + ''' + copy c:\\var\\vatsim.json . + python -u scripts/jenkins.py -w 32 -t msvc -d -e ''' + getEolInMonth() + ''' -q SWIFT_CONFIG_JSON+=vatsim.json ''' warnings consoleParsers: [[parserName: 'MSBuild']], unstableTotalAll: '0' @@ -140,8 +140,8 @@ builders['Build swift Win64'] = { stage('Win64 Build') { bat ''' - copy /Y c:\\var\\vatsim.pri.official mkspecs\\features\\vatsim.pri - python -u scripts/jenkins.py -w 64 -t msvc -d -e ''' + getEolInMonth() + ''' + copy c:\\var\\vatsim.json . + python -u scripts/jenkins.py -w 64 -t msvc -d -e ''' + getEolInMonth() + ''' -q SWIFT_CONFIG_JSON+=vatsim.json ''' warnings consoleParsers: [[parserName: 'MSBuild']], unstableTotalAll: '0' diff --git a/default.json b/default.json new file mode 100644 index 000000000..04e6752f1 --- /dev/null +++ b/default.json @@ -0,0 +1,37 @@ +{ + "libs": { + "blackcore": true, + "blackgui": true, + "blacksound": true, + "blackinput": true + }, + "samples": true, + "unitTests": true, + "apps": { + "swiftdata": true, + "swiftcore": true, + "swiftgui": true, + "swiftlauncher": true + }, + "sims": { + "fs9": true, + "fsx": true, + "p3d": true, + "fsuipc": true, + "xplane": true + }, + "profileRelease": true, + "assertsInRelease": true, + "allowNoisyWarnings": false, + "packageInstaller": true, + "static": false, + "doxygen": true, + "devBranch": false, + "stableBranch": false, + "endOfLife": "20190601", + "vatsimSupport": true, + "vatsim": { + "id": "0xb9ba", + "key": "727d1efd5cb9f8d2c28372469d922bb4" + } +} diff --git a/mkspecs/features/common_pre.prf b/mkspecs/features/common_pre.prf index 4257e088b..3188f712e 100644 --- a/mkspecs/features/common_pre.prf +++ b/mkspecs/features/common_pre.prf @@ -57,7 +57,7 @@ contains(TEMPLATE, "vc.*"): QMAKE_CXXFLAGS *= /MP # Profile build ################################ -contains(BLACK_CONFIG, ProfileRelease) { +swiftConfig(profileRelease) { msvc { QMAKE_CXXFLAGS_RELEASE *= /Zi QMAKE_LFLAGS_RELEASE *= /DEBUG /PROFILE /INCREMENTAL:NO /OPT:REF /OPT:ICF @@ -90,9 +90,9 @@ win32-g++: QMAKE_CXXFLAGS *= -Wa,-mbig-obj # FSX or FS9 on 32bit Windows only ################################ -!win32: BLACK_CONFIG -= P3D -equals(WORD_SIZE,64)|!win32: BLACK_CONFIG -= FSX FS9 -# equals(WORD_SIZE,64):win32-g++: BLACK_CONFIG -= P3D +!win32: disableSwiftConfig(sims.p3d) +equals(WORD_SIZE,64)|!win32: disableSwiftConfig(sims.fsx, sims.fs9) +# equals(WORD_SIZE,64):win32-g++: disableSwiftConfig(sims.p3d) ################################ # For BlackMisc::getStackTrace @@ -163,7 +163,7 @@ defineTest(addStaticLibraryDependency) { export(PRE_TARGETDEPS) } defineTest(addLibraryDependency) { - contains(BLACK_CONFIG, Static) { + swiftConfig(static) { addStaticLibraryDependency($$1) } else { diff --git a/mkspecs/features/config.pri b/mkspecs/features/config.pri index 7361c43b9..871cec478 100644 --- a/mkspecs/features/config.pri +++ b/mkspecs/features/config.pri @@ -1,63 +1,120 @@ -## Public Area ## +# Make sure _QMAKE_CACHE_ is initialized (otherwise config.log goes to the root directory) +cache() -BLACK_CONFIG *= BlackCore -BLACK_CONFIG *= BlackGui -BLACK_CONFIG *= BlackSound -BLACK_CONFIG *= BlackInput -BLACK_CONFIG *= Samples -BLACK_CONFIG *= Unittests -BLACK_CONFIG *= SwiftData -BLACK_CONFIG *= SwiftCore -BLACK_CONFIG *= SwiftGui -BLACK_CONFIG *= SwiftLauncher -BLACK_CONFIG *= FS9 -BLACK_CONFIG *= FSX -BLACK_CONFIG *= P3D -BLACK_CONFIG *= XPlane -BLACK_CONFIG *= ProfileRelease -BLACK_CONFIG *= AssertsInRelease -#BLACK_CONFIG *= AllowNoisyWarnings -BLACK_CONFIG *= PackageInstaller -#BLACK_CONFIG *= Static -BLACK_CONFIG *= Doxygen -#BLACK_CONFIG *= SwiftDevBranch -#BLACK_CONFIG *= SwiftStableBranch -BLACK_CONFIG *= FSUIPC +################################ +# Parse json config files +################################ -isEmpty(BLACK_EOL): BLACK_EOL = "20190601" +# Copy json keys/values from one variable prefix to another, optionally caching the result +defineTest(copyJsonFromTo) { + from = $$1 + to = $$2 + options = $$3 -## Private Area ## + unset($${to}._KEYS_) + for(key, $${from}._KEYS_) { + $${to}._KEYS_ += $$key + export($${to}._KEYS_) + copyJsonFromTo($${from}.$$key, $${to}.$$key, $$options) + } + contains(options, cache):defined($${to}._KEYS_, var): cache($${to}._KEYS_) + + defined($$from, var) { + contains(options, overwrite)|!defined($$to, var) { + eval(newValue = \$\${$$from}) + $$to = $$newValue + export($$to) + } + contains(options, cache):defined($$to, var): cache($$to) + } +} + +# Options that control how the config works +!swiftNoDefaultJson: SWIFT_CONFIG_JSON = default.json $$SWIFT_CONFIG_JSON +equals(_PRO_FILE_PWD_, $$SourceRoot): CONFIG *= swiftNoCacheConfig + +# Parse the json files (or get the values from the cache) +for(jsonFile, SWIFT_CONFIG_JSON) { + contains(jsonFile, [^A-Za-z0-9_\\.]): error(Illegal character in filename \"$$jsonFile\") + jsonPath = $$SourceRoot/$$jsonFile + !exists($$jsonPath): error($$jsonPath not found) + SWIFT_CONFIG_JSON_PATHS += $$jsonPath + export(SWIFT_CONFIG_JSON_PATHS) + swiftNoCacheConfig { + message(Parsing $${jsonFile}...) + jsonBlob = $$cat($$jsonPath, blob) + parseJson(jsonBlob, SWIFT_CONFIG_PARSED.$$jsonFile) + copyJsonFromTo(SWIFT_CONFIG_PARSED.$$jsonFile, SWIFT_CONFIG_PARSED_ALL, overwrite) + } +} +swiftNoCacheConfig { + copyJsonFromTo(SWIFT_CONFIG_PARSED_ALL, SWIFT_CONFIG) + copyJsonFromTo(SWIFT_CONFIG, SWIFT_CONFIG_CACHE, cache overwrite) +} +else { + copyJsonFromTo(SWIFT_CONFIG_CACHE, SWIFT_CONFIG) +} + +# Automatically run qmake again when a json file changed +QMAKE_INTERNAL_INCLUDED_FILES *= $$SWIFT_CONFIG_JSON_PATHS + +# The line above doesn't work with Qt Creator's MSVC kit, so we report an error as a fallback +load(touch) +system($$TOUCH $$system_path($$BuildRoot/swift_config.cookie)) { + swift_config_changed.target = $$shell_path($$BuildRoot/swift_config.cookie) + swift_config_changed.depends = $$shell_path($$SWIFT_CONFIG_JSON_PATHS) + swift_config_changed.commands = @echo ERROR: swift config changed, please run qmake again >&2 && exit 1 + QMAKE_EXTRA_TARGETS += swift_config_changed + PRE_TARGETDEPS += $${swift_config_changed.target} +} +else:msvc { + warning(Failed to create swift_config.cookie, you will need to manually run qmake again after any changes in $$join(SWIFT_CONFIG_JSON, ", ").) +} + +################################ +# Functions to read json config +################################ + +defineTest(swiftConfig) { + equals(SWIFT_CONFIG.$$1, true): return(true) + return(false) +} +defineReplace(swiftConfig) { + eval(value = \$\${SWIFT_CONFIG.$$1}) + return($$value) +} + +################################ +# Functions to modify json config +################################ + +defineTest(setSwiftConfig) { + SWIFT_CONFIG.$$1 = $$2 + export(SWIFT_CONFIG.$$1) +} +defineTest(enableSwiftConfig) { + for(arg, ARGS): setSwiftConfig($$arg, true) +} +defineTest(disableSwiftConfig) { + for(arg, ARGS): setSwiftConfig($$arg, false) +} + +################################ +# Functions for checking dependencies +################################ -## Dependency Checks ## load(configure) defineTest(CheckMandatoryDependency) { !qtCompileTest($${1}): error(Cannot find $${1} development package. Make sure it is installed. Inspect config.log for more information.) } - defineTest(CheckOptionalDependency) { qtCompileTest($${1}) } -# include vatsim client id and key -include(vatsim.pri) +################################ +# Global compiler macros +################################ -# Header based compiler macros -# DEFINES correspond with buildconfig_gen.cpp.in -!contains(BLACK_CONFIG, BlackSound) { DEFINE_WITH_BLACKSOUND = "//" } -!contains(BLACK_CONFIG, BlackInput) { DEFINE_WITH_BLACKINPUT = "//" } -!contains(BLACK_CONFIG, BlackCore) { DEFINE_WITH_BLACKCORE = "//" } -!contains(BLACK_CONFIG, BlackGui) { DEFINE_WITH_BLACKGUI = "//" } -!contains(BLACK_CONFIG, SwiftData) { DEFINE_WITH_SWIFTDATA = "//" } -!contains(BLACK_CONFIG, SwiftGui) { DEFINE_WITH_SWIFTGUI = "//" } -!contains(BLACK_CONFIG, SwiftCore) { DEFINE_WITH_SWIFTCORE = "//" } -!contains(BLACK_CONFIG, P3D) { DEFINE_WITH_P3D = "//" } -!contains(BLACK_CONFIG, FSX) { DEFINE_WITH_FSX = "//" } -!contains(BLACK_CONFIG, FS9) { DEFINE_WITH_FS9 = "//" } -!contains(BLACK_CONFIG, FSUIPC) { DEFINE_WITH_FSUIPC = "//" } -!contains(BLACK_CONFIG, XPlane) { DEFINE_WITH_XPLANE = "//" } -!contains(BLACK_CONFIG, SwiftVatsimSupport) { DEFINE_SWIFT_VATSIM_SUPPORT = "//" } - -# Global compiler Macros -contains(BLACK_CONFIG, Static) { DEFINES *= WITH_STATIC } -contains(BLACK_CONFIG, AssertsInRelease) { DEFINES *= QT_FORCE_ASSERTS } +swiftConfig(static) { DEFINES *= WITH_STATIC } +swiftConfig(assertsInRelease) { DEFINES *= QT_FORCE_ASSERTS } diff --git a/mkspecs/features/templight.pri b/mkspecs/features/templight.pri index 61cf72754..db89248ec 100644 --- a/mkspecs/features/templight.pri +++ b/mkspecs/features/templight.pri @@ -1,4 +1,4 @@ -contains(BLACK_CONFIG, Templight) { +swiftConfig(templight) { QMAKE_CXXFLAGS += -Xtemplight -profiler -Xtemplight -ignore-system QMAKE_CXXFLAGS += -Xtemplight -blacklist -Xtemplight $$PWD/templight_blacklist clang_cl { diff --git a/mkspecs/features/touch.prf b/mkspecs/features/touch.prf index fe6adf32e..79e3352cd 100644 --- a/mkspecs/features/touch.prf +++ b/mkspecs/features/touch.prf @@ -1,5 +1,5 @@ win32:isEmpty(MINGW_IN_SHELL) { - TOUCH = copy /y nul + TOUCH = copy /y nul >nul } else { TOUCH = touch diff --git a/mkspecs/features/vatsim.pri b/mkspecs/features/vatsim.pri deleted file mode 100644 index 2ec930a7c..000000000 --- a/mkspecs/features/vatsim.pri +++ /dev/null @@ -1,11 +0,0 @@ -# This is in a separate file to allow easy patching. - -# VATSIM client id as assigned by VATSIM Network team. The one below is a test key. -# It is working only with VATGER test server. -isEmpty(VATSIM_CLIENT_ID):VATSIM_CLIENT_ID = "0xb9ba" - -# VATSIM private key, which belongs to the id above. -isEmpty(VATSIM_CLIENT_PRIVATE_KEY):VATSIM_CLIENT_PRIVATE_KEY = "727d1efd5cb9f8d2c28372469d922bb4" - -# Comment the section below to build a version without VATSIM features enabled -BLACK_CONFIG *= SwiftVatsimSupport diff --git a/mkspecs/features/warnings.pri b/mkspecs/features/warnings.pri index 624d06782..e503dadf8 100644 --- a/mkspecs/features/warnings.pri +++ b/mkspecs/features/warnings.pri @@ -7,7 +7,7 @@ gcc:QMAKE_CXXFLAGS_WARN_ON *= -Woverloaded-virtual gcc:QMAKE_CXXFLAGS_USE_PRECOMPILE = -Winvalid-pch $$QMAKE_CXXFLAGS_USE_PRECOMPILE # elevated warnings -contains(BLACK_CONFIG, AllowNoisyWarnings) { +swiftConfig(allowNoisyWarnings) { clang { QMAKE_CXXFLAGS_WARN_ON *= -Weverything --system-header-prefix=$$[QT_INSTALL_HEADERS] QMAKE_CXXFLAGS_WARN_ON += -Wno-system-headers -Wno-c++98-compat-pedantic -Wno-class-varargs -Wno-covered-switch-default @@ -32,7 +32,7 @@ gcc { greaterThan(GCC_MAJOR, 5) { QMAKE_CXXFLAGS_WARN_ON *= -Wsuggest-override } - greaterThan(GCC_MAJOR, 4):contains(BLACK_CONFIG, AllowNoisyWarnings) { + greaterThan(GCC_MAJOR, 4):swiftConfig(allowNoisyWarnings) { QMAKE_CXXFLAGS_WARN_ON *= -Wsuggest-override } } diff --git a/scripts/jenkins.py b/scripts/jenkins.py index bd2b4adea..58f86eef3 100644 --- a/scripts/jenkins.py +++ b/scripts/jenkins.py @@ -45,7 +45,7 @@ class Builder: shared_path = os.path.abspath(os.path.join(source_path, 'resources', 'share')) datastore.update_shared(host, datastore_version, shared_path) - def build(self, jobs, dev_build, eolInMonth): + def build(self, jobs, qmake_args, dev_build, eolInMonth): """ Run the build itself. Pass dev_build=True to enable a dev build """ @@ -55,9 +55,9 @@ class Builder: os.makedirs(build_path) os.chdir(build_path) - qmake_call = ['qmake'] + qmake_call = ['qmake'] + qmake_args if dev_build: - qmake_call += ['"BLACK_CONFIG+=SwiftDevBranch"'] + qmake_call += ['"SWIFT_CONFIG.devBranch=true"'] if eolInMonth > 0: eolYear = date.today().year @@ -66,7 +66,7 @@ class Builder: eolMonth = eolMonth % 12 + 1 eolDate = date(int(eolYear), int(eolMonth), 1) print('Setting EOL date to ' + eolDate.strftime('%Y%m%d')) - qmake_call += ['BLACK_EOL=' + eolDate.strftime('%Y%m%d')] + qmake_call += ['SWIFT_CONFIG.endOfLife=' + eolDate.strftime('%Y%m%d')] qmake_call += ['-r', os.pardir] subprocess.check_call(qmake_call, env=dict(os.environ)) @@ -384,7 +384,7 @@ def print_help(): 'Windows': ['msvc', 'mingw'] } compiler_help = '|'.join(supported_compilers[platform.system()]) - print('jenkins.py -c -w <32|64> -t <' + compiler_help + '> [-d] [-e ]') + print('jenkins.py -c -w <32|64> -t <' + compiler_help + '> [-d] [-e ] [-q ]') # Entry point if called as a standalone program @@ -396,9 +396,10 @@ def main(argv): jobs = None upload_symbols = False eolInMonth = 0 + qmake_args = [] try: - opts, args = getopt.getopt(argv, 'hc:w:t:j:due:', ['config=', 'wordsize=', 'toolchain=', 'jobs=', 'dev', 'upload', 'eol']) + opts, args = getopt.getopt(argv, 'hc:w:t:j:due:q:', ['config=', 'wordsize=', 'toolchain=', 'jobs=', 'dev', 'upload', 'eol', 'qmake-arg=']) except getopt.GetoptError: print_help() sys.exit(2) @@ -428,6 +429,8 @@ def main(argv): upload_symbols = True elif opt in ('-e', '--eol'): eolInMonth = int(arg) + elif opt in ('-q', '--qmake-arg'): + qmake_args += [arg] if word_size not in ['32', '64']: print('Unsupported word size. Choose 32 or 64') @@ -450,7 +453,7 @@ def main(argv): builder = builders[platform.system()][tool_chain](config_file, word_size) builder.prepare() - builder.build(jobs, dev_build, eolInMonth) + builder.build(jobs, qmake_args, dev_build, eolInMonth) builder.checks() builder.install() builder.publish() diff --git a/src/blackconfig/buildconfig_gen.cpp.in b/src/blackconfig/buildconfig_gen.cpp.in index 0562d630a..37ca3c7a7 100644 --- a/src/blackconfig/buildconfig_gen.cpp.in +++ b/src/blackconfig/buildconfig_gen.cpp.in @@ -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; } diff --git a/src/blackconfig/buildconfig_gen.inc.in b/src/blackconfig/buildconfig_gen.inc.in index 5365aaa32..53bdda797 100644 --- a/src/blackconfig/buildconfig_gen.inc.in +++ b/src/blackconfig/buildconfig_gen.inc.in @@ -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; } diff --git a/src/blackcore/blackcore.pro b/src/blackcore/blackcore.pro index 1c4136727..bb7bd7ba2 100644 --- a/src/blackcore/blackcore.pro +++ b/src/blackcore/blackcore.pro @@ -8,7 +8,7 @@ TARGET = blackcore TEMPLATE = lib CONFIG += blackconfig blackmisc blackinput blacksound precompile_header -contains(BLACK_CONFIG, Static) { +swiftConfig(static) { CONFIG += staticlib } diff --git a/src/blackgui/blackgui.pro b/src/blackgui/blackgui.pro index b303e6015..c852a8d69 100644 --- a/src/blackgui/blackgui.pro +++ b/src/blackgui/blackgui.pro @@ -6,7 +6,7 @@ TARGET = blackgui TEMPLATE = lib CONFIG += blackconfig blackmisc blackcore precompile_header -contains(BLACK_CONFIG, Static) { +swiftConfig(static) { CONFIG += staticlib } diff --git a/src/blackinput/blackinput.pro b/src/blackinput/blackinput.pro index 4f819e83d..f8ceb50e4 100644 --- a/src/blackinput/blackinput.pro +++ b/src/blackinput/blackinput.pro @@ -7,7 +7,7 @@ TARGET = blackinput TEMPLATE = lib CONFIG += blackmisc -contains(BLACK_CONFIG, Static) { +swiftConfig(static) { CONFIG += staticlib } diff --git a/src/blackmisc/blackmisc.pro b/src/blackmisc/blackmisc.pro index a4d9cc6de..fc312c982 100644 --- a/src/blackmisc/blackmisc.pro +++ b/src/blackmisc/blackmisc.pro @@ -6,7 +6,7 @@ TARGET = blackmisc TEMPLATE = lib CONFIG += blackconfig precompile_header -contains(BLACK_CONFIG, Static) { +swiftConfig(static) { CONFIG += staticlib } diff --git a/src/blacksound/blacksound.pro b/src/blacksound/blacksound.pro index 3e218aebe..48a5d82e2 100644 --- a/src/blacksound/blacksound.pro +++ b/src/blacksound/blacksound.pro @@ -6,7 +6,7 @@ TARGET = blacksound TEMPLATE = lib CONFIG += blackconfig blackmisc -contains(BLACK_CONFIG, Static) { +swiftConfig(static) { CONFIG += staticlib } diff --git a/src/plugins/simulator/fscommon/fscommon.pro b/src/plugins/simulator/fscommon/fscommon.pro index 118540d58..ce87e9444 100644 --- a/src/plugins/simulator/fscommon/fscommon.pro +++ b/src/plugins/simulator/fscommon/fscommon.pro @@ -17,7 +17,7 @@ HEADERS += *.h LIBS *= -lsimulatorplugincommon addStaticLibraryDependency(simulatorplugincommon) -contains(BLACK_CONFIG, FSUIPC) { +swiftConfig(sims.fsuipc) { equals(WORD_SIZE,32) { DEFINES += SWIFT_USING_FSUIPC32 } diff --git a/src/plugins/simulator/fsx/fsx.pro b/src/plugins/simulator/fsx/fsx.pro index 674fcfdea..d56f7e009 100644 --- a/src/plugins/simulator/fsx/fsx.pro +++ b/src/plugins/simulator/fsx/fsx.pro @@ -15,7 +15,7 @@ DESTDIR = $$DestRoot/bin/plugins/simulator SOURCES += *.cpp HEADERS += *.h -REQUIRES += contains(BLACK_CONFIG,FSX) +REQUIRES += swiftConfig(sims.fsx) TARGET = simulatorfsx DISTFILES += simulatorfsx.json diff --git a/src/plugins/simulator/fsxconfig/fsxconfig.pro b/src/plugins/simulator/fsxconfig/fsxconfig.pro index c7e762927..9376358d4 100644 --- a/src/plugins/simulator/fsxconfig/fsxconfig.pro +++ b/src/plugins/simulator/fsxconfig/fsxconfig.pro @@ -15,7 +15,7 @@ DESTDIR = $$DestRoot/bin/plugins/simulator SOURCES += *.cpp HEADERS += *.h -REQUIRES += contains(BLACK_CONFIG,FSX) +REQUIRES += swiftConfig(sims.fsx) TARGET = simulatorfsxconfig DISTFILES += simulatorfsx.json diff --git a/src/plugins/simulator/p3d/p3d.pro b/src/plugins/simulator/p3d/p3d.pro index f14e8b0fa..ec517eb77 100644 --- a/src/plugins/simulator/p3d/p3d.pro +++ b/src/plugins/simulator/p3d/p3d.pro @@ -20,7 +20,7 @@ DESTDIR = $$DestRoot/bin/plugins/simulator SOURCES += *.cpp HEADERS += *.h -REQUIRES += contains(BLACK_CONFIG,P3D) +REQUIRES += swiftConfig(sims.p3d) TARGET = simulatorp3d DISTFILES += simulatorp3d.json diff --git a/src/plugins/simulator/p3dconfig/p3dconfig.pro b/src/plugins/simulator/p3dconfig/p3dconfig.pro index b68c556b2..928ef5fd1 100644 --- a/src/plugins/simulator/p3dconfig/p3dconfig.pro +++ b/src/plugins/simulator/p3dconfig/p3dconfig.pro @@ -15,7 +15,7 @@ DESTDIR = $$DestRoot/bin/plugins/simulator SOURCES += *.cpp HEADERS += *.h -REQUIRES += contains(BLACK_CONFIG,P3D) +REQUIRES += swiftConfig(sims.p3d) TARGET = simulatorp3dconfig DISTFILES += simulatorp3d.json diff --git a/src/plugins/simulator/simulator.pro b/src/plugins/simulator/simulator.pro index 72a0444e3..8a6ee8b31 100644 --- a/src/plugins/simulator/simulator.pro +++ b/src/plugins/simulator/simulator.pro @@ -7,26 +7,26 @@ SUBDIRS += plugincommon SUBDIRS += emulated SUBDIRS += emulatedconfig -contains(BLACK_CONFIG,FSX|FS9|P3D) { +swiftConfig(sims.fsx)|swiftConfig(sims.fs9)|swiftConfig(sims.p3d) { SUBDIRS += fsuipc32 SUBDIRS += fsuipc64 SUBDIRS += fscommon } -contains(BLACK_CONFIG,FSX|P3D) { +swiftConfig(sims.fsx)|swiftConfig(sims.p3d) { SUBDIRS += fsxcommon } -contains(BLACK_CONFIG,P3D) { +swiftConfig(sims.p3d) { SUBDIRS += p3d SUBDIRS += p3dconfig } -contains(BLACK_CONFIG,FSX) { +swiftConfig(sims.fsx) { SUBDIRS += fsx SUBDIRS += fsxconfig } -contains(BLACK_CONFIG,FS9):contains(BLACK_CONFIG,FSUIPC) { +swiftConfig(sims.fs9):swiftConfig(sims.fsuipc) { SUBDIRS += fs9 } -contains(BLACK_CONFIG,XPlane) { +swiftConfig(sims.xplane) { SUBDIRS += xplane SUBDIRS += xplaneconfig } diff --git a/src/src.pro b/src/src.pro index b18b74f06..db9058019 100644 --- a/src/src.pro +++ b/src/src.pro @@ -5,31 +5,31 @@ CONFIG += ordered SUBDIRS += blackconfig SUBDIRS += blackmisc -contains(BLACK_CONFIG,BlackSound) { +swiftConfig(libs.blacksound) { SUBDIRS += blacksound } -contains(BLACK_CONFIG,BlackInput) { +swiftConfig(libs.blackinput) { SUBDIRS += blackinput } -contains(BLACK_CONFIG,BlackCore) { +swiftConfig(libs.blackcore) { SUBDIRS += blackcore } -contains(BLACK_CONFIG,BlackGui) { +swiftConfig(libs.blackgui) { SUBDIRS += blackgui } -contains(BLACK_CONFIG,SwiftGui) { +swiftConfig(apps.swiftgui) { SUBDIRS += swiftguistandard } -contains(BLACK_CONFIG,SwiftCore) { +swiftConfig(apps.swiftcore) { SUBDIRS += swiftcore } -contains(BLACK_CONFIG,SwiftData) { +swiftConfig(apps.swiftdata) { SUBDIRS += swiftdata } -contains(BLACK_CONFIG,SwiftLauncher) { +swiftConfig(apps.swiftlauncher) { SUBDIRS += swiftlauncher } -contains(BLACK_CONFIG,XPlane) { +swiftConfig(sims.xplane) { SUBDIRS += xswiftbus } SUBDIRS += plugins diff --git a/swift.pro b/swift.pro index db65ade24..02b6f68fe 100644 --- a/swift.pro +++ b/swift.pro @@ -13,15 +13,15 @@ CheckMandatoryDependency(glu) CheckMandatoryDependency(libpng) CheckMandatoryDependency(zlib) -contains(BLACK_CONFIG,Doxygen) { +swiftConfig(doxygen) { SUBDIRS += docs } SUBDIRS += resources SUBDIRS += src -contains(BLACK_CONFIG,Samples) { +swiftConfig(samples) { SUBDIRS += samples } -contains(BLACK_CONFIG,Unittests) { +swiftConfig(unitTests) { SUBDIRS += tests } diff --git a/tests/tests.pro b/tests/tests.pro index 1ddd4e1a3..a11e0f485 100644 --- a/tests/tests.pro +++ b/tests/tests.pro @@ -11,7 +11,7 @@ SUBDIRS += blackgui # testblackcore.file = blackcore/testblackcore.pro # testblackgui.file = blackgui/testblackgui.pro -contains(BLACK_CONFIG,FSX|P3D) { +swiftConfig(sims.fsx)|swiftConfig(sims.p3d) { SUBDIRS += testsimpluginfsxp3d testsimpluginfsxp3d.file = blacksimpluginfsxp3d/testblacksimpluginfsxp3d.pro }