forked from qt-creator/qt-creator
Utils: Dissolve ProcessArgs::ConstIterator
Only used in one place, encapsulate its use into a simpler API. Change-Id: If5542863f77c93979c0a3f7d27fe94d8a07127b6 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -1588,6 +1588,18 @@ CommandLine CommandLine::toLocal() const
|
||||
return cmd;
|
||||
}
|
||||
|
||||
QStringList ProcessArgs::filterSimpleArgs(const QString &args, OsType osType)
|
||||
{
|
||||
QStringList result;
|
||||
QString args_ = args;
|
||||
for (ArgIterator ait(&args_, osType); ait.next(); ) {
|
||||
// This filters out items containing e.g. shell variables like '$FOO'
|
||||
if (ait.isSimple())
|
||||
result << ait.value();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QTCREATOR_UTILS_EXPORT bool operator==(const CommandLine &first, const CommandLine &second)
|
||||
{
|
||||
return first.m_executable == second.m_executable && first.m_arguments == second.m_arguments;
|
||||
|
@@ -53,6 +53,9 @@ public:
|
||||
static QStringList splitArgs(const QString &cmd, OsType osType,
|
||||
bool abortOnMeta = false, SplitError *err = nullptr,
|
||||
const Environment *env = nullptr, const QString &pwd = {});
|
||||
//! Split a shell command into separate arguments and drop complex ones
|
||||
//! as input for the internal .pro parser.
|
||||
static QStringList filterSimpleArgs(const QString &cmd, OsType osType);
|
||||
|
||||
using FindMacro = std::function<int(const QString &str, int *pos, QString *ret)>;
|
||||
|
||||
@@ -89,20 +92,6 @@ public:
|
||||
OsType m_osType;
|
||||
};
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT ConstArgIterator
|
||||
{
|
||||
public:
|
||||
ConstArgIterator(const QString &str, OsType osType = HostOsInfo::hostOs())
|
||||
: m_str(str), m_ait(&m_str, osType)
|
||||
{}
|
||||
bool next() { return m_ait.next(); }
|
||||
bool isSimple() const { return m_ait.isSimple(); }
|
||||
QString value() const { return m_ait.value(); }
|
||||
|
||||
private:
|
||||
QString m_str;
|
||||
ArgIterator m_ait;
|
||||
};
|
||||
};
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT RunResult
|
||||
|
@@ -375,15 +375,11 @@ QString QMakeStep::effectiveQMakeCall() const
|
||||
|
||||
QStringList QMakeStep::parserArguments()
|
||||
{
|
||||
// NOTE: extra parser args placed before the other args intentionally
|
||||
QStringList result = m_extraParserArgs;
|
||||
QtVersion *qt = QtKitAspect::qtVersion(kit());
|
||||
QTC_ASSERT(qt, return {});
|
||||
for (ProcessArgs::ConstArgIterator ait(allArguments(qt, ArgumentFlag::Expand)); ait.next(); ) {
|
||||
if (ait.isSimple())
|
||||
result << ait.value();
|
||||
}
|
||||
return result;
|
||||
const QString allArgs = allArguments(qt, ArgumentFlag::Expand);
|
||||
// NOTE: extra parser args placed before the other args intentionally
|
||||
return m_extraParserArgs + ProcessArgs::filterSimpleArgs(allArgs, qt->qmakeFilePath().osType());
|
||||
}
|
||||
|
||||
QString QMakeStep::mkspec() const
|
||||
|
Reference in New Issue
Block a user