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 <QDir>
#include <QLoggingCategory>
#include <QMessageBox>
#include <QPushButton>
#include <QSet>
@@ -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 = "<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()
{
CMakeBuildConfiguration *bc = buildConfiguration();

View File

@@ -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;

View File

@@ -55,6 +55,8 @@
#include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
#include <QLoggingCategory>
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),

View File

@@ -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();