From 6836caa14c247829bfd4edf47d31c87310d56211 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Thu, 22 Jun 2023 14:59:24 +0200 Subject: [PATCH] Do not compile PROJECT_USER_FILE_EXTENSION into plugins Set it in the app info in the main application and read it from there. Moves more branding information out of the plugins. Change-Id: I2f2e9fc96900793be15ac1907df70dda31c1b9c1 Reviewed-by: Qt CI Bot Reviewed-by: Alessandro Portale --- qbs/modules/qtc/qtc.qbs | 1 + src/app/app_version.h.cmakein | 3 +++ src/app/app_version_header.qbs | 2 ++ src/app/main.cpp | 1 + src/libs/utils/appinfo.h | 1 + src/plugins/projectexplorer/CMakeLists.txt | 5 ---- .../projectexplorer/userfileaccessor.cpp | 24 +++++++++---------- 7 files changed, 19 insertions(+), 18 deletions(-) diff --git a/qbs/modules/qtc/qtc.qbs b/qbs/modules/qtc/qtc.qbs index 58ad299d3e3..8a78e329b07 100644 --- a/qbs/modules/qtc/qtc.qbs +++ b/qbs/modules/qtc/qtc.qbs @@ -26,6 +26,7 @@ Module { property string ide_id: 'qtcreator' property string ide_cased_id: 'QtCreator' property string ide_bundle_identifier: 'org.qt-project.qtcreator' + property string ide_user_file_extension: '.user' property string libDirName: "lib" property string ide_app_path: qbs.targetOS.contains("macos") ? "" : "bin" diff --git a/src/app/app_version.h.cmakein b/src/app/app_version.h.cmakein index 5b9098f056e..6c1fb9bb297 100644 --- a/src/app/app_version.h.cmakein +++ b/src/app/app_version.h.cmakein @@ -28,5 +28,8 @@ const char IDE_REVISION_URL[] = "${IDE_REVISION_URL}"; // changes the path where the settings are saved to const char IDE_SETTINGSVARIANT_STR[] = "${IDE_SETTINGSVARIANT}"; +// added extension for project user settings +const char IDE_PROJECT_USER_FILE_EXTENSION[] = "${PROJECT_USER_FILE_EXTENSION}"; + } // Constants } // Core diff --git a/src/app/app_version_header.qbs b/src/app/app_version_header.qbs index 59cd014df7c..110ec345403 100644 --- a/src/app/app_version_header.qbs +++ b/src/app/app_version_header.qbs @@ -57,6 +57,8 @@ Product { product.moduleProperty("qtc", "ide_id")); content = content.replace("$${IDE_CASED_ID}", product.moduleProperty("qtc", "ide_cased_id")); + content = content.replace("$${PROJECT_USER_FILE_EXTENSION}", + product.moduleProperty("qtc", "ide_user_file_extension")); file = new TextFile(output.filePath, TextFile.WriteOnly); file.truncate(); file.write(content); diff --git a/src/app/main.cpp b/src/app/main.cpp index c488a2d9be6..b2c10208a6f 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -662,6 +662,7 @@ int main(int argc, char **argv) info.id = Constants::IDE_ID; info.revision = Constants::IDE_REVISION_STR; info.revisionUrl = Constants::IDE_REVISION_URL; + info.userFileExtension = Constants::IDE_PROJECT_USER_FILE_EXTENSION; Utils::Internal::setAppInfo(info); QTranslator translator; diff --git a/src/libs/utils/appinfo.h b/src/libs/utils/appinfo.h index 2ce926f8b57..9fd5a3f35e8 100644 --- a/src/libs/utils/appinfo.h +++ b/src/libs/utils/appinfo.h @@ -18,6 +18,7 @@ public: QString id; QString revision; QString revisionUrl; + QString userFileExtension; }; QTCREATOR_UTILS_EXPORT AppInfo appInfo(); diff --git a/src/plugins/projectexplorer/CMakeLists.txt b/src/plugins/projectexplorer/CMakeLists.txt index b9758fbfe7e..dd3d2d1e995 100644 --- a/src/plugins/projectexplorer/CMakeLists.txt +++ b/src/plugins/projectexplorer/CMakeLists.txt @@ -182,11 +182,6 @@ add_qtc_plugin(ProjectExplorer xcodebuildparser.cpp xcodebuildparser.h ) -extend_qtc_plugin(ProjectExplorer - CONDITION PROJECT_USER_FILE_EXTENSION - DEFINES "PROJECT_USER_FILE_EXTENSION=${PROJECT_USER_FILE_EXTENSION}" -) - if (TARGET clangd) set(CLANG_BINDIR "$") endif() diff --git a/src/plugins/projectexplorer/userfileaccessor.cpp b/src/plugins/projectexplorer/userfileaccessor.cpp index 295bb2ea000..4a174cdf837 100644 --- a/src/plugins/projectexplorer/userfileaccessor.cpp +++ b/src/plugins/projectexplorer/userfileaccessor.cpp @@ -14,6 +14,8 @@ #include "kitmanager.h" #include + +#include #include #include #include @@ -29,22 +31,18 @@ using namespace ProjectExplorer::Internal; using StringVariantPair = std::pair; +static QString userFileExtension() +{ + const QString ext = Utils::appInfo().userFileExtension; + return ext.isEmpty() ? QLatin1String(".user") : ext; +} + namespace { const char OBSOLETE_VERSION_KEY[] = "ProjectExplorer.Project.Updater.FileVersion"; const char SHARED_SETTINGS[] = "SharedSettings"; const char USER_STICKY_KEYS_KEY[] = "UserStickyKeys"; -#ifdef PROJECT_USER_FILE_EXTENSION -#define STRINGIFY_INTERNAL(x) #x -#define STRINGIFY(x) STRINGIFY_INTERNAL(x) - -const char FILE_EXTENSION_STR[] = STRINGIFY(PROJECT_USER_FILE_EXTENSION); -#else -const char FILE_EXTENSION_STR[] = ".user"; - -#endif - // Version 14 Move builddir into BuildConfiguration class UserFileVersion14Upgrader : public VersionUpgrader { @@ -385,15 +383,15 @@ QVariant UserFileAccessor::retrieveSharedSettings() const FilePath UserFileAccessor::projectUserFile() const { static const QString qtcExt = qtcEnvironmentVariable("QTC_EXTENSION"); - return m_project->projectFilePath() - .stringAppended(generateSuffix(qtcExt.isEmpty() ? FILE_EXTENSION_STR : qtcExt)); + return m_project->projectFilePath().stringAppended( + generateSuffix(qtcExt.isEmpty() ? userFileExtension() : qtcExt)); } FilePath UserFileAccessor::externalUserFile() const { static const QString qtcExt = qtcEnvironmentVariable("QTC_EXTENSION"); return externalUserFilePath(m_project->projectFilePath(), - generateSuffix(qtcExt.isEmpty() ? FILE_EXTENSION_STR : qtcExt)); + generateSuffix(qtcExt.isEmpty() ? userFileExtension() : qtcExt)); } FilePath UserFileAccessor::sharedFile() const