diff --git a/src/plugins/qbsprojectmanager/qbsprojectparser.cpp b/src/plugins/qbsprojectmanager/qbsprojectparser.cpp index a31435f4292..77b0ebbb80d 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectparser.cpp +++ b/src/plugins/qbsprojectmanager/qbsprojectparser.cpp @@ -49,6 +49,7 @@ namespace Internal { QbsProjectParser::QbsProjectParser(QbsProject *project, QFutureInterface *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) diff --git a/src/plugins/qbsprojectmanager/qbsprojectparser.h b/src/plugins/qbsprojectmanager/qbsprojectparser.h index 4033725dc49..d50c2ab9e27 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectparser.h +++ b/src/plugins/qbsprojectmanager/qbsprojectparser.h @@ -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; diff --git a/src/shared/qbs b/src/shared/qbs index 8b2decf0b9b..451e5ee7778 160000 --- a/src/shared/qbs +++ b/src/shared/qbs @@ -1 +1 @@ -Subproject commit 8b2decf0b9bd2c53b742db148802b4e08bfa73ba +Subproject commit 451e5ee77786296a37bad864aca9c44d11bbee9d