forked from qt-creator/qt-creator
ProcessParameters: Reuse ProcessRunData
Change-Id: I0fdde4303d23ed1350cc36846319264f952df42b Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -35,7 +35,7 @@ ProcessParameters::ProcessParameters() = default;
|
|||||||
*/
|
*/
|
||||||
void ProcessParameters::setCommandLine(const CommandLine &cmdLine)
|
void ProcessParameters::setCommandLine(const CommandLine &cmdLine)
|
||||||
{
|
{
|
||||||
m_command = cmdLine;
|
m_runData.command = cmdLine;
|
||||||
m_effectiveCommand.clear();
|
m_effectiveCommand.clear();
|
||||||
m_effectiveArguments.clear();
|
m_effectiveArguments.clear();
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ void ProcessParameters::setCommandLine(const CommandLine &cmdLine)
|
|||||||
|
|
||||||
void ProcessParameters::setWorkingDirectory(const FilePath &workingDirectory)
|
void ProcessParameters::setWorkingDirectory(const FilePath &workingDirectory)
|
||||||
{
|
{
|
||||||
m_workingDirectory = workingDirectory;
|
m_runData.workingDirectory = workingDirectory;
|
||||||
m_effectiveWorkingDirectory.clear();
|
m_effectiveWorkingDirectory.clear();
|
||||||
|
|
||||||
effectiveWorkingDirectory();
|
effectiveWorkingDirectory();
|
||||||
@@ -79,12 +79,12 @@ void ProcessParameters::setWorkingDirectory(const FilePath &workingDirectory)
|
|||||||
FilePath ProcessParameters::effectiveWorkingDirectory() const
|
FilePath ProcessParameters::effectiveWorkingDirectory() const
|
||||||
{
|
{
|
||||||
if (m_effectiveWorkingDirectory.isEmpty()) {
|
if (m_effectiveWorkingDirectory.isEmpty()) {
|
||||||
m_effectiveWorkingDirectory = m_workingDirectory;
|
m_effectiveWorkingDirectory = m_runData.workingDirectory;
|
||||||
QString path = m_workingDirectory.path();
|
QString path = m_runData.workingDirectory.path();
|
||||||
if (m_macroExpander)
|
if (m_macroExpander)
|
||||||
path = m_macroExpander->expand(path);
|
path = m_macroExpander->expand(path);
|
||||||
m_effectiveWorkingDirectory =
|
m_effectiveWorkingDirectory = m_effectiveWorkingDirectory.withNewPath(
|
||||||
m_effectiveWorkingDirectory.withNewPath(QDir::cleanPath(m_environment.expandVariables(path)));
|
QDir::cleanPath(m_runData.environment.expandVariables(path)));
|
||||||
}
|
}
|
||||||
return m_effectiveWorkingDirectory;
|
return m_effectiveWorkingDirectory;
|
||||||
}
|
}
|
||||||
@@ -96,15 +96,15 @@ FilePath ProcessParameters::effectiveWorkingDirectory() const
|
|||||||
FilePath ProcessParameters::effectiveCommand() const
|
FilePath ProcessParameters::effectiveCommand() const
|
||||||
{
|
{
|
||||||
if (m_effectiveCommand.isEmpty()) {
|
if (m_effectiveCommand.isEmpty()) {
|
||||||
FilePath cmd = m_command.executable();
|
FilePath cmd = m_runData.command.executable();
|
||||||
if (m_macroExpander)
|
if (m_macroExpander)
|
||||||
cmd = m_macroExpander->expand(cmd);
|
cmd = m_macroExpander->expand(cmd);
|
||||||
if (cmd.needsDevice()) {
|
if (cmd.needsDevice()) {
|
||||||
// Assume this is already good. FIXME: It is possibly not, so better fix searchInPath.
|
// Assume this is already good. FIXME: It is possibly not, so better fix searchInPath.
|
||||||
m_effectiveCommand = cmd;
|
m_effectiveCommand = cmd;
|
||||||
} else {
|
} else {
|
||||||
m_effectiveCommand = m_environment.searchInPath(cmd.toString(),
|
m_effectiveCommand = m_runData.environment.searchInPath(cmd.toString(),
|
||||||
{effectiveWorkingDirectory()});
|
{effectiveWorkingDirectory()});
|
||||||
}
|
}
|
||||||
m_commandMissing = m_effectiveCommand.isEmpty();
|
m_commandMissing = m_effectiveCommand.isEmpty();
|
||||||
if (m_commandMissing)
|
if (m_commandMissing)
|
||||||
@@ -126,7 +126,7 @@ bool ProcessParameters::commandMissing() const
|
|||||||
QString ProcessParameters::effectiveArguments() const
|
QString ProcessParameters::effectiveArguments() const
|
||||||
{
|
{
|
||||||
if (m_effectiveArguments.isEmpty()) {
|
if (m_effectiveArguments.isEmpty()) {
|
||||||
m_effectiveArguments = m_command.arguments();
|
m_effectiveArguments = m_runData.command.arguments();
|
||||||
if (m_macroExpander)
|
if (m_macroExpander)
|
||||||
m_effectiveArguments = m_macroExpander->expand(m_effectiveArguments);
|
m_effectiveArguments = m_macroExpander->expand(m_effectiveArguments);
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ QString ProcessParameters::effectiveArguments() const
|
|||||||
|
|
||||||
QString ProcessParameters::prettyCommand() const
|
QString ProcessParameters::prettyCommand() const
|
||||||
{
|
{
|
||||||
QString cmd = m_command.executable().toString();
|
QString cmd = m_runData.command.executable().toString();
|
||||||
if (m_macroExpander)
|
if (m_macroExpander)
|
||||||
cmd = m_macroExpander->expand(cmd);
|
cmd = m_macroExpander->expand(cmd);
|
||||||
return FilePath::fromString(cmd).fileName();
|
return FilePath::fromString(cmd).fileName();
|
||||||
@@ -143,11 +143,11 @@ QString ProcessParameters::prettyCommand() const
|
|||||||
|
|
||||||
QString ProcessParameters::prettyArguments() const
|
QString ProcessParameters::prettyArguments() const
|
||||||
{
|
{
|
||||||
QString margs = effectiveArguments();
|
const QString margs = effectiveArguments();
|
||||||
FilePath workDir = effectiveWorkingDirectory();
|
const FilePath workDir = effectiveWorkingDirectory();
|
||||||
ProcessArgs::SplitError err;
|
ProcessArgs::SplitError err;
|
||||||
ProcessArgs args =
|
const ProcessArgs args = ProcessArgs::prepareArgs(margs, &err, HostOsInfo::hostOs(),
|
||||||
ProcessArgs::prepareArgs(margs, &err, HostOsInfo::hostOs(), &m_environment, &workDir);
|
&m_runData.environment, &workDir);
|
||||||
if (err != ProcessArgs::SplitOk)
|
if (err != ProcessArgs::SplitOk)
|
||||||
return margs; // Sorry, too complex - just fall back.
|
return margs; // Sorry, too complex - just fall back.
|
||||||
return args.toString();
|
return args.toString();
|
||||||
|
|||||||
@@ -5,9 +5,7 @@
|
|||||||
|
|
||||||
#include "projectexplorer_export.h"
|
#include "projectexplorer_export.h"
|
||||||
|
|
||||||
#include <utils/commandline.h>
|
#include <utils/processinterface.h>
|
||||||
#include <utils/environment.h>
|
|
||||||
#include <utils/fileutils.h>
|
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
class MacroExpander;
|
class MacroExpander;
|
||||||
@@ -22,13 +20,13 @@ public:
|
|||||||
ProcessParameters();
|
ProcessParameters();
|
||||||
|
|
||||||
void setCommandLine(const Utils::CommandLine &cmdLine);
|
void setCommandLine(const Utils::CommandLine &cmdLine);
|
||||||
Utils::CommandLine command() const { return m_command; }
|
Utils::CommandLine command() const { return m_runData.command; }
|
||||||
|
|
||||||
void setWorkingDirectory(const Utils::FilePath &workingDirectory);
|
void setWorkingDirectory(const Utils::FilePath &workingDirectory);
|
||||||
Utils::FilePath workingDirectory() const { return m_workingDirectory; }
|
Utils::FilePath workingDirectory() const { return m_runData.workingDirectory; }
|
||||||
|
|
||||||
void setEnvironment(const Utils::Environment &env) { m_environment = env; }
|
void setEnvironment(const Utils::Environment &env) { m_runData.environment = env; }
|
||||||
Utils::Environment environment() const { return m_environment; }
|
Utils::Environment environment() const { return m_runData.environment; }
|
||||||
|
|
||||||
void setMacroExpander(Utils::MacroExpander *mx) { m_macroExpander = mx; }
|
void setMacroExpander(Utils::MacroExpander *mx) { m_macroExpander = mx; }
|
||||||
Utils::MacroExpander *macroExpander() const { return m_macroExpander; }
|
Utils::MacroExpander *macroExpander() const { return m_macroExpander; }
|
||||||
@@ -49,9 +47,7 @@ public:
|
|||||||
QString summaryInWorkdir(const QString &displayName) const;
|
QString summaryInWorkdir(const QString &displayName) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Utils::FilePath m_workingDirectory;
|
Utils::ProcessRunData m_runData;
|
||||||
Utils::CommandLine m_command;
|
|
||||||
Utils::Environment m_environment;
|
|
||||||
Utils::MacroExpander *m_macroExpander = nullptr;
|
Utils::MacroExpander *m_macroExpander = nullptr;
|
||||||
|
|
||||||
mutable Utils::FilePath m_effectiveWorkingDirectory;
|
mutable Utils::FilePath m_effectiveWorkingDirectory;
|
||||||
|
|||||||
Reference in New Issue
Block a user