forked from qt-creator/qt-creator
Utils: Add overloads for CommandLine with osType
In the next commit we want to test these functions, so we need to make sure that we can specify their osType. We will also need these functions when we are combining command lines from different platforms e.g. on docker where the host might be windows, but the docker image is Linux (or vice versa). Task-number: QTCREATORBUG-32325 Change-Id: I7d01bdc5f292b6bf6b76d03856f6d4e588e371ab Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -628,6 +628,12 @@ void ProcessArgs::addArgs(QString *args, const QStringList &inArgs)
|
||||
addArg(args, arg);
|
||||
}
|
||||
|
||||
void ProcessArgs::addArgs(QString *args, const QStringList &inArgs, OsType osType)
|
||||
{
|
||||
for (const QString &arg : inArgs)
|
||||
addArg(args, arg, osType);
|
||||
}
|
||||
|
||||
CommandLine &CommandLine::operator<<(const QString &arg)
|
||||
{
|
||||
addArg(arg);
|
||||
@@ -1543,6 +1549,15 @@ void CommandLine::addCommandLineAsSingleArg(const CommandLine &cmd)
|
||||
addArg(combined);
|
||||
}
|
||||
|
||||
void CommandLine::addCommandLineAsSingleArg(const CommandLine &cmd, OsType osType)
|
||||
{
|
||||
QString combined;
|
||||
ProcessArgs::addArg(&combined, cmd.executable().path(), osType);
|
||||
ProcessArgs::addArgs(&combined, cmd.arguments());
|
||||
|
||||
addArg(combined, osType);
|
||||
}
|
||||
|
||||
void CommandLine::addCommandLineWithAnd(const CommandLine &cmd)
|
||||
{
|
||||
if (m_executable.isEmpty()) {
|
||||
|
@@ -53,6 +53,8 @@ public:
|
||||
const Environment *env = nullptr, const FilePath *pwd = nullptr);
|
||||
//! Quote and append each argument to a shell command
|
||||
static void addArgs(QString *args, const QStringList &inArgs);
|
||||
//! Quote and append each argument to a shell command
|
||||
static void addArgs(QString *args, const QStringList &inArgs, OsType osType);
|
||||
//! Append already quoted arguments to a shell command
|
||||
static void addArgs(QString *args, const QString &inArgs);
|
||||
//! Split a shell command into separate arguments.
|
||||
@@ -170,6 +172,7 @@ public:
|
||||
void addCommandLineAsArgs(const CommandLine &cmd, RawType);
|
||||
|
||||
void addCommandLineAsSingleArg(const CommandLine &cmd);
|
||||
void addCommandLineAsSingleArg(const CommandLine &cmd, OsType osType);
|
||||
void addCommandLineWithAnd(const CommandLine &cmd);
|
||||
|
||||
QString toUserOutput() const;
|
||||
|
Reference in New Issue
Block a user