Commit a57e7588 authored by Christian Kandeler's avatar Christian Kandeler
Browse files

QbsProjectManager: Execute rules when parsing a project.



This makes information about build artifacts available before the actual
build starts (as far as the rule implementations allow that), at the
cost of a higher initial project resolving time.

Task-number: QBS-901
Change-Id: I0a223db85001136d359a53d4edc7239350f01701
Reviewed-by: default avatarUlf Hermann <ulf.hermann@theqtcompany.com>
Reviewed-by: default avatarJake Petroules <jake.petroules@theqtcompany.com>
parent da3f3eec
......@@ -49,6 +49,7 @@ namespace Internal {
QbsProjectParser::QbsProjectParser(QbsProject *project, QFutureInterface<bool> *fi) :
m_qbsSetupProjectJob(0),
m_ruleExecutionJob(0),
m_fi(fi),
m_currentProgressBase(0)
{
......@@ -64,6 +65,12 @@ QbsProjectParser::~QbsProjectParser()
m_qbsSetupProjectJob->deleteLater();
m_qbsSetupProjectJob = 0;
}
if (m_ruleExecutionJob) {
m_ruleExecutionJob->disconnect(this);
m_ruleExecutionJob->cancel();
m_ruleExecutionJob->deleteLater();
m_ruleExecutionJob = 0;
}
m_fi = 0; // we do not own m_fi, do not delete
}
......@@ -110,7 +117,10 @@ void QbsProjectParser::parse(const QVariantMap &config, const Environment &env,
void QbsProjectParser::cancel()
{
QTC_ASSERT(m_qbsSetupProjectJob, return);
m_qbsSetupProjectJob->cancel();
if (m_ruleExecutionJob)
m_ruleExecutionJob->cancel();
else
m_qbsSetupProjectJob->cancel();
}
qbs::Project QbsProjectParser::qbsProject() const
......@@ -133,7 +143,33 @@ void QbsProjectParser::handleQbsParsingDone(bool success)
// Do not report the operation as canceled here, as we might want to make overlapping
// parses appear atomic to the user.
emit done(success);
if (!success)
emit done(false);
else
startRuleExecution();
}
void QbsProjectParser::startRuleExecution()
{
qbs::BuildOptions options;
options.setExecuteRulesOnly(true);
m_ruleExecutionJob = m_project.buildAllProducts(
options, qbs::Project::ProductSelectionWithNonDefault, this);
connect(m_ruleExecutionJob, &qbs::AbstractJob::finished,
this, &QbsProjectParser::handleRuleExecutionDone);
connect(m_ruleExecutionJob, &qbs::AbstractJob::taskStarted,
this, &QbsProjectParser::handleQbsParsingTaskSetup);
connect(m_ruleExecutionJob, &qbs::AbstractJob::taskProgress,
this, &QbsProjectParser::handleQbsParsingProgress);
}
void QbsProjectParser::handleRuleExecutionDone()
{
QTC_ASSERT(m_ruleExecutionJob, return);
// We always report success here, since execution of some very dynamic rules might fail due
// to artifacts not being present. No genuine errors will get lost, as they will re-appear
// on the next build attempt.
emit done(true);
}
void QbsProjectParser::handleQbsParsingProgress(int progress)
......
......@@ -66,8 +66,12 @@ private:
QString resourcesBaseDirectory() const;
QString libExecDirectory() const;
void startRuleExecution();
void handleRuleExecutionDone();
QString m_projectFilePath;
qbs::SetupProjectJob *m_qbsSetupProjectJob;
qbs::BuildJob *m_ruleExecutionJob;
qbs::ErrorInfo m_error;
qbs::Project m_project;
......
Subproject commit 8b2decf0b9bd2c53b742db148802b4e08bfa73ba
Subproject commit 451e5ee77786296a37bad864aca9c44d11bbee9d
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment