forked from qt-creator/qt-creator
CMakeBuildStep: Employ task tree for running
Remove emitting 100% progress on finish, as that's done automatically by the task tree. Task-number: QTCREATORBUG-29168 Change-Id: I468fd2c12ffda4c051a46e586fc18214598269f9 Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
@@ -57,7 +57,24 @@ const char CLEAR_SYSTEM_ENVIRONMENT_KEY[] = "CMakeProjectManager.MakeStep.ClearS
|
|||||||
const char USER_ENVIRONMENT_CHANGES_KEY[] = "CMakeProjectManager.MakeStep.UserEnvironmentChanges";
|
const char USER_ENVIRONMENT_CHANGES_KEY[] = "CMakeProjectManager.MakeStep.UserEnvironmentChanges";
|
||||||
const char BUILD_PRESET_KEY[] = "CMakeProjectManager.MakeStep.BuildPreset";
|
const char BUILD_PRESET_KEY[] = "CMakeProjectManager.MakeStep.BuildPreset";
|
||||||
|
|
||||||
// CmakeProgressParser
|
class ProjectParserTaskAdapter : public Tasking::TaskAdapter<QPointer<Target>>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void start() final {
|
||||||
|
Target *target = *task();
|
||||||
|
if (!target) {
|
||||||
|
emit done(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
connect(target, &Target::parsingFinished, this, &TaskInterface::done);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CMakeProjectManager::Internal
|
||||||
|
|
||||||
|
TASKING_DECLARE_TASK(ProjectParserTask, CMakeProjectManager::Internal::ProjectParserTaskAdapter);
|
||||||
|
|
||||||
|
namespace CMakeProjectManager::Internal {
|
||||||
|
|
||||||
class CmakeProgressParser : public Utils::OutputLineParser
|
class CmakeProgressParser : public Utils::OutputLineParser
|
||||||
{
|
{
|
||||||
@@ -253,11 +270,6 @@ CMakeBuildStep::CMakeBuildStep(BuildStepList *bsl, Id id) :
|
|||||||
|
|
||||||
connect(target(), &Target::activeRunConfigurationChanged,
|
connect(target(), &Target::activeRunConfigurationChanged,
|
||||||
this, &CMakeBuildStep::updateBuildTargetsModel);
|
this, &CMakeBuildStep::updateBuildTargetsModel);
|
||||||
|
|
||||||
setDoneHook([this](bool) {
|
|
||||||
updateDeploymentData();
|
|
||||||
emit progress(100, {});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap CMakeBuildStep::toMap() const
|
QVariantMap CMakeBuildStep::toMap() const
|
||||||
@@ -337,40 +349,39 @@ void CMakeBuildStep::setupOutputFormatter(Utils::OutputFormatter *formatter)
|
|||||||
|
|
||||||
void CMakeBuildStep::doRun()
|
void CMakeBuildStep::doRun()
|
||||||
{
|
{
|
||||||
// Make sure CMake state was written to disk before trying to build:
|
using namespace Tasking;
|
||||||
auto bs = static_cast<CMakeBuildSystem *>(buildSystem());
|
|
||||||
QString message;
|
|
||||||
if (bs->persistCMakeState()) {
|
|
||||||
message = Tr::tr("Persisting CMake state...");
|
|
||||||
} else if (bs->isWaitingForParse()) {
|
|
||||||
message = Tr::tr("Running CMake in preparation to build...");
|
|
||||||
} else {
|
|
||||||
runImpl();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
emit addOutput(message, OutputFormat::NormalMessage);
|
|
||||||
m_runTrigger = connect(target(), &Target::parsingFinished,
|
|
||||||
this, [this](bool success) { handleProjectWasParsed(success); });
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMakeBuildStep::runImpl()
|
const auto onParserSetup = [this](QPointer<Target> &parseTarget) {
|
||||||
{
|
// Make sure CMake state was written to disk before trying to build:
|
||||||
// Do the actual build:
|
auto bs = qobject_cast<CMakeBuildSystem *>(buildSystem());
|
||||||
CMakeAbstractProcessStep::doRun();
|
QTC_ASSERT(bs, return SetupResult::StopWithError);
|
||||||
}
|
QString message;
|
||||||
|
if (bs->persistCMakeState())
|
||||||
void CMakeBuildStep::handleProjectWasParsed(bool success)
|
message = Tr::tr("Persisting CMake state...");
|
||||||
{
|
else if (bs->isWaitingForParse())
|
||||||
disconnect(m_runTrigger);
|
message = Tr::tr("Running CMake in preparation to build...");
|
||||||
if (isCanceled()) {
|
else
|
||||||
emit finished(false);
|
return SetupResult::StopWithDone;
|
||||||
} else if (success) {
|
emit addOutput(message, OutputFormat::NormalMessage);
|
||||||
runImpl();
|
parseTarget = target();
|
||||||
} else {
|
return SetupResult::Continue;
|
||||||
|
};
|
||||||
|
const auto onParserError = [this](const QPointer<Target> &) {
|
||||||
emit addOutput(Tr::tr("Project did not parse successfully, cannot build."),
|
emit addOutput(Tr::tr("Project did not parse successfully, cannot build."),
|
||||||
OutputFormat::ErrorMessage);
|
OutputFormat::ErrorMessage);
|
||||||
emit finished(false);
|
};
|
||||||
}
|
const auto onEnd = [this] {
|
||||||
|
updateDeploymentData();
|
||||||
|
};
|
||||||
|
const Group root {
|
||||||
|
ignoreReturnValue() ? finishAllAndDone : stopOnError,
|
||||||
|
ProjectParserTask(onParserSetup, {}, onParserError),
|
||||||
|
defaultProcessTask(),
|
||||||
|
onGroupDone(onEnd),
|
||||||
|
onGroupError(onEnd)
|
||||||
|
};
|
||||||
|
|
||||||
|
runTaskTree(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CMakeBuildStep::defaultBuildTarget() const
|
QString CMakeBuildStep::defaultBuildTarget() const
|
||||||
|
@@ -91,16 +91,11 @@ private:
|
|||||||
QString defaultBuildTarget() const;
|
QString defaultBuildTarget() const;
|
||||||
bool isCleanStep() const;
|
bool isCleanStep() const;
|
||||||
|
|
||||||
void runImpl();
|
|
||||||
void handleProjectWasParsed(bool success);
|
|
||||||
|
|
||||||
void handleBuildTargetsChanges(bool success);
|
void handleBuildTargetsChanges(bool success);
|
||||||
void recreateBuildTargetsModel();
|
void recreateBuildTargetsModel();
|
||||||
void updateBuildTargetsModel();
|
void updateBuildTargetsModel();
|
||||||
void updateDeploymentData();
|
void updateDeploymentData();
|
||||||
|
|
||||||
QMetaObject::Connection m_runTrigger;
|
|
||||||
|
|
||||||
friend class CMakeBuildStepConfigWidget;
|
friend class CMakeBuildStepConfigWidget;
|
||||||
QStringList m_buildTargets; // Convention: Empty string member signifies "Current executable"
|
QStringList m_buildTargets; // Convention: Empty string member signifies "Current executable"
|
||||||
Utils::StringAspect *m_cmakeArguments = nullptr;
|
Utils::StringAspect *m_cmakeArguments = nullptr;
|
||||||
|
Reference in New Issue
Block a user