From 87f496d091be334d240c285fa5aa9fae7f139055 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Fri, 9 Aug 2019 12:20:49 +0200 Subject: [PATCH] CMake: More logging of cmake parsing flags Add more logging of cmake parsing flags as cmake runs are requested in the plugin. Change-Id: I5231bd29dfeb6521218dc28c26a5b658ccb4059b Reviewed-by: Eike Ziller --- .../cmakeprojectmanager/builddirmanager.cpp | 39 ++++++++++++++++++- .../cmakeprojectmanager/builddirmanager.h | 21 +++++----- .../cmakebuildconfiguration.cpp | 10 ++++- .../cmakeprojectmanager/fileapireader.cpp | 2 +- 4 files changed, 58 insertions(+), 14 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/builddirmanager.cpp b/src/plugins/cmakeprojectmanager/builddirmanager.cpp index b5fe1c501ae..68169bdd136 100644 --- a/src/plugins/cmakeprojectmanager/builddirmanager.cpp +++ b/src/plugins/cmakeprojectmanager/builddirmanager.cpp @@ -45,6 +45,7 @@ #include #include +#include #include #include #include @@ -55,6 +56,8 @@ using namespace Utils; namespace CMakeProjectManager { namespace Internal { +Q_LOGGING_CATEGORY(cmakeBuildDirManagerLog, "qtc.cmake.builddirmanager", QtWarningMsg); + // -------------------------------------------------------------------- // BuildDirManager: // -------------------------------------------------------------------- @@ -283,7 +286,10 @@ bool BuildDirManager::persistCMakeState() void BuildDirManager::parse(int reparseParameters) { - QTC_ASSERT(m_parameters.isValid(), return); + qCDebug(cmakeBuildDirManagerLog) + << "Parse called with flags:" << flagsString(reparseParameters); + + QTC_ASSERT(m_parameters.isValid(), return ); QTC_ASSERT(m_reader, return); QTC_ASSERT((reparseParameters & REPARSE_FAIL) == 0, return); QTC_ASSERT((reparseParameters & REPARSE_IGNORE) == 0, return); @@ -294,9 +300,14 @@ void BuildDirManager::parse(int reparseParameters) if (!m_parameters.workDirectory.toFileInfo().exists("CMakeCache.txt")) { reparseParameters |= REPARSE_FORCE_CONFIGURATION | REPARSE_FORCE_CMAKE_RUN; + qCDebug(cmakeBuildDirManagerLog) + << "No CMakeCache.txt file found, new flags:" << flagsString(reparseParameters); } else if (reparseParameters & REPARSE_CHECK_CONFIGURATION) { - if (checkConfiguration()) + if (checkConfiguration()) { reparseParameters |= REPARSE_FORCE_CONFIGURATION | REPARSE_FORCE_CMAKE_RUN; + qCDebug(cmakeBuildDirManagerLog) + << "Config check triggered flags change:" << flagsString(reparseParameters); + } } m_reader->parse(reparseParameters & REPARSE_FORCE_CMAKE_RUN, @@ -406,6 +417,30 @@ CMakeConfig BuildDirManager::parseCMakeConfiguration(const Utils::FilePath &cach return result; } +QString BuildDirManager::flagsString(int reparseFlags) +{ + QString result; + if (reparseFlags == REPARSE_DEFAULT) { + result = ""; + } else { + if (reparseFlags & REPARSE_URGENT) + result += " URGENT"; + if (reparseFlags & REPARSE_FORCE_CMAKE_RUN) + result += " FORCE_CMAKE_RUN"; + if (reparseFlags & REPARSE_FORCE_CONFIGURATION) + result += " FORCE_CONFIG"; + if (reparseFlags & REPARSE_CHECK_CONFIGURATION) + result += " CHECK_CONFIG"; + if (reparseFlags & REPARSE_SCAN) + result += " SCAN"; + if (reparseFlags & REPARSE_IGNORE) + result += " IGNORE"; + if (reparseFlags & REPARSE_FAIL) + result += " FAIL"; + } + return result.trimmed(); +} + bool BuildDirManager::checkConfiguration() { CMakeBuildConfiguration *bc = buildConfiguration(); diff --git a/src/plugins/cmakeprojectmanager/builddirmanager.h b/src/plugins/cmakeprojectmanager/builddirmanager.h index f4e8f4a25f2..17c343656a2 100644 --- a/src/plugins/cmakeprojectmanager/builddirmanager.h +++ b/src/plugins/cmakeprojectmanager/builddirmanager.h @@ -91,15 +91,18 @@ public: static CMakeConfig parseCMakeConfiguration(const Utils::FilePath &cacheFile, QString *errorMessage); - enum ReparseParameters { REPARSE_DEFAULT = 0, // use defaults - REPARSE_URGENT = 1, // Do not wait for more requests, start ASAP - REPARSE_FORCE_CMAKE_RUN = 2, // Force cmake to run - REPARSE_FORCE_CONFIGURATION = 4, // Force configuration arguments to cmake - REPARSE_CHECK_CONFIGURATION = 8, // Check and warn if on-disk config and QtC config differ - REPARSE_SCAN = 16, - REPARSE_IGNORE = 32, // Do not reparse:-) - REPARSE_FAIL = 64 // Do not reparse and raise a warning - }; + enum ReparseParameters { + REPARSE_DEFAULT = 0, // use defaults + REPARSE_URGENT = 1, // Do not wait for more requests, start ASAP + REPARSE_FORCE_CMAKE_RUN = 2, // Force cmake to run + REPARSE_FORCE_CONFIGURATION = 4, // Force configuration arguments to cmake + REPARSE_CHECK_CONFIGURATION = 8, // Check and warn if on-disk config and QtC config differ + REPARSE_SCAN = 16, + REPARSE_IGNORE = 32, // Do not reparse:-) + REPARSE_FAIL = 64 // Do not reparse and raise a warning + }; + + static QString flagsString(int reparseFlags); signals: void requestReparse(int reparseParameters) const; diff --git a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp index 77e660d3dd0..fb3a73a6d14 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp @@ -55,6 +55,8 @@ #include #include +#include + using namespace ProjectExplorer; using namespace Utils; @@ -75,6 +77,8 @@ Q_DECLARE_METATYPE(CMakeProjectManager::CMakeExtraBuildInfo) namespace CMakeProjectManager { namespace Internal { +Q_LOGGING_CATEGORY(cmakeBuildConfigurationLog, "qtc.cmake.bc", QtWarningMsg); + const char CONFIGURATION_KEY[] = "CMake.Configuration"; CMakeBuildConfiguration::CMakeBuildConfiguration(Target *parent, Core::Id id) @@ -89,8 +93,11 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *parent, Core::Id id) // BuildDirManager: connect(&m_buildDirManager, &BuildDirManager::requestReparse, this, [this](int options) { - if (isActive()) + if (isActive()) { + qCDebug(cmakeBuildConfigurationLog) + << "Passing on reparse request with flags" << BuildDirManager::flagsString(options); project()->requestReparse(options); + } }); connect(&m_buildDirManager, &BuildDirManager::dataAvailable, @@ -111,7 +118,6 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *parent, Core::Id id) connect(KitManager::instance(), &KitManager::kitUpdated, this, [this](Kit *k) { if (k != target()->kit()) return; // not for us... - // Build configuration has not changed, but Kit settings might have: // reparse and check the configuration, independent of whether the reader has changed m_buildDirManager.setParametersAndRequestParse(BuildDirParameters(this), diff --git a/src/plugins/cmakeprojectmanager/fileapireader.cpp b/src/plugins/cmakeprojectmanager/fileapireader.cpp index 377553563b7..a984231082e 100644 --- a/src/plugins/cmakeprojectmanager/fileapireader.cpp +++ b/src/plugins/cmakeprojectmanager/fileapireader.cpp @@ -124,7 +124,7 @@ void FileApiReader::resetData() void FileApiReader::parse(bool forceCMakeRun, bool forceConfiguration) { - qCDebug(cmakeFileApiMode) << "\n\nParse: ForceCMakeRun:" << forceCMakeRun + qCDebug(cmakeFileApiMode) << "Parse called with arguments: ForceCMakeRun:" << forceCMakeRun << " - forceConfiguration:" << forceConfiguration; startState();