CMake: Simplify setting up a new reader

There is no need to reset a reader when e.g. the build directory changes
when the server-mode reader is *not* used. So the one case where having
separate reparse-options for the case where the reader changes and the
case where it stays the same is bogus.

So unify the flags into one set and simplify the code accordingly.

Change-Id: I9bcfcc6333d574d49513ef1256a9a8597bda4ec7
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Tobias Hunger
2019-08-09 13:11:03 +02:00
parent d880f1f771
commit 200b04f9ca
4 changed files with 8 additions and 33 deletions

View File

@@ -208,8 +208,7 @@ void BuildDirManager::stopParsingAndClearState()
}
void BuildDirManager::setParametersAndRequestParse(const BuildDirParameters &parameters,
int newReaderReparseOptions,
int existingReaderReparseOptions)
int reparseOptions)
{
if (!parameters.cmakeTool()) {
TaskHub::addTask(Task::Error,
@@ -219,18 +218,13 @@ void BuildDirManager::setParametersAndRequestParse(const BuildDirParameters &par
}
QTC_ASSERT(parameters.isValid(), return );
BuildDirReader *old = m_reader.get();
stopParsingAndClearState();
m_parameters = parameters;
m_parameters.workDirectory = workDirectory(parameters);
updateReaderType(m_parameters,
[this, old, newReaderReparseOptions, existingReaderReparseOptions]() {
int options = (old != m_reader.get()) ? newReaderReparseOptions
: existingReaderReparseOptions;
emit requestReparse(options);
});
[this, reparseOptions]() { emit requestReparse(reparseOptions); });
}
CMakeBuildConfiguration *BuildDirManager::buildConfiguration() const
@@ -277,10 +271,8 @@ bool BuildDirManager::persistCMakeState()
BuildDirParameters newParameters = m_parameters;
newParameters.workDirectory.clear();
setParametersAndRequestParse(newParameters,
REPARSE_URGENT
| REPARSE_FORCE_CMAKE_RUN | REPARSE_FORCE_CONFIGURATION
| REPARSE_CHECK_CONFIGURATION,
REPARSE_FAIL);
REPARSE_URGENT | REPARSE_FORCE_CMAKE_RUN
| REPARSE_FORCE_CONFIGURATION | REPARSE_CHECK_CONFIGURATION);
return true;
}
@@ -291,7 +283,6 @@ void BuildDirManager::parse(int 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);
m_reader->stop();
@@ -435,8 +426,6 @@ QString BuildDirManager::flagsString(int reparseFlags)
result += " SCAN";
if (reparseFlags & REPARSE_IGNORE)
result += " IGNORE";
if (reparseFlags & REPARSE_FAIL)
result += " FAIL";
}
return result.trimmed();
}

View File

@@ -66,9 +66,7 @@ public:
void stopParsingAndClearState();
void setParametersAndRequestParse(const BuildDirParameters &parameters,
int newReaderReparseOptions,
int existingReaderReparseOptions);
void setParametersAndRequestParse(const BuildDirParameters &parameters, int reparseOptions);
// nullptr if the BC is not active anymore!
CMakeBuildConfiguration *buildConfiguration() const;
CMakeProject *project() const {return m_project; }
@@ -99,7 +97,6 @@ public:
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);

View File

@@ -121,7 +121,6 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *parent, Core::Id id)
// 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),
BuildDirManager::REPARSE_CHECK_CONFIGURATION,
BuildDirManager::REPARSE_CHECK_CONFIGURATION);
});
@@ -133,7 +132,6 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *parent, Core::Id id)
// * run cmake without configuration arguments if the reader stays
m_buildDirManager
.setParametersAndRequestParse(BuildDirParameters(this),
BuildDirManager::REPARSE_CHECK_CONFIGURATION,
BuildDirManager::REPARSE_CHECK_CONFIGURATION);
} else {
m_buildDirManager.stopParsingAndClearState();
@@ -146,9 +144,8 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *parent, Core::Id id)
// The environment on our BC has changed:
// * Error out if the reader updates, cannot happen since all BCs share a target/kit.
// * run cmake without configuration arguments if the reader stays
m_buildDirManager.setParametersAndRequestParse(
BuildDirParameters(this),
BuildDirManager::REPARSE_CHECK_CONFIGURATION, // server-mode might need a restart...
m_buildDirManager
.setParametersAndRequestParse(BuildDirParameters(this),
BuildDirManager::REPARSE_CHECK_CONFIGURATION);
}
});
@@ -161,7 +158,6 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *parent, Core::Id id)
// the reader.
m_buildDirManager
.setParametersAndRequestParse(BuildDirParameters(this),
BuildDirManager::REPARSE_FAIL,
BuildDirManager::REPARSE_CHECK_CONFIGURATION);
}
});
@@ -172,7 +168,6 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *parent, Core::Id id)
// * run cmake with configuration arguments if the reader stays
m_buildDirManager
.setParametersAndRequestParse(BuildDirParameters(this),
BuildDirManager::REPARSE_FAIL,
BuildDirManager::REPARSE_FORCE_CONFIGURATION);
}
});

View File

@@ -316,8 +316,6 @@ void CMakeProject::runCMake()
BuildDirParameters parameters(bc);
bc->m_buildDirManager
.setParametersAndRequestParse(parameters,
BuildDirManager::REPARSE_CHECK_CONFIGURATION
| BuildDirManager::REPARSE_FORCE_CMAKE_RUN,
BuildDirManager::REPARSE_CHECK_CONFIGURATION
| BuildDirManager::REPARSE_FORCE_CMAKE_RUN);
}
@@ -331,8 +329,6 @@ void CMakeProject::runCMakeAndScanProjectTree()
BuildDirParameters parameters(bc);
bc->m_buildDirManager.setParametersAndRequestParse(parameters,
BuildDirManager::REPARSE_CHECK_CONFIGURATION
| BuildDirManager::REPARSE_SCAN,
BuildDirManager::REPARSE_CHECK_CONFIGURATION
| BuildDirManager::REPARSE_SCAN);
}
@@ -369,7 +365,6 @@ void CMakeProject::startParsing(int reparseParameters)
{
m_delayedParsingParameters = BuildDirManager::REPARSE_DEFAULT;
QTC_ASSERT((reparseParameters & BuildDirManager::REPARSE_FAIL) == 0, return);
if (reparseParameters & BuildDirManager::REPARSE_IGNORE)
return;
@@ -417,7 +412,6 @@ void CMakeProject::reportError(const QString &errorMessage) const
void CMakeProject::requestReparse(int reparseParameters)
{
QTC_ASSERT(!(reparseParameters & BuildDirManager::REPARSE_FAIL), return );
if (reparseParameters & BuildDirManager::REPARSE_IGNORE)
return;