forked from qt-creator/qt-creator
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:
@@ -208,8 +208,7 @@ void BuildDirManager::stopParsingAndClearState()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BuildDirManager::setParametersAndRequestParse(const BuildDirParameters ¶meters,
|
void BuildDirManager::setParametersAndRequestParse(const BuildDirParameters ¶meters,
|
||||||
int newReaderReparseOptions,
|
int reparseOptions)
|
||||||
int existingReaderReparseOptions)
|
|
||||||
{
|
{
|
||||||
if (!parameters.cmakeTool()) {
|
if (!parameters.cmakeTool()) {
|
||||||
TaskHub::addTask(Task::Error,
|
TaskHub::addTask(Task::Error,
|
||||||
@@ -219,18 +218,13 @@ void BuildDirManager::setParametersAndRequestParse(const BuildDirParameters &par
|
|||||||
}
|
}
|
||||||
QTC_ASSERT(parameters.isValid(), return );
|
QTC_ASSERT(parameters.isValid(), return );
|
||||||
|
|
||||||
BuildDirReader *old = m_reader.get();
|
|
||||||
stopParsingAndClearState();
|
stopParsingAndClearState();
|
||||||
|
|
||||||
m_parameters = parameters;
|
m_parameters = parameters;
|
||||||
m_parameters.workDirectory = workDirectory(parameters);
|
m_parameters.workDirectory = workDirectory(parameters);
|
||||||
|
|
||||||
updateReaderType(m_parameters,
|
updateReaderType(m_parameters,
|
||||||
[this, old, newReaderReparseOptions, existingReaderReparseOptions]() {
|
[this, reparseOptions]() { emit requestReparse(reparseOptions); });
|
||||||
int options = (old != m_reader.get()) ? newReaderReparseOptions
|
|
||||||
: existingReaderReparseOptions;
|
|
||||||
emit requestReparse(options);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CMakeBuildConfiguration *BuildDirManager::buildConfiguration() const
|
CMakeBuildConfiguration *BuildDirManager::buildConfiguration() const
|
||||||
@@ -277,10 +271,8 @@ bool BuildDirManager::persistCMakeState()
|
|||||||
BuildDirParameters newParameters = m_parameters;
|
BuildDirParameters newParameters = m_parameters;
|
||||||
newParameters.workDirectory.clear();
|
newParameters.workDirectory.clear();
|
||||||
setParametersAndRequestParse(newParameters,
|
setParametersAndRequestParse(newParameters,
|
||||||
REPARSE_URGENT
|
REPARSE_URGENT | REPARSE_FORCE_CMAKE_RUN
|
||||||
| REPARSE_FORCE_CMAKE_RUN | REPARSE_FORCE_CONFIGURATION
|
| REPARSE_FORCE_CONFIGURATION | REPARSE_CHECK_CONFIGURATION);
|
||||||
| REPARSE_CHECK_CONFIGURATION,
|
|
||||||
REPARSE_FAIL);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,7 +283,6 @@ void BuildDirManager::parse(int 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_IGNORE) == 0, return);
|
QTC_ASSERT((reparseParameters & REPARSE_IGNORE) == 0, return);
|
||||||
|
|
||||||
m_reader->stop();
|
m_reader->stop();
|
||||||
@@ -435,8 +426,6 @@ QString BuildDirManager::flagsString(int reparseFlags)
|
|||||||
result += " SCAN";
|
result += " SCAN";
|
||||||
if (reparseFlags & REPARSE_IGNORE)
|
if (reparseFlags & REPARSE_IGNORE)
|
||||||
result += " IGNORE";
|
result += " IGNORE";
|
||||||
if (reparseFlags & REPARSE_FAIL)
|
|
||||||
result += " FAIL";
|
|
||||||
}
|
}
|
||||||
return result.trimmed();
|
return result.trimmed();
|
||||||
}
|
}
|
||||||
|
@@ -66,9 +66,7 @@ public:
|
|||||||
|
|
||||||
void stopParsingAndClearState();
|
void stopParsingAndClearState();
|
||||||
|
|
||||||
void setParametersAndRequestParse(const BuildDirParameters ¶meters,
|
void setParametersAndRequestParse(const BuildDirParameters ¶meters, int reparseOptions);
|
||||||
int newReaderReparseOptions,
|
|
||||||
int existingReaderReparseOptions);
|
|
||||||
// nullptr if the BC is not active anymore!
|
// nullptr if the BC is not active anymore!
|
||||||
CMakeBuildConfiguration *buildConfiguration() const;
|
CMakeBuildConfiguration *buildConfiguration() const;
|
||||||
CMakeProject *project() const {return m_project; }
|
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_CHECK_CONFIGURATION = 8, // Check and warn if on-disk config and QtC config differ
|
||||||
REPARSE_SCAN = 16,
|
REPARSE_SCAN = 16,
|
||||||
REPARSE_IGNORE = 32, // Do not reparse:-)
|
REPARSE_IGNORE = 32, // Do not reparse:-)
|
||||||
REPARSE_FAIL = 64 // Do not reparse and raise a warning
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static QString flagsString(int reparseFlags);
|
static QString flagsString(int reparseFlags);
|
||||||
|
@@ -121,7 +121,6 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *parent, Core::Id id)
|
|||||||
// 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),
|
||||||
BuildDirManager::REPARSE_CHECK_CONFIGURATION,
|
|
||||||
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
|
// * run cmake without configuration arguments if the reader stays
|
||||||
m_buildDirManager
|
m_buildDirManager
|
||||||
.setParametersAndRequestParse(BuildDirParameters(this),
|
.setParametersAndRequestParse(BuildDirParameters(this),
|
||||||
BuildDirManager::REPARSE_CHECK_CONFIGURATION,
|
|
||||||
BuildDirManager::REPARSE_CHECK_CONFIGURATION);
|
BuildDirManager::REPARSE_CHECK_CONFIGURATION);
|
||||||
} else {
|
} else {
|
||||||
m_buildDirManager.stopParsingAndClearState();
|
m_buildDirManager.stopParsingAndClearState();
|
||||||
@@ -146,10 +144,9 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *parent, Core::Id id)
|
|||||||
// The environment on our BC has changed:
|
// The environment on our BC has changed:
|
||||||
// * Error out if the reader updates, cannot happen since all BCs share a target/kit.
|
// * Error out if the reader updates, cannot happen since all BCs share a target/kit.
|
||||||
// * run cmake without configuration arguments if the reader stays
|
// * run cmake without configuration arguments if the reader stays
|
||||||
m_buildDirManager.setParametersAndRequestParse(
|
m_buildDirManager
|
||||||
BuildDirParameters(this),
|
.setParametersAndRequestParse(BuildDirParameters(this),
|
||||||
BuildDirManager::REPARSE_CHECK_CONFIGURATION, // server-mode might need a restart...
|
BuildDirManager::REPARSE_CHECK_CONFIGURATION);
|
||||||
BuildDirManager::REPARSE_CHECK_CONFIGURATION);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connect(this, &CMakeBuildConfiguration::buildDirectoryChanged, this, [this]() {
|
connect(this, &CMakeBuildConfiguration::buildDirectoryChanged, this, [this]() {
|
||||||
@@ -161,7 +158,6 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *parent, Core::Id id)
|
|||||||
// the reader.
|
// the reader.
|
||||||
m_buildDirManager
|
m_buildDirManager
|
||||||
.setParametersAndRequestParse(BuildDirParameters(this),
|
.setParametersAndRequestParse(BuildDirParameters(this),
|
||||||
BuildDirManager::REPARSE_FAIL,
|
|
||||||
BuildDirManager::REPARSE_CHECK_CONFIGURATION);
|
BuildDirManager::REPARSE_CHECK_CONFIGURATION);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -172,7 +168,6 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *parent, Core::Id id)
|
|||||||
// * run cmake with configuration arguments if the reader stays
|
// * run cmake with configuration arguments if the reader stays
|
||||||
m_buildDirManager
|
m_buildDirManager
|
||||||
.setParametersAndRequestParse(BuildDirParameters(this),
|
.setParametersAndRequestParse(BuildDirParameters(this),
|
||||||
BuildDirManager::REPARSE_FAIL,
|
|
||||||
BuildDirManager::REPARSE_FORCE_CONFIGURATION);
|
BuildDirManager::REPARSE_FORCE_CONFIGURATION);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -316,8 +316,6 @@ void CMakeProject::runCMake()
|
|||||||
BuildDirParameters parameters(bc);
|
BuildDirParameters parameters(bc);
|
||||||
bc->m_buildDirManager
|
bc->m_buildDirManager
|
||||||
.setParametersAndRequestParse(parameters,
|
.setParametersAndRequestParse(parameters,
|
||||||
BuildDirManager::REPARSE_CHECK_CONFIGURATION
|
|
||||||
| BuildDirManager::REPARSE_FORCE_CMAKE_RUN,
|
|
||||||
BuildDirManager::REPARSE_CHECK_CONFIGURATION
|
BuildDirManager::REPARSE_CHECK_CONFIGURATION
|
||||||
| BuildDirManager::REPARSE_FORCE_CMAKE_RUN);
|
| BuildDirManager::REPARSE_FORCE_CMAKE_RUN);
|
||||||
}
|
}
|
||||||
@@ -331,8 +329,6 @@ void CMakeProject::runCMakeAndScanProjectTree()
|
|||||||
|
|
||||||
BuildDirParameters parameters(bc);
|
BuildDirParameters parameters(bc);
|
||||||
bc->m_buildDirManager.setParametersAndRequestParse(parameters,
|
bc->m_buildDirManager.setParametersAndRequestParse(parameters,
|
||||||
BuildDirManager::REPARSE_CHECK_CONFIGURATION
|
|
||||||
| BuildDirManager::REPARSE_SCAN,
|
|
||||||
BuildDirManager::REPARSE_CHECK_CONFIGURATION
|
BuildDirManager::REPARSE_CHECK_CONFIGURATION
|
||||||
| BuildDirManager::REPARSE_SCAN);
|
| BuildDirManager::REPARSE_SCAN);
|
||||||
}
|
}
|
||||||
@@ -369,7 +365,6 @@ void CMakeProject::startParsing(int reparseParameters)
|
|||||||
{
|
{
|
||||||
m_delayedParsingParameters = BuildDirManager::REPARSE_DEFAULT;
|
m_delayedParsingParameters = BuildDirManager::REPARSE_DEFAULT;
|
||||||
|
|
||||||
QTC_ASSERT((reparseParameters & BuildDirManager::REPARSE_FAIL) == 0, return);
|
|
||||||
if (reparseParameters & BuildDirManager::REPARSE_IGNORE)
|
if (reparseParameters & BuildDirManager::REPARSE_IGNORE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -417,7 +412,6 @@ void CMakeProject::reportError(const QString &errorMessage) const
|
|||||||
|
|
||||||
void CMakeProject::requestReparse(int reparseParameters)
|
void CMakeProject::requestReparse(int reparseParameters)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(!(reparseParameters & BuildDirManager::REPARSE_FAIL), return );
|
|
||||||
if (reparseParameters & BuildDirManager::REPARSE_IGNORE)
|
if (reparseParameters & BuildDirManager::REPARSE_IGNORE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user