forked from qt-creator/qt-creator
ProjectExplorer: Use Utils::FileName in ProcessParameters
For the command and the working directory. Change-Id: Ia69dc7100aeb57bb6e1b35f4dd4f3cf3763d8cda Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -44,7 +44,9 @@
|
||||
\sa ProjectExplorer::AbstractProcessStep
|
||||
*/
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
ProcessParameters::ProcessParameters() :
|
||||
m_macroExpander(nullptr),
|
||||
@@ -56,7 +58,7 @@ ProcessParameters::ProcessParameters() :
|
||||
Sets the executable to run.
|
||||
*/
|
||||
|
||||
void ProcessParameters::setCommand(const QString &cmd)
|
||||
void ProcessParameters::setCommand(const Utils::FileName &cmd)
|
||||
{
|
||||
m_command = cmd;
|
||||
m_effectiveCommand.clear();
|
||||
@@ -78,7 +80,7 @@ void ProcessParameters::setArguments(const QString &arguments)
|
||||
Should be called from init().
|
||||
*/
|
||||
|
||||
void ProcessParameters::setWorkingDirectory(const QString &workingDirectory)
|
||||
void ProcessParameters::setWorkingDirectory(const FileName &workingDirectory)
|
||||
{
|
||||
m_workingDirectory = workingDirectory;
|
||||
m_effectiveWorkingDirectory.clear();
|
||||
@@ -103,13 +105,14 @@ void ProcessParameters::setWorkingDirectory(const QString &workingDirectory)
|
||||
Gets the fully expanded working directory.
|
||||
*/
|
||||
|
||||
QString ProcessParameters::effectiveWorkingDirectory() const
|
||||
FileName ProcessParameters::effectiveWorkingDirectory() const
|
||||
{
|
||||
if (m_effectiveWorkingDirectory.isEmpty()) {
|
||||
QString wds = m_workingDirectory;
|
||||
QString wds = m_workingDirectory.toString();
|
||||
if (m_macroExpander)
|
||||
wds = m_macroExpander->expand(wds);
|
||||
m_effectiveWorkingDirectory = QDir::cleanPath(m_environment.expandVariables(wds));
|
||||
m_effectiveWorkingDirectory
|
||||
= FileName::fromString(QDir::cleanPath(m_environment.expandVariables(wds)));
|
||||
}
|
||||
return m_effectiveWorkingDirectory;
|
||||
}
|
||||
@@ -118,14 +121,15 @@ QString ProcessParameters::effectiveWorkingDirectory() const
|
||||
Gets the fully expanded command name to run.
|
||||
*/
|
||||
|
||||
QString ProcessParameters::effectiveCommand() const
|
||||
FileName ProcessParameters::effectiveCommand() const
|
||||
{
|
||||
if (m_effectiveCommand.isEmpty()) {
|
||||
QString cmd = m_command;
|
||||
FileName cmd = m_command;
|
||||
if (m_macroExpander)
|
||||
cmd = m_macroExpander->expand(cmd);
|
||||
m_effectiveCommand =
|
||||
m_environment.searchInPath(cmd, {Utils::FileName::fromString(effectiveWorkingDirectory())}).toString();
|
||||
m_environment.searchInPath(cmd.toString(),
|
||||
{effectiveWorkingDirectory()});
|
||||
m_commandMissing = m_effectiveCommand.isEmpty();
|
||||
if (m_commandMissing)
|
||||
m_effectiveCommand = cmd;
|
||||
@@ -155,7 +159,7 @@ QString ProcessParameters::effectiveArguments() const
|
||||
|
||||
QString ProcessParameters::prettyCommand() const
|
||||
{
|
||||
QString cmd = m_command;
|
||||
QString cmd = m_command.toString();
|
||||
if (m_macroExpander)
|
||||
cmd = m_macroExpander->expand(cmd);
|
||||
return Utils::FileName::fromString(cmd).fileName();
|
||||
@@ -164,7 +168,7 @@ QString ProcessParameters::prettyCommand() const
|
||||
QString ProcessParameters::prettyArguments() const
|
||||
{
|
||||
QString margs = effectiveArguments();
|
||||
QString workDir = effectiveWorkingDirectory();
|
||||
QString workDir = effectiveWorkingDirectory().toString();
|
||||
Utils::QtcProcess::SplitError err;
|
||||
Utils::QtcProcess::Arguments args =
|
||||
Utils::QtcProcess::prepareArgs(margs, &err, Utils::HostOsInfo::hostOs(), &m_environment, &workDir);
|
||||
@@ -187,7 +191,7 @@ QString ProcessParameters::summaryInWorkdir(const QString &displayName) const
|
||||
.arg(displayName,
|
||||
Utils::QtcProcess::quoteArg(prettyCommand()),
|
||||
prettyArguments(),
|
||||
QDir::toNativeSeparators(effectiveWorkingDirectory()));
|
||||
QDir::toNativeSeparators(effectiveWorkingDirectory().toString()));
|
||||
}
|
||||
|
||||
void ProcessParameters::resolveAll()
|
||||
@@ -196,3 +200,5 @@ void ProcessParameters::resolveAll()
|
||||
effectiveArguments();
|
||||
effectiveWorkingDirectory();
|
||||
}
|
||||
|
||||
} // ProcessExplorer
|
||||
|
||||
Reference in New Issue
Block a user