Utils: Add CommandLine::toLocal()

And get rid of ProcessRunner::forceRunOnHost().

Change-Id: Ia2d0e526c59a474db0fb79d675b7acd0bf45f2ca
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2025-01-02 17:29:02 +01:00
parent 00cef252c5
commit e37b7efdee
7 changed files with 15 additions and 16 deletions

View File

@@ -1598,6 +1598,17 @@ QStringList CommandLine::splitArguments() const
return ProcessArgs::splitArgs(m_arguments, m_executable.osType());
}
CommandLine CommandLine::toLocal() const
{
if (m_executable.isLocal())
return *this;
QTC_CHECK(false); // TODO: Does it make sense?
CommandLine cmd = *this;
cmd.setExecutable(FilePath::fromString(m_executable.path()));
return cmd;
}
QTCREATOR_UTILS_EXPORT bool operator==(const CommandLine &first, const CommandLine &second)
{
return first.m_executable == second.m_executable && first.m_arguments == second.m_arguments;

View File

@@ -184,6 +184,7 @@ public:
QStringList splitArguments() const;
bool isEmpty() const { return m_executable.isEmpty(); }
CommandLine toLocal() const;
private:
friend QTCREATOR_UTILS_EXPORT bool operator==(const CommandLine &first, const CommandLine &second);

View File

@@ -176,8 +176,7 @@ RunWorker *GdbServerProvider::targetRunner(RunControl *runControl) const
worker->setId("BareMetalGdbServer");
// Baremetal's GDB servers are launched on the host, not on the target.
worker->setStartModifier([worker, cmd = command()] {
worker->setCommandLine(cmd);
worker->forceRunOnHost();
worker->setCommandLine(cmd.toLocal());
});
return worker;
}

View File

@@ -1710,15 +1710,6 @@ void ProcessRunner::suppressDefaultStdOutHandling()
d->m_suppressDefaultStdOutHandling = true;
}
void ProcessRunner::forceRunOnHost()
{
const FilePath executable = d->m_command.executable();
if (!executable.isLocal()) {
QTC_CHECK(false);
d->m_command.setExecutable(FilePath::fromString(executable.path()));
}
}
// RunWorkerPrivate
RunWorkerPrivate::RunWorkerPrivate(RunWorker *runWorker, RunControl *runControl)

View File

@@ -295,7 +295,6 @@ public:
void setProcessMode(Utils::ProcessMode processMode);
void suppressDefaultStdOutHandling();
void forceRunOnHost();
signals:
void stdOutData(const QByteArray &data);

View File

@@ -213,8 +213,7 @@ LocalQmlPreviewSupportFactory::LocalQmlPreviewSupportFactory()
}
cmd.addArg(qmlDebugLocalArguments(QmlPreviewServices, runControl->qmlChannel().path()));
worker->setCommandLine(cmd);
worker->forceRunOnHost();
worker->setCommandLine(cmd.toLocal());
});
return worker;
});

View File

@@ -154,8 +154,7 @@ RunWorker *createLocalQmlProfilerWorker(RunControl *runControl)
const QString oldArgs = cmd.arguments();
cmd.setArguments(arguments);
cmd.addArgs(oldArgs, Utils::CommandLine::Raw);
worker->setCommandLine(cmd);
worker->forceRunOnHost();
worker->setCommandLine(cmd.toLocal());
});
return worker;