QmakePM: Expand qmake arguments for summary, effective call and parser

For example, if you set MAKEFILE=Makefile.%{CurrentBuild:Name}, the
effective qmake call should show Makefile.foo and so should the command-
line summary (with details collapsed).

Change-Id: Ide0c0b0758b92f77f7cc97dd538db818575c91dd
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Orgad Shaneh
2018-05-14 21:59:18 +03:00
committed by Orgad Shaneh
parent 88b223ed40
commit c0b8ac7966
2 changed files with 20 additions and 8 deletions

View File

@@ -97,14 +97,14 @@ QmakeBuildConfiguration *QMakeStep::qmakeBuildConfiguration() const
/// config arguemnts /// config arguemnts
/// moreArguments /// moreArguments
/// user arguments /// user arguments
QString QMakeStep::allArguments(const BaseQtVersion *v, bool shorted) const QString QMakeStep::allArguments(const BaseQtVersion *v, ArgumentFlags flags) const
{ {
QTC_ASSERT(v, return QString()); QTC_ASSERT(v, return QString());
QmakeBuildConfiguration *bc = qmakeBuildConfiguration(); QmakeBuildConfiguration *bc = qmakeBuildConfiguration();
QStringList arguments; QStringList arguments;
if (bc->subNodeBuild()) if (bc->subNodeBuild())
arguments << bc->subNodeBuild()->filePath().toUserOutput(); arguments << bc->subNodeBuild()->filePath().toUserOutput();
else if (shorted) else if (flags & ArgumentFlag::OmitProjectPath)
arguments << project()->projectFilePath().fileName(); arguments << project()->projectFilePath().fileName();
else else
arguments << project()->projectFilePath().toUserOutput(); arguments << project()->projectFilePath().toUserOutput();
@@ -134,7 +134,7 @@ QString QMakeStep::allArguments(const BaseQtVersion *v, bool shorted) const
QtcProcess::addArgs(&args, m_userArgs); QtcProcess::addArgs(&args, m_userArgs);
foreach (QString arg, m_extraArgs) foreach (QString arg, m_extraArgs)
QtcProcess::addArgs(&args, arg); QtcProcess::addArgs(&args, arg);
return args; return (flags & ArgumentFlag::Expand) ? bc->macroExpander()->expand(args) : args;
} }
QMakeStepConfig QMakeStep::deducedArguments() const QMakeStepConfig QMakeStep::deducedArguments() const
@@ -480,7 +480,7 @@ QString QMakeStep::effectiveQMakeCall() const
QString result = qmake; QString result = qmake;
if (qtVersion) { if (qtVersion) {
result += ' ' + buildConfiguration()->macroExpander()->expand(allArguments(qtVersion)); result += ' ' + allArguments(qtVersion, ArgumentFlag::Expand);
if (qtVersion->qtVersion() >= QtVersionNumber(5, 0, 0)) if (qtVersion->qtVersion() >= QtVersionNumber(5, 0, 0))
result.append(QString::fromLatin1(" && %1 %2").arg(make).arg(makeArguments())); result.append(QString::fromLatin1(" && %1 %2").arg(make).arg(makeArguments()));
} }
@@ -492,7 +492,7 @@ QStringList QMakeStep::parserArguments()
QStringList result; QStringList result;
BaseQtVersion *qt = QtKitInformation::qtVersion(target()->kit()); BaseQtVersion *qt = QtKitInformation::qtVersion(target()->kit());
QTC_ASSERT(qt, return QStringList()); QTC_ASSERT(qt, return QStringList());
for (QtcProcess::ConstArgIterator ait(allArguments(qt)); ait.next(); ) { for (QtcProcess::ConstArgIterator ait(allArguments(qt, ArgumentFlag::Expand)); ait.next(); ) {
if (ait.isSimple()) if (ait.isSimple())
result << ait.value(); result << ait.value();
} }
@@ -780,9 +780,12 @@ void QMakeStepConfigWidget::updateSummaryLabel()
return; return;
} }
// We don't want the full path to the .pro file // We don't want the full path to the .pro file
QString args = m_step->allArguments(qtVersion, true); const QString args = m_step->allArguments(
qtVersion,
QMakeStep::ArgumentFlag::OmitProjectPath
| QMakeStep::ArgumentFlag::Expand);
// And we only use the .pro filename not the full path // And we only use the .pro filename not the full path
QString program = qtVersion->qmakeCommand().fileName(); const QString program = qtVersion->qmakeCommand().fileName();
setSummaryText(tr("<b>qmake:</b> %1 %2").arg(program, args)); setSummaryText(tr("<b>qmake:</b> %1 %2").arg(program, args));
} }

View File

@@ -120,8 +120,15 @@ public:
bool immutable() const override; bool immutable() const override;
void setForced(bool b); void setForced(bool b);
enum class ArgumentFlag {
OmitProjectPath = 0x01,
Expand = 0x02
};
Q_DECLARE_FLAGS(ArgumentFlags, ArgumentFlag);
// the complete argument line // the complete argument line
QString allArguments(const QtSupport::BaseQtVersion *v, bool shorted = false) const; QString allArguments(const QtSupport::BaseQtVersion *v,
ArgumentFlags flags = ArgumentFlags()) const;
QMakeStepConfig deducedArguments() const; QMakeStepConfig deducedArguments() const;
// arguments passed to the pro file parser // arguments passed to the pro file parser
QStringList parserArguments(); QStringList parserArguments();
@@ -231,3 +238,5 @@ private:
}; };
} // namespace QmakeProjectManager } // namespace QmakeProjectManager
Q_DECLARE_OPERATORS_FOR_FLAGS(QmakeProjectManager::QMakeStep::ArgumentFlags);