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 <eike.ziller@qt.io>
This commit is contained in:
Tobias Hunger
2019-08-09 12:20:49 +02:00
parent 39b66f0557
commit 87f496d091
4 changed files with 58 additions and 14 deletions

View File

@@ -45,6 +45,7 @@
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QDir> #include <QDir>
#include <QLoggingCategory>
#include <QMessageBox> #include <QMessageBox>
#include <QPushButton> #include <QPushButton>
#include <QSet> #include <QSet>
@@ -55,6 +56,8 @@ using namespace Utils;
namespace CMakeProjectManager { namespace CMakeProjectManager {
namespace Internal { namespace Internal {
Q_LOGGING_CATEGORY(cmakeBuildDirManagerLog, "qtc.cmake.builddirmanager", QtWarningMsg);
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// BuildDirManager: // BuildDirManager:
// -------------------------------------------------------------------- // --------------------------------------------------------------------
@@ -283,6 +286,9 @@ bool BuildDirManager::persistCMakeState()
void BuildDirManager::parse(int reparseParameters) void BuildDirManager::parse(int reparseParameters)
{ {
qCDebug(cmakeBuildDirManagerLog)
<< "Parse called with flags:" << flagsString(reparseParameters);
QTC_ASSERT(m_parameters.isValid(), return ); QTC_ASSERT(m_parameters.isValid(), return );
QTC_ASSERT(m_reader, return); QTC_ASSERT(m_reader, return);
QTC_ASSERT((reparseParameters & REPARSE_FAIL) == 0, return); QTC_ASSERT((reparseParameters & REPARSE_FAIL) == 0, return);
@@ -294,9 +300,14 @@ void BuildDirManager::parse(int reparseParameters)
if (!m_parameters.workDirectory.toFileInfo().exists("CMakeCache.txt")) { if (!m_parameters.workDirectory.toFileInfo().exists("CMakeCache.txt")) {
reparseParameters |= REPARSE_FORCE_CONFIGURATION | REPARSE_FORCE_CMAKE_RUN; 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) { } else if (reparseParameters & REPARSE_CHECK_CONFIGURATION) {
if (checkConfiguration()) if (checkConfiguration()) {
reparseParameters |= REPARSE_FORCE_CONFIGURATION | REPARSE_FORCE_CMAKE_RUN; 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, m_reader->parse(reparseParameters & REPARSE_FORCE_CMAKE_RUN,
@@ -406,6 +417,30 @@ CMakeConfig BuildDirManager::parseCMakeConfiguration(const Utils::FilePath &cach
return result; return result;
} }
QString BuildDirManager::flagsString(int reparseFlags)
{
QString result;
if (reparseFlags == REPARSE_DEFAULT) {
result = "<NONE>";
} 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() bool BuildDirManager::checkConfiguration()
{ {
CMakeBuildConfiguration *bc = buildConfiguration(); CMakeBuildConfiguration *bc = buildConfiguration();

View File

@@ -91,7 +91,8 @@ public:
static CMakeConfig parseCMakeConfiguration(const Utils::FilePath &cacheFile, static CMakeConfig parseCMakeConfiguration(const Utils::FilePath &cacheFile,
QString *errorMessage); QString *errorMessage);
enum ReparseParameters { REPARSE_DEFAULT = 0, // use defaults enum ReparseParameters {
REPARSE_DEFAULT = 0, // use defaults
REPARSE_URGENT = 1, // Do not wait for more requests, start ASAP REPARSE_URGENT = 1, // Do not wait for more requests, start ASAP
REPARSE_FORCE_CMAKE_RUN = 2, // Force cmake to run REPARSE_FORCE_CMAKE_RUN = 2, // Force cmake to run
REPARSE_FORCE_CONFIGURATION = 4, // Force configuration arguments to cmake REPARSE_FORCE_CONFIGURATION = 4, // Force configuration arguments to cmake
@@ -101,6 +102,8 @@ public:
REPARSE_FAIL = 64 // Do not reparse and raise a warning REPARSE_FAIL = 64 // Do not reparse and raise a warning
}; };
static QString flagsString(int reparseFlags);
signals: signals:
void requestReparse(int reparseParameters) const; void requestReparse(int reparseParameters) const;
void parsingStarted() const; void parsingStarted() const;

View File

@@ -55,6 +55,8 @@
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/qtcprocess.h> #include <utils/qtcprocess.h>
#include <QLoggingCategory>
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils; using namespace Utils;
@@ -75,6 +77,8 @@ Q_DECLARE_METATYPE(CMakeProjectManager::CMakeExtraBuildInfo)
namespace CMakeProjectManager { namespace CMakeProjectManager {
namespace Internal { namespace Internal {
Q_LOGGING_CATEGORY(cmakeBuildConfigurationLog, "qtc.cmake.bc", QtWarningMsg);
const char CONFIGURATION_KEY[] = "CMake.Configuration"; const char CONFIGURATION_KEY[] = "CMake.Configuration";
CMakeBuildConfiguration::CMakeBuildConfiguration(Target *parent, Core::Id id) CMakeBuildConfiguration::CMakeBuildConfiguration(Target *parent, Core::Id id)
@@ -89,8 +93,11 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *parent, Core::Id id)
// BuildDirManager: // BuildDirManager:
connect(&m_buildDirManager, &BuildDirManager::requestReparse, this, [this](int options) { 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); project()->requestReparse(options);
}
}); });
connect(&m_buildDirManager, connect(&m_buildDirManager,
&BuildDirManager::dataAvailable, &BuildDirManager::dataAvailable,
@@ -111,7 +118,6 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *parent, Core::Id id)
connect(KitManager::instance(), &KitManager::kitUpdated, this, [this](Kit *k) { connect(KitManager::instance(), &KitManager::kitUpdated, this, [this](Kit *k) {
if (k != target()->kit()) if (k != target()->kit())
return; // not for us... return; // not for us...
// Build configuration has not changed, but Kit settings might have: // Build configuration has not changed, but Kit settings might have:
// reparse and check the configuration, independent of whether the reader has changed // reparse and check the configuration, independent of whether the reader has changed
m_buildDirManager.setParametersAndRequestParse(BuildDirParameters(this), m_buildDirManager.setParametersAndRequestParse(BuildDirParameters(this),

View File

@@ -124,7 +124,7 @@ void FileApiReader::resetData()
void FileApiReader::parse(bool forceCMakeRun, bool forceConfiguration) void FileApiReader::parse(bool forceCMakeRun, bool forceConfiguration)
{ {
qCDebug(cmakeFileApiMode) << "\n\nParse: ForceCMakeRun:" << forceCMakeRun qCDebug(cmakeFileApiMode) << "Parse called with arguments: ForceCMakeRun:" << forceCMakeRun
<< " - forceConfiguration:" << forceConfiguration; << " - forceConfiguration:" << forceConfiguration;
startState(); startState();