forked from qt-creator/qt-creator
Utils: Make QtcProcess::{setW,w}orkingDirectory use FilePath
But keep the old setter for a while to ease transition. Change-Id: If02b79b1fcd31fbf8b06ef26876c41af891127f9 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -285,7 +285,8 @@ static bool runBuildProcess(QtcProcess &proc,
|
|||||||
*errorMessage =
|
*errorMessage =
|
||||||
QCoreApplication::translate("ProjectExplorer::BuildableHelperLibrary",
|
QCoreApplication::translate("ProjectExplorer::BuildableHelperLibrary",
|
||||||
"Error running \"%1\" in %2: %3").
|
"Error running \"%1\" in %2: %3").
|
||||||
arg(cmd, proc.workingDirectory(), *errorMessage);
|
arg(cmd, proc.workingDirectory().toUserOutput(),
|
||||||
|
*errorMessage);
|
||||||
qWarning("%s", qPrintable(*errorMessage));
|
qWarning("%s", qPrintable(*errorMessage));
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
|
@@ -170,6 +170,7 @@ public:
|
|||||||
QtcProcess *q;
|
QtcProcess *q;
|
||||||
ProcessHelper *m_process;
|
ProcessHelper *m_process;
|
||||||
CommandLine m_commandLine;
|
CommandLine m_commandLine;
|
||||||
|
FilePath m_workingDirectory;
|
||||||
Environment m_environment;
|
Environment m_environment;
|
||||||
QByteArray m_writeData;
|
QByteArray m_writeData;
|
||||||
bool m_haveEnv = false;
|
bool m_haveEnv = false;
|
||||||
@@ -263,6 +264,9 @@ const Environment &QtcProcess::environment() const
|
|||||||
|
|
||||||
void QtcProcess::setCommand(const CommandLine &cmdLine)
|
void QtcProcess::setCommand(const CommandLine &cmdLine)
|
||||||
{
|
{
|
||||||
|
if (d->m_workingDirectory.needsDevice() && cmdLine.executable().needsDevice()) {
|
||||||
|
QTC_CHECK(d->m_workingDirectory.host() == cmdLine.executable().host());
|
||||||
|
}
|
||||||
d->m_commandLine = cmdLine;
|
d->m_commandLine = cmdLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,14 +275,22 @@ const CommandLine &QtcProcess::commandLine() const
|
|||||||
return d->m_commandLine;
|
return d->m_commandLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QtcProcess::workingDirectory() const
|
FilePath QtcProcess::workingDirectory() const
|
||||||
{
|
{
|
||||||
return d->m_process->workingDirectory();
|
return d->m_workingDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtcProcess::setWorkingDirectory(const FilePath &dir)
|
||||||
|
{
|
||||||
|
if (dir.needsDevice() && d->m_commandLine.executable().needsDevice()) {
|
||||||
|
QTC_CHECK(dir.host() == d->m_commandLine.executable().host());
|
||||||
|
}
|
||||||
|
d->m_workingDirectory = dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtcProcess::setWorkingDirectory(const QString &dir)
|
void QtcProcess::setWorkingDirectory(const QString &dir)
|
||||||
{
|
{
|
||||||
d->m_process->setWorkingDirectory(dir);
|
setWorkingDirectory(FilePath::fromString(dir));
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtcProcess::setUseCtrlCStub(bool enabled)
|
void QtcProcess::setUseCtrlCStub(bool enabled)
|
||||||
@@ -322,7 +334,8 @@ void QtcProcess::start()
|
|||||||
env = Environment::systemEnvironment();
|
env = Environment::systemEnvironment();
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &workDir = workingDirectory();
|
const QString workDir = d->m_workingDirectory.path();
|
||||||
|
|
||||||
QString command;
|
QString command;
|
||||||
ProcessArgs arguments;
|
ProcessArgs arguments;
|
||||||
bool success = ProcessArgs::prepareCommand(d->m_commandLine.executable().toString(),
|
bool success = ProcessArgs::prepareCommand(d->m_commandLine.executable().toString(),
|
||||||
|
@@ -83,8 +83,9 @@ public:
|
|||||||
void setCommand(const CommandLine &cmdLine);
|
void setCommand(const CommandLine &cmdLine);
|
||||||
const CommandLine &commandLine() const;
|
const CommandLine &commandLine() const;
|
||||||
|
|
||||||
QString workingDirectory() const;
|
FilePath workingDirectory() const;
|
||||||
void setWorkingDirectory(const QString &dir);
|
void setWorkingDirectory(const FilePath &dir);
|
||||||
|
void setWorkingDirectory(const QString &dir); // FIXME: Kept to ease downstream transition
|
||||||
|
|
||||||
void setUseCtrlCStub(bool enabled);
|
void setUseCtrlCStub(bool enabled);
|
||||||
void setLowPriority();
|
void setLowPriority();
|
||||||
|
@@ -289,7 +289,7 @@ AndroidDeployQtStep::DeployErrorCode AndroidDeployQtStep::runDeploy()
|
|||||||
|
|
||||||
m_process = new Utils::QtcProcess;
|
m_process = new Utils::QtcProcess;
|
||||||
m_process->setCommand(cmd);
|
m_process->setCommand(cmd);
|
||||||
m_process->setWorkingDirectory(m_workingDirectory.toString());
|
m_process->setWorkingDirectory(m_workingDirectory);
|
||||||
m_process->setEnvironment(m_environment);
|
m_process->setEnvironment(m_environment);
|
||||||
|
|
||||||
if (Utils::HostOsInfo::isWindowsHost())
|
if (Utils::HostOsInfo::isWindowsHost())
|
||||||
|
@@ -103,7 +103,7 @@ void CMakeProcess::run(const BuildDirParameters ¶meters, const QStringList &
|
|||||||
|
|
||||||
m_cancelTimer.start();
|
m_cancelTimer.start();
|
||||||
|
|
||||||
process->setWorkingDirectory(workDirectory.toString());
|
process->setWorkingDirectory(workDirectory);
|
||||||
process->setEnvironment(parameters.environment);
|
process->setEnvironment(parameters.environment);
|
||||||
|
|
||||||
connect(process.get(), &QtcProcess::readyReadStandardOutput,
|
connect(process.get(), &QtcProcess::readyReadStandardOutput,
|
||||||
|
@@ -3856,9 +3856,10 @@ void GdbEngine::setupEngine()
|
|||||||
if (!m_gdbProc.waitForStarted()) {
|
if (!m_gdbProc.waitForStarted()) {
|
||||||
handleGdbStartFailed();
|
handleGdbStartFailed();
|
||||||
QString msg;
|
QString msg;
|
||||||
QString wd = m_gdbProc.workingDirectory();
|
FilePath wd = m_gdbProc.workingDirectory();
|
||||||
if (!QFileInfo(wd).isDir())
|
if (!wd.isReadableDir())
|
||||||
msg = failedToStartMessage() + ' ' + tr("The working directory \"%1\" is not usable.").arg(wd);
|
msg = failedToStartMessage() + ' ' + tr("The working directory \"%1\" is not usable.")
|
||||||
|
.arg(wd.toUserOutput());
|
||||||
else
|
else
|
||||||
msg = RunWorker::userMessageForProcessError(QProcess::FailedToStart, rp.debugger.executable);
|
msg = RunWorker::userMessageForProcessError(QProcess::FailedToStart, rp.debugger.executable);
|
||||||
handleAdapterStartFailed(msg);
|
handleAdapterStartFailed(msg);
|
||||||
|
@@ -718,16 +718,16 @@ QByteArray DockerDevice::fileContents(const FilePath &filePath, int limit) const
|
|||||||
|
|
||||||
void DockerDevice::runProcess(QtcProcess &process) const
|
void DockerDevice::runProcess(QtcProcess &process) const
|
||||||
{
|
{
|
||||||
const QString origWd = process.workingDirectory();
|
const FilePath workingDir = process.workingDirectory();
|
||||||
const CommandLine origCmd = process.commandLine();
|
const CommandLine origCmd = process.commandLine();
|
||||||
|
|
||||||
CommandLine cmd{"docker", {"exec"}};
|
CommandLine cmd{"docker", {"exec"}};
|
||||||
cmd.addArgs({"-w", process.workingDirectory()});
|
cmd.addArgs({"-w", workingDir.path()});
|
||||||
cmd.addArg(d->m_container);
|
cmd.addArg(d->m_container);
|
||||||
cmd.addArg(origCmd.executable().path()); // Cut off the docker://.../ bits.
|
cmd.addArg(origCmd.executable().path()); // Cut off the docker://.../ bits.
|
||||||
cmd.addArgs(origCmd.splitArguments(osType()));
|
cmd.addArgs(origCmd.splitArguments(osType()));
|
||||||
|
|
||||||
LOG("Run" << cmd.toUserOutput());
|
LOG("Run" << cmd.toUserOutput() << " in " << workingDir.toUserOutput());
|
||||||
|
|
||||||
process.setCommand(cmd);
|
process.setCommand(cmd);
|
||||||
process.start();
|
process.start();
|
||||||
|
@@ -321,7 +321,7 @@ void QueryContext::start()
|
|||||||
fp->setKeepOnFinish(Core::FutureProgress::HideOnFinish);
|
fp->setKeepOnFinish(Core::FutureProgress::HideOnFinish);
|
||||||
m_progress.reportStarted();
|
m_progress.reportStarted();
|
||||||
// Order: synchronous call to error handling if something goes wrong.
|
// Order: synchronous call to error handling if something goes wrong.
|
||||||
VcsOutputWindow::appendCommand(m_process.workingDirectory(), {m_binary, m_arguments});
|
VcsOutputWindow::appendCommand(m_process.workingDirectory().toString(), {m_binary, m_arguments});
|
||||||
m_timer.start();
|
m_timer.start();
|
||||||
m_process.setCommand({m_binary, m_arguments});
|
m_process.setCommand({m_binary, m_arguments});
|
||||||
m_process.start();
|
m_process.start();
|
||||||
|
@@ -180,7 +180,7 @@ void MesonProcess::setupProcess(const Command &command,
|
|||||||
&MesonProcess::processStandardError);
|
&MesonProcess::processStandardError);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_process->setWorkingDirectory(command.workDir().toString());
|
m_process->setWorkingDirectory(command.workDir());
|
||||||
m_process->setEnvironment(env);
|
m_process->setEnvironment(env);
|
||||||
Core::MessageManager::writeFlashing(
|
Core::MessageManager::writeFlashing(
|
||||||
tr("Running %1 in %2.").arg(command.toUserOutput()).arg(command.workDir().toUserOutput()));
|
tr("Running %1 in %2.").arg(command.toUserOutput()).arg(command.workDir().toUserOutput()));
|
||||||
|
@@ -220,13 +220,12 @@ void AbstractProcessStep::doRun()
|
|||||||
|
|
||||||
d->m_process.reset(new QtcProcess());
|
d->m_process.reset(new QtcProcess());
|
||||||
d->m_process->setUseCtrlCStub(HostOsInfo::isWindowsHost());
|
d->m_process->setUseCtrlCStub(HostOsInfo::isWindowsHost());
|
||||||
if (!wd.needsDevice()) // FIXME: Make QtcProcess take FilePath as working directory.
|
d->m_process->setWorkingDirectory(wd);
|
||||||
d->m_process->setWorkingDirectory(wd.toString());
|
|
||||||
// Enforce PWD in the environment because some build tools use that.
|
// Enforce PWD in the environment because some build tools use that.
|
||||||
// PWD can be different from getcwd in case of symbolic links (getcwd resolves symlinks).
|
// PWD can be different from getcwd in case of symbolic links (getcwd resolves symlinks).
|
||||||
// For example Clang uses PWD for paths in debug info, see QTCREATORBUG-23788
|
// For example Clang uses PWD for paths in debug info, see QTCREATORBUG-23788
|
||||||
Environment envWithPwd = d->m_param.environment();
|
Environment envWithPwd = d->m_param.environment();
|
||||||
envWithPwd.set("PWD", d->m_process->workingDirectory());
|
envWithPwd.set("PWD", d->m_process->workingDirectory().path());
|
||||||
d->m_process->setEnvironment(envWithPwd);
|
d->m_process->setEnvironment(envWithPwd);
|
||||||
d->m_process->setCommand(effectiveCommand);
|
d->m_process->setCommand(effectiveCommand);
|
||||||
if (d->m_lowPriority && ProjectExplorerPlugin::projectExplorerSettings().lowBuildPriority)
|
if (d->m_lowPriority && ProjectExplorerPlugin::projectExplorerSettings().lowBuildPriority)
|
||||||
|
Reference in New Issue
Block a user