From f048cfa84607b531f29b8d8c6e0b7c6f1c80c2e4 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Thu, 17 May 2018 18:13:26 +0200 Subject: [PATCH] MakeStep: Fix that make command could not be set without tool chain Both the configuration widget and the build itself were complaining that a tool chain is needed, even though the build in the end cares only about the make command, not the tool chain. Change-Id: I5be0f44376a446bd76053f5365c842384d71be30 Reviewed-by: Tobias Hunger --- src/plugins/projectexplorer/makestep.cpp | 49 +++++++++++++------ src/plugins/projectexplorer/makestep.h | 4 ++ .../qmakeprojectmanager/qmakemakestep.cpp | 12 +++-- 3 files changed, 45 insertions(+), 20 deletions(-) diff --git a/src/plugins/projectexplorer/makestep.cpp b/src/plugins/projectexplorer/makestep.cpp index f1419b501b7..76fabcbf213 100644 --- a/src/plugins/projectexplorer/makestep.cpp +++ b/src/plugins/projectexplorer/makestep.cpp @@ -66,11 +66,11 @@ bool MakeStep::init(QList &earlierSteps) if (!bc) emit addTask(Task::buildConfigurationMissingTask()); - ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit(), ProjectExplorer::Constants::CXX_LANGUAGE_ID); - if (!tc) - emit addTask(Task::compilerMissingTask()); + const QString make = effectiveMakeCommand(); + if (make.isEmpty()) + emit addTask(makeCommandMissingTask()); - if (!bc || !tc) { + if (!bc || make.isEmpty()) { emitFaultyConfigurationMessage(); return false; } @@ -81,7 +81,7 @@ bool MakeStep::init(QList &earlierSteps) Utils::Environment env = bc->environment(); Utils::Environment::setupEnglishOutput(&env); pp->setEnvironment(env); - pp->setCommand(effectiveMakeCommand()); + pp->setCommand(make); pp->setArguments(allArguments()); pp->resolveAll(); @@ -114,6 +114,29 @@ QString MakeStep::defaultDisplayName() return tr("Make"); } +QString MakeStep::defaultMakeCommand() const +{ + BuildConfiguration *bc = buildConfiguration(); + ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit(), ProjectExplorer::Constants::CXX_LANGUAGE_ID); + if (bc && tc) + return tc->makeCommand(bc->environment()); + return QString(); +} + +QString MakeStep::msgNoMakeCommand() +{ + return tr("Make command missing. Specify Make command in step configuration."); +} + +Task MakeStep::makeCommandMissingTask() +{ + return Task(Task::Error, + msgNoMakeCommand(), + Utils::FileName(), + -1, + Constants::TASK_CATEGORY_BUILDSYSTEM); +} + void MakeStep::setMakeCommand(const QString &command) { m_makeCommand = command; @@ -166,11 +189,7 @@ QString MakeStep::effectiveMakeCommand() const { if (!m_makeCommand.isEmpty()) return m_makeCommand; - BuildConfiguration *bc = buildConfiguration(); - ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit(), ProjectExplorer::Constants::CXX_LANGUAGE_ID); - if (bc && tc) - return tc->makeCommand(bc->environment()); - return QString(); + return defaultMakeCommand(); } BuildStepConfigWidget *MakeStep::createConfigWidget() @@ -290,14 +309,14 @@ void MakeStepConfigWidget::updateDetails() = ToolChainKitInformation::toolChain(m_makeStep->target()->kit(), ProjectExplorer::Constants::CXX_LANGUAGE_ID); BuildConfiguration *bc = m_makeStep->buildConfiguration(); - const QString make = tc && bc ? tc->makeCommand(bc->environment()) : QString(); - if (make.isEmpty()) + const QString defaultMake = m_makeStep->defaultMakeCommand(); + if (defaultMake.isEmpty()) m_ui->makeLabel->setText(tr("Make:")); else - m_ui->makeLabel->setText(tr("Override %1:").arg(QDir::toNativeSeparators(make))); + m_ui->makeLabel->setText(tr("Override %1:").arg(QDir::toNativeSeparators(defaultMake))); - if (!tc) { - setSummaryText(tr("Make: %1").arg(ProjectExplorer::ToolChainKitInformation::msgNoToolChainInTarget())); + if (m_makeStep->effectiveMakeCommand().isEmpty()) { + setSummaryText(tr("Make: %1").arg(MakeStep::msgNoMakeCommand())); return; } if (!bc) { diff --git a/src/plugins/projectexplorer/makestep.h b/src/plugins/projectexplorer/makestep.h index 126ca68809b..e4ebe14c46e 100644 --- a/src/plugins/projectexplorer/makestep.h +++ b/src/plugins/projectexplorer/makestep.h @@ -64,6 +64,10 @@ public: static QString defaultDisplayName(); + QString defaultMakeCommand() const; + static QString msgNoMakeCommand(); + static Task makeCommandMissingTask(); + private: QVariantMap toMap() const override; bool fromMap(const QVariantMap &map) override; diff --git a/src/plugins/qmakeprojectmanager/qmakemakestep.cpp b/src/plugins/qmakeprojectmanager/qmakemakestep.cpp index 4bd69c93ef6..9e826385405 100644 --- a/src/plugins/qmakeprojectmanager/qmakemakestep.cpp +++ b/src/plugins/qmakeprojectmanager/qmakemakestep.cpp @@ -71,11 +71,11 @@ bool QmakeMakeStep::init(QList &earlierSteps) if (!bc) emit addTask(Task::buildConfigurationMissingTask()); - ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit(), ProjectExplorer::Constants::CXX_LANGUAGE_ID); - if (!tc) - emit addTask(Task::compilerMissingTask()); + const QString make = effectiveMakeCommand(); + if (make.isEmpty()) + emit addTask(makeCommandMissingTask()); - if (!bc || !tc) { + if (!bc || make.isEmpty()) { emitFaultyConfigurationMessage(); return false; } @@ -90,7 +90,7 @@ bool QmakeMakeStep::init(QList &earlierSteps) workingDirectory = bc->buildDirectory().toString(); pp->setWorkingDirectory(workingDirectory); - pp->setCommand(effectiveMakeCommand()); + pp->setCommand(make); // If we are cleaning, then make can fail with a error code, but that doesn't mean // we should stop the clean queue @@ -154,6 +154,8 @@ bool QmakeMakeStep::init(QList &earlierSteps) Utils::Environment env = bc->environment(); Utils::Environment::setupEnglishOutput(&env); // We also prepend "L" to the MAKEFLAGS, so that nmake / jom are less verbose + ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit(), + ProjectExplorer::Constants::CXX_LANGUAGE_ID); if (tc && makeCommand().isEmpty()) { if (tc->targetAbi().os() == Abi::WindowsOS && tc->targetAbi().osFlavor() != Abi::WindowsMSysFlavor) {