forked from qt-creator/qt-creator
CMakePM: Only watch for CMake index json file reply chages
Previously the whole directory was watched, and the directory can have lots of json files that would change. And since we are only interested in the index file, make sure to just watch for the index file changes. Change-Id: Ifda794dbd0c4012a1551dfbe8ecaa4f13e16259a Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -40,9 +40,9 @@ FileApiReader::FileApiReader()
|
||||
: m_lastReplyTimestamp()
|
||||
{
|
||||
QObject::connect(&m_watcher,
|
||||
&FileSystemWatcher::directoryChanged,
|
||||
&FileSystemWatcher::fileChanged,
|
||||
this,
|
||||
&FileApiReader::handleReplyDirectoryChange);
|
||||
&FileApiReader::handleReplyIndexFileChange);
|
||||
}
|
||||
|
||||
FileApiReader::~FileApiReader()
|
||||
@@ -60,11 +60,7 @@ void FileApiReader::setParameters(const BuildDirParameters &p)
|
||||
m_parameters = p;
|
||||
qCDebug(cmakeFileApiMode) << "Work directory:" << m_parameters.buildDirectory.toUserOutput();
|
||||
|
||||
FileApiParser::setupCMakeFileApi(m_parameters.buildDirectory);
|
||||
|
||||
const FilePath replyDirectory = FileApiParser::cmakeReplyDirectory(m_parameters.buildDirectory);
|
||||
if (!m_watcher.watchesDirectory(replyDirectory))
|
||||
m_watcher.addDirectory(replyDirectory.path(), FileSystemWatcher::WatchAllChanges);
|
||||
setupCMakeFileApi();
|
||||
|
||||
resetData();
|
||||
}
|
||||
@@ -351,6 +347,15 @@ void FileApiReader::writeConfigurationIntoBuildDirectory(const QStringList &conf
|
||||
QTC_ASSERT_EXPECTED(settingsFile.writeFileContents(contents), return);
|
||||
}
|
||||
|
||||
void FileApiReader::setupCMakeFileApi()
|
||||
{
|
||||
FileApiParser::setupCMakeFileApi(m_parameters.buildDirectory);
|
||||
|
||||
const FilePath replyIndexfile = FileApiParser::scanForCMakeReplyFile(m_parameters.buildDirectory);
|
||||
if (!replyIndexfile.isEmpty() && !m_watcher.watchesFile(replyIndexfile))
|
||||
m_watcher.addFile(replyIndexfile.path(), FileSystemWatcher::WatchAllChanges);
|
||||
}
|
||||
|
||||
QString FileApiReader::cmakeGenerator() const
|
||||
{
|
||||
return m_cmakeGenerator;
|
||||
@@ -403,16 +408,13 @@ void FileApiReader::cmakeFinishedState(int exitCode)
|
||||
if (m_lastCMakeExitCode != 0)
|
||||
makeBackupConfiguration(false);
|
||||
|
||||
FileApiParser::setupCMakeFileApi(m_parameters.buildDirectory);
|
||||
|
||||
m_watcher.addDirectory(FileApiParser::cmakeReplyDirectory(m_parameters.buildDirectory).path(),
|
||||
FileSystemWatcher::WatchAllChanges);
|
||||
setupCMakeFileApi();
|
||||
|
||||
endState(FileApiParser::scanForCMakeReplyFile(m_parameters.buildDirectory),
|
||||
m_lastCMakeExitCode != 0);
|
||||
}
|
||||
|
||||
void FileApiReader::handleReplyDirectoryChange(const QString &directory)
|
||||
void FileApiReader::handleReplyIndexFileChange(const QString &indexFile)
|
||||
{
|
||||
if (m_isParsing)
|
||||
return; // This has been triggered by ourselves, ignore.
|
||||
@@ -422,7 +424,7 @@ void FileApiReader::handleReplyDirectoryChange(const QString &directory)
|
||||
if (dir.isEmpty())
|
||||
return; // CMake started to fill the result dir, but has not written a result file yet
|
||||
QTC_CHECK(dir.isLocal());
|
||||
QTC_ASSERT(dir.path() == directory, return);
|
||||
QTC_ASSERT(dir == FilePath::fromString(indexFile).parentDir(), return);
|
||||
|
||||
if (m_lastReplyTimestamp.isValid() && reply.lastModified() > m_lastReplyTimestamp) {
|
||||
m_lastReplyTimestamp = reply.lastModified();
|
||||
|
@@ -78,10 +78,11 @@ private:
|
||||
void startCMakeState(const QStringList &configurationArguments);
|
||||
void cmakeFinishedState(int exitCode);
|
||||
|
||||
void handleReplyDirectoryChange(const QString &directory);
|
||||
void handleReplyIndexFileChange(const QString &indexFile);
|
||||
void makeBackupConfiguration(bool store);
|
||||
|
||||
void writeConfigurationIntoBuildDirectory(const QStringList &configuration);
|
||||
void setupCMakeFileApi();
|
||||
|
||||
std::unique_ptr<CMakeProcess> m_cmakeProcess;
|
||||
|
||||
|
Reference in New Issue
Block a user