forked from qt-creator/qt-creator
Generic/Base make step: Improve details text
The new summary is similar to the one in the qmake make step, adding the working directory to the summary text, and adding checks for tool chain and build configuration etc. Different to the qmake variant is that it doesn't restrict to any particular build configuration type, and that it needs to show allArguments() instead of just userArguments(). Change-Id: Ie79264267a2ce834a3d3ffe2e4c066786642adc1 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -182,7 +182,6 @@ MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep) :
|
||||
m_ui->makeLineEdit->setHistoryCompleter("PE.MakeCommand.History");
|
||||
m_ui->makeLineEdit->setPath(m_makeStep->makeCommand());
|
||||
m_ui->makeArgumentsLineEdit->setText(m_makeStep->userArguments());
|
||||
updateMakeOverrideLabel();
|
||||
updateDetails();
|
||||
|
||||
connect(m_ui->targetsList, &QListWidget::itemChanged,
|
||||
@@ -192,25 +191,26 @@ MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep) :
|
||||
connect(m_ui->makeArgumentsLineEdit, &QLineEdit::textEdited,
|
||||
this, &MakeStepConfigWidget::makeArgumentsLineEditTextEdited);
|
||||
|
||||
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged,
|
||||
this, &MakeStepConfigWidget::updateMakeOverrideLabel);
|
||||
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged,
|
||||
this, &MakeStepConfigWidget::updateDetails);
|
||||
|
||||
connect(m_makeStep->target(), &Target::kitChanged,
|
||||
this, &MakeStepConfigWidget::updateMakeOverrideLabel);
|
||||
this, &MakeStepConfigWidget::updateDetails);
|
||||
|
||||
const auto pro = m_makeStep->target()->project();
|
||||
pro->subscribeSignal(&BuildConfiguration::environmentChanged, this, [this]() {
|
||||
if (static_cast<BuildConfiguration *>(sender())->isActive()) {
|
||||
updateMakeOverrideLabel();
|
||||
updateDetails();
|
||||
}
|
||||
});
|
||||
pro->subscribeSignal(&BuildConfiguration::buildDirectoryChanged, this, [this]() {
|
||||
if (static_cast<BuildConfiguration *>(sender())->isActive()) {
|
||||
updateDetails();
|
||||
}
|
||||
});
|
||||
connect(pro, &Project::activeProjectConfigurationChanged,
|
||||
this, [this](ProjectConfiguration *pc) {
|
||||
if (pc && pc->isActive()) {
|
||||
updateMakeOverrideLabel();
|
||||
updateDetails();
|
||||
}
|
||||
});
|
||||
@@ -228,35 +228,60 @@ QString MakeStepConfigWidget::displayName() const
|
||||
return m_makeStep->displayName();
|
||||
}
|
||||
|
||||
void MakeStepConfigWidget::updateMakeOverrideLabel()
|
||||
void MakeStepConfigWidget::setSummaryText(const QString &text)
|
||||
{
|
||||
BuildConfiguration *bc = m_makeStep->buildConfiguration();
|
||||
if (!bc)
|
||||
bc = m_makeStep->target()->activeBuildConfiguration();
|
||||
ToolChain *tc = ToolChainKitInformation::toolChain(m_makeStep->target()->kit(),
|
||||
ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
||||
if (bc && tc) {
|
||||
m_ui->makeLabel->setText(
|
||||
tr("Override %1:").arg(QDir::toNativeSeparators(tc->makeCommand(bc->environment()))));
|
||||
} else {
|
||||
m_ui->makeLabel->setText(tr("Make:"));
|
||||
}
|
||||
if (text == m_summaryText)
|
||||
return;
|
||||
m_summaryText = text;
|
||||
emit updateSummary();
|
||||
}
|
||||
|
||||
void MakeStepConfigWidget::updateDetails()
|
||||
{
|
||||
ToolChain *tc
|
||||
= ToolChainKitInformation::toolChain(m_makeStep->target()->kit(), ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
||||
BuildConfiguration *bc = m_makeStep->buildConfiguration();
|
||||
if (!bc)
|
||||
bc = m_makeStep->target()->activeBuildConfiguration();
|
||||
|
||||
const QString make = tc && bc ? tc->makeCommand(bc->environment()) : QString();
|
||||
if (make.isEmpty())
|
||||
m_ui->makeLabel->setText(tr("Make:"));
|
||||
else
|
||||
m_ui->makeLabel->setText(tr("Override %1:").arg(QDir::toNativeSeparators(make)));
|
||||
|
||||
if (!tc) {
|
||||
setSummaryText(tr("<b>Make:</b> %1").arg(ProjectExplorer::ToolChainKitInformation::msgNoToolChainInTarget()));
|
||||
return;
|
||||
}
|
||||
if (!bc) {
|
||||
setSummaryText(tr("<b>Make:</b> No build configuration."));
|
||||
return;
|
||||
}
|
||||
|
||||
ProcessParameters param;
|
||||
param.setMacroExpander(bc->macroExpander());
|
||||
param.setWorkingDirectory(bc->buildDirectory().toString());
|
||||
param.setEnvironment(bc->environment());
|
||||
param.setCommand(m_makeStep->effectiveMakeCommand());
|
||||
|
||||
Utils::Environment env = bc->environment();
|
||||
Utils::Environment::setupEnglishOutput(&env);
|
||||
// We prepend "L" to the MAKEFLAGS, so that nmake / jom are less verbose
|
||||
// FIXME doing this without the user having a way to override this is rather bad
|
||||
if (tc && m_makeStep->makeCommand().isEmpty()) {
|
||||
if (tc->targetAbi().os() == Abi::WindowsOS
|
||||
&& tc->targetAbi().osFlavor() != Abi::WindowsMSysFlavor) {
|
||||
const QString makeFlags = "MAKEFLAGS";
|
||||
env.set(makeFlags, 'L' + env.value(makeFlags));
|
||||
}
|
||||
}
|
||||
param.setArguments(m_makeStep->allArguments());
|
||||
m_summaryText = param.summary(displayName());
|
||||
emit updateSummary();
|
||||
param.setEnvironment(env);
|
||||
|
||||
if (param.commandMissing())
|
||||
setSummaryText(tr("<b>Make:</b> %1 not found in the environment.").arg(param.command())); // Override display text
|
||||
else
|
||||
setSummaryText(param.summaryInWorkdir(displayName()));
|
||||
}
|
||||
|
||||
QString MakeStepConfigWidget::summaryText() const
|
||||
|
||||
@@ -87,8 +87,8 @@ private:
|
||||
void itemChanged(QListWidgetItem *item);
|
||||
void makeLineEditTextEdited();
|
||||
void makeArgumentsLineEditTextEdited();
|
||||
void updateMakeOverrideLabel();
|
||||
void updateDetails();
|
||||
void setSummaryText(const QString &text);
|
||||
|
||||
Internal::Ui::MakeStep *m_ui;
|
||||
MakeStep *m_makeStep;
|
||||
|
||||
Reference in New Issue
Block a user