ProjectExplorer: Ensure working dir is reachable

Previously the working directory might not be reachable by
the executable.

This change fixes that by calling "ensureReachable", and
changing the path to an on-device path of the exectuable.

This also fixes the path when the Host is Windows, and
the build device is a unix type system by changing the paths
from e.g. "c:/..." to "/c/..."

Change-Id: I6c86e16c867bb654b6c2a4951d9f62fdb879298e
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Marcus Tillmanns
2022-10-18 14:17:35 +02:00
parent 389d2acd87
commit 6dd15ef3f3
2 changed files with 17 additions and 8 deletions

View File

@@ -152,7 +152,8 @@ bool AbstractProcessStep::init()
if (d->m_process) if (d->m_process)
return false; return false;
setupProcessParameters(processParameters()); if (!setupProcessParameters(processParameters()))
return false;
return true; return true;
} }
@@ -233,7 +234,7 @@ ProcessParameters *AbstractProcessStep::processParameters()
return &d->m_param; return &d->m_param;
} }
void AbstractProcessStep::setupProcessParameters(ProcessParameters *params) const bool AbstractProcessStep::setupProcessParameters(ProcessParameters *params) const
{ {
params->setMacroExpander(macroExpander()); params->setMacroExpander(macroExpander());
@@ -242,13 +243,21 @@ void AbstractProcessStep::setupProcessParameters(ProcessParameters *params) cons
d->m_environmentModifier(env); d->m_environmentModifier(env);
params->setEnvironment(env); params->setEnvironment(env);
if (d->m_workingDirectoryProvider)
params->setWorkingDirectory(d->m_workingDirectoryProvider());
else
params->setWorkingDirectory(buildDirectory());
if (d->m_commandLineProvider) if (d->m_commandLineProvider)
params->setCommandLine(d->m_commandLineProvider()); params->setCommandLine(d->m_commandLineProvider());
FilePath workingDirectory;
if (d->m_workingDirectoryProvider)
workingDirectory = d->m_workingDirectoryProvider();
else
workingDirectory = buildDirectory();
const FilePath executable = params->effectiveCommand();
QTC_ASSERT(executable.ensureReachable(workingDirectory), return false);
params->setWorkingDirectory(workingDirectory.onDevice(executable));
return true;
} }
void AbstractProcessStep::Private::cleanUp(int exitCode, QProcess::ExitStatus status) void AbstractProcessStep::Private::cleanUp(int exitCode, QProcess::ExitStatus status)

View File

@@ -21,7 +21,7 @@ class PROJECTEXPLORER_EXPORT AbstractProcessStep : public BuildStep
public: public:
ProcessParameters *processParameters(); ProcessParameters *processParameters();
void setupProcessParameters(ProcessParameters *params) const; bool setupProcessParameters(ProcessParameters *params) const;
bool ignoreReturnValue() const; bool ignoreReturnValue() const;
void setIgnoreReturnValue(bool b); void setIgnoreReturnValue(bool b);