forked from qt-creator/qt-creator
QbsProjectManager: Do not reparse the project after every build.
While it is true that additional information about target artifacts can appear during a build, this data is already present in the qbs::Project object and can simply be retrieved. No reparsing is necessary. The exception is when reparsing was requested while the build was going on. In that case, we really need to do it after the build has finished. Change-Id: Ief3797782ad0ca5651974d4b5d3d64e1199ca9a5 Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
This commit is contained in:
@@ -243,24 +243,25 @@ void QbsBuildStep::buildingDone(bool success)
|
|||||||
item.codeLocation().fileName(), item.codeLocation().line());
|
item.codeLocation().fileName(), item.codeLocation().line());
|
||||||
|
|
||||||
QbsProject *pro = static_cast<QbsProject *>(project());
|
QbsProject *pro = static_cast<QbsProject *>(project());
|
||||||
connect(pro, SIGNAL(projectParsingDone(bool)), this, SLOT(reparsingDone()));
|
|
||||||
|
|
||||||
// Building can uncover additional target artifacts.
|
// Building can uncover additional target artifacts.
|
||||||
// Wait for reparsing to finish, since before that our run configurations may not be valid.
|
pro->updateAfterBuild();
|
||||||
|
|
||||||
|
// The reparsing, if it is necessary, has to be done before finished() is emitted, as
|
||||||
|
// otherwise a potential additional build step could conflict with the parsing step.
|
||||||
|
if (pro->parsingScheduled()) {
|
||||||
|
connect(pro, SIGNAL(projectParsingDone(bool)), this, SLOT(reparsingDone()));
|
||||||
pro->parseCurrentBuildConfiguration(true);
|
pro->parseCurrentBuildConfiguration(true);
|
||||||
|
} else {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QbsBuildStep::reparsingDone()
|
void QbsBuildStep::reparsingDone()
|
||||||
{
|
{
|
||||||
disconnect(static_cast<QbsProject *>(project()), SIGNAL(projectParsingDone(bool)),
|
disconnect(static_cast<QbsProject *>(project()), SIGNAL(projectParsingDone(bool)),
|
||||||
this, SLOT(reparsingDone()));
|
this, SLOT(reparsingDone()));
|
||||||
QTC_ASSERT(m_fi, return);
|
finish();
|
||||||
m_fi->reportResult(m_lastWasSuccess);
|
|
||||||
m_fi = 0; // do not delete, it is not ours
|
|
||||||
m_job->deleteLater();
|
|
||||||
m_job = 0;
|
|
||||||
|
|
||||||
emit finished();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QbsBuildStep::handleTaskStarted(const QString &desciption, int max)
|
void QbsBuildStep::handleTaskStarted(const QString &desciption, int max)
|
||||||
@@ -374,6 +375,17 @@ void QbsBuildStep::setMaxJobs(int jobcount)
|
|||||||
emit qbsBuildOptionsChanged();
|
emit qbsBuildOptionsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QbsBuildStep::finish()
|
||||||
|
{
|
||||||
|
QTC_ASSERT(m_fi, return);
|
||||||
|
m_fi->reportResult(m_lastWasSuccess);
|
||||||
|
m_fi = 0; // do not delete, it is not ours
|
||||||
|
m_job->deleteLater();
|
||||||
|
m_job = 0;
|
||||||
|
|
||||||
|
emit finished();
|
||||||
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
// QbsBuildStepConfigWidget:
|
// QbsBuildStepConfigWidget:
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|||||||
@@ -98,6 +98,8 @@ private:
|
|||||||
void setCheckTimestamps(bool ts);
|
void setCheckTimestamps(bool ts);
|
||||||
void setMaxJobs(int jobcount);
|
void setMaxJobs(int jobcount);
|
||||||
|
|
||||||
|
void finish();
|
||||||
|
|
||||||
QVariantMap m_qbsConfiguration;
|
QVariantMap m_qbsConfiguration;
|
||||||
qbs::BuildOptions m_qbsBuildOptions;
|
qbs::BuildOptions m_qbsBuildOptions;
|
||||||
|
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ QbsProject::QbsProject(QbsManager *manager, const QString &fileName) :
|
|||||||
m_qbsProjectParser(0),
|
m_qbsProjectParser(0),
|
||||||
m_qbsUpdateFutureInterface(0),
|
m_qbsUpdateFutureInterface(0),
|
||||||
m_forceParsing(false),
|
m_forceParsing(false),
|
||||||
|
m_parsingScheduled(false),
|
||||||
m_currentBc(0)
|
m_currentBc(0)
|
||||||
{
|
{
|
||||||
m_parsingDelay.setInterval(1000); // delay parsing by 1s.
|
m_parsingDelay.setInterval(1000); // delay parsing by 1s.
|
||||||
@@ -358,17 +359,14 @@ void QbsProject::readQbsData()
|
|||||||
qbs::ProjectData data = m_rootProjectNode->qbsProjectData();
|
qbs::ProjectData data = m_rootProjectNode->qbsProjectData();
|
||||||
updateCppCodeModel(data);
|
updateCppCodeModel(data);
|
||||||
updateQmlJsCodeModel(data);
|
updateQmlJsCodeModel(data);
|
||||||
updateApplicationTargets(data);
|
updateBuildTargetData();
|
||||||
updateDeploymentInfo(project);
|
|
||||||
|
|
||||||
foreach (Target *t, targets())
|
|
||||||
t->updateDefaultRunConfigurations();
|
|
||||||
|
|
||||||
emit fileListChanged();
|
emit fileListChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QbsProject::parseCurrentBuildConfiguration(bool force)
|
void QbsProject::parseCurrentBuildConfiguration(bool force)
|
||||||
{
|
{
|
||||||
|
m_parsingScheduled = false;
|
||||||
if (!m_forceParsing)
|
if (!m_forceParsing)
|
||||||
m_forceParsing = force;
|
m_forceParsing = force;
|
||||||
|
|
||||||
@@ -380,6 +378,11 @@ void QbsProject::parseCurrentBuildConfiguration(bool force)
|
|||||||
parse(bc->qbsConfiguration(), bc->environment(), bc->buildDirectory().toString());
|
parse(bc->qbsConfiguration(), bc->environment(), bc->buildDirectory().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QbsProject::updateAfterBuild()
|
||||||
|
{
|
||||||
|
updateBuildTargetData();
|
||||||
|
}
|
||||||
|
|
||||||
void QbsProject::registerQbsProjectParser(QbsProjectParser *p)
|
void QbsProject::registerQbsProjectParser(QbsProjectParser *p)
|
||||||
{
|
{
|
||||||
m_parsingDelay.stop();
|
m_parsingDelay.stop();
|
||||||
@@ -647,5 +650,13 @@ void QbsProject::updateDeploymentInfo(const qbs::Project &project)
|
|||||||
activeTarget()->setDeploymentData(deploymentData);
|
activeTarget()->setDeploymentData(deploymentData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QbsProject::updateBuildTargetData()
|
||||||
|
{
|
||||||
|
updateApplicationTargets(m_qbsProject.projectData());
|
||||||
|
updateDeploymentInfo(m_qbsProject);
|
||||||
|
foreach (Target *t, targets())
|
||||||
|
t->updateDefaultRunConfigurations();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace QbsProjectManager
|
} // namespace QbsProjectManager
|
||||||
|
|||||||
@@ -94,6 +94,9 @@ public:
|
|||||||
bool isParsing() const;
|
bool isParsing() const;
|
||||||
bool hasParseResult() const;
|
bool hasParseResult() const;
|
||||||
void parseCurrentBuildConfiguration(bool force);
|
void parseCurrentBuildConfiguration(bool force);
|
||||||
|
void scheduleParsing() { m_parsingScheduled = true; }
|
||||||
|
bool parsingScheduled() const { return m_parsingScheduled; }
|
||||||
|
void updateAfterBuild();
|
||||||
|
|
||||||
void registerQbsProjectParser(QbsProjectParser *p);
|
void registerQbsProjectParser(QbsProjectParser *p);
|
||||||
|
|
||||||
@@ -136,6 +139,7 @@ private:
|
|||||||
void updateQmlJsCodeModel(const qbs::ProjectData &prj);
|
void updateQmlJsCodeModel(const qbs::ProjectData &prj);
|
||||||
void updateApplicationTargets(const qbs::ProjectData &projectData);
|
void updateApplicationTargets(const qbs::ProjectData &projectData);
|
||||||
void updateDeploymentInfo(const qbs::Project &project);
|
void updateDeploymentInfo(const qbs::Project &project);
|
||||||
|
void updateBuildTargetData();
|
||||||
|
|
||||||
QbsManager *const m_manager;
|
QbsManager *const m_manager;
|
||||||
const QString m_projectName;
|
const QString m_projectName;
|
||||||
@@ -148,6 +152,7 @@ private:
|
|||||||
|
|
||||||
QFutureInterface<bool> *m_qbsUpdateFutureInterface;
|
QFutureInterface<bool> *m_qbsUpdateFutureInterface;
|
||||||
bool m_forceParsing;
|
bool m_forceParsing;
|
||||||
|
bool m_parsingScheduled;
|
||||||
|
|
||||||
QFuture<void> m_codeModelFuture;
|
QFuture<void> m_codeModelFuture;
|
||||||
|
|
||||||
|
|||||||
@@ -514,13 +514,14 @@ void QbsProjectManagerPlugin::reparseCurrentProject()
|
|||||||
|
|
||||||
void QbsProjectManagerPlugin::reparseProject(QbsProject *project)
|
void QbsProjectManagerPlugin::reparseProject(QbsProject *project)
|
||||||
{
|
{
|
||||||
if (!project || BuildManager::isBuilding(project)) {
|
if (!project)
|
||||||
|
return;
|
||||||
|
|
||||||
// Qbs does update the build graph during the build. So we cannot
|
// Qbs does update the build graph during the build. So we cannot
|
||||||
// start to parse while a build is running or we will lose information.
|
// start to parse while a build is running or we will lose information.
|
||||||
// Just return since the qbsbuildstep will trigger a reparse after the build.
|
if (BuildManager::isBuilding(project))
|
||||||
return;
|
project->scheduleParsing();
|
||||||
}
|
else
|
||||||
|
|
||||||
project->parseCurrentBuildConfiguration(true);
|
project->parseCurrentBuildConfiguration(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user