forked from qt-creator/qt-creator
Meson: Simplify Command structure
Also, change from .toString() to .path() which is the right thing to uses in this context. Change-Id: Ic1fe001267a729e9f68a313bea476eb17b718ba3 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -327,7 +327,7 @@ bool MesonProjectParser::run(const Command &command,
|
||||
setupProcess(command, env, projectName, captureStdo);
|
||||
m_elapsed.start();
|
||||
m_process->start();
|
||||
qCDebug(mesonProcessLog()) << "Starting:" << command.toUserOutput();
|
||||
qCDebug(mesonProcessLog()) << "Starting:" << command.cmdLine.toUserOutput();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -372,18 +372,18 @@ void MesonProjectParser::setupProcess(const Command &command, const Environment
|
||||
this, &MesonProjectParser::processStandardError);
|
||||
}
|
||||
|
||||
m_process->setWorkingDirectory(command.workDir());
|
||||
m_process->setWorkingDirectory(command.workDir);
|
||||
m_process->setEnvironment(env);
|
||||
MessageManager::writeFlashing(Tr::tr("Running %1 in %2.")
|
||||
.arg(command.toUserOutput(), command.workDir().toUserOutput()));
|
||||
m_process->setCommand(command.cmdLine());
|
||||
.arg(command.cmdLine.toUserOutput(), command.workDir.toUserOutput()));
|
||||
m_process->setCommand(command.cmdLine);
|
||||
ProcessProgress *progress = new ProcessProgress(m_process.get());
|
||||
progress->setDisplayName(Tr::tr("Configuring \"%1\".").arg(projectName));
|
||||
}
|
||||
|
||||
bool MesonProjectParser::sanityCheck(const Command &command) const
|
||||
{
|
||||
const auto &exe = command.cmdLine().executable();
|
||||
const auto &exe = command.cmdLine.executable();
|
||||
if (!exe.exists()) {
|
||||
//Should only reach this point if Meson exe is removed while a Meson project is opened
|
||||
TaskHub::addTask(
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
#include <QFuture>
|
||||
#include <QQueue>
|
||||
|
||||
#include <utils/qtcprocess.h>
|
||||
|
||||
namespace MesonProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "toolwrapper.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/environment.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
@@ -94,42 +95,42 @@ QStringList options_cat(const T &...args)
|
||||
return result;
|
||||
}
|
||||
|
||||
Command MesonWrapper::setup(const Utils::FilePath &sourceDirectory,
|
||||
const Utils::FilePath &buildDirectory,
|
||||
Command MesonWrapper::setup(const FilePath &sourceDirectory,
|
||||
const FilePath &buildDirectory,
|
||||
const QStringList &options) const
|
||||
{
|
||||
return {m_exe,
|
||||
sourceDirectory,
|
||||
options_cat("setup", options, sourceDirectory.toString(), buildDirectory.toString())};
|
||||
return {{m_exe, options_cat("setup", options, sourceDirectory.path(), buildDirectory.path())},
|
||||
sourceDirectory};
|
||||
}
|
||||
|
||||
Command MesonWrapper::configure(const Utils::FilePath &sourceDirectory,
|
||||
const Utils::FilePath &buildDirectory,
|
||||
Command MesonWrapper::configure(const FilePath &sourceDirectory,
|
||||
const FilePath &buildDirectory,
|
||||
const QStringList &options) const
|
||||
{
|
||||
if (!isSetup(buildDirectory))
|
||||
return setup(sourceDirectory, buildDirectory, options);
|
||||
return {m_exe, buildDirectory, options_cat("configure", options, buildDirectory.toString())};
|
||||
return {{m_exe, options_cat("configure", options, buildDirectory.path())},
|
||||
buildDirectory};
|
||||
}
|
||||
|
||||
Command MesonWrapper::regenerate(const Utils::FilePath &sourceDirectory,
|
||||
const Utils::FilePath &buildDirectory) const
|
||||
Command MesonWrapper::regenerate(const FilePath &sourceDirectory,
|
||||
const FilePath &buildDirectory) const
|
||||
{
|
||||
return {m_exe,
|
||||
buildDirectory,
|
||||
return {{m_exe,
|
||||
options_cat("--internal",
|
||||
"regenerate",
|
||||
sourceDirectory.toString(),
|
||||
buildDirectory.toString(),
|
||||
sourceDirectory.path(),
|
||||
buildDirectory.path(),
|
||||
"--backend",
|
||||
"ninja")};
|
||||
"ninja")},
|
||||
buildDirectory};
|
||||
}
|
||||
|
||||
Command MesonWrapper::introspect(const Utils::FilePath &sourceDirectory) const
|
||||
{
|
||||
return {m_exe,
|
||||
sourceDirectory,
|
||||
{"introspect", "--all", QString("%1/meson.build").arg(sourceDirectory.toString())}};
|
||||
return {{m_exe,
|
||||
{"introspect", "--all", QString("%1/meson.build").arg(sourceDirectory.path())}},
|
||||
sourceDirectory};
|
||||
}
|
||||
|
||||
std::optional<FilePath> MesonWrapper::find()
|
||||
@@ -152,8 +153,8 @@ bool containsFiles(const QString &path, const File_t &file, const T &...files)
|
||||
bool run_meson(const Command &command, QIODevice *output)
|
||||
{
|
||||
Utils::Process process;
|
||||
process.setWorkingDirectory(command.workDir());
|
||||
process.setCommand(command.cmdLine());
|
||||
process.setWorkingDirectory(command.workDir);
|
||||
process.setCommand(command.cmdLine);
|
||||
process.start();
|
||||
if (!process.waitForFinished())
|
||||
return false;
|
||||
|
||||
@@ -7,10 +7,7 @@
|
||||
#include "versionhelper.h"
|
||||
|
||||
#include <utils/commandline.h>
|
||||
#include <utils/environment.h>
|
||||
#include <utils/id.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
#include <utils/store.h>
|
||||
|
||||
#include <optional>
|
||||
@@ -20,20 +17,9 @@ namespace Internal {
|
||||
|
||||
class Command
|
||||
{
|
||||
Utils::CommandLine m_cmd;
|
||||
Utils::FilePath m_workDir;
|
||||
|
||||
public:
|
||||
Command() = default;
|
||||
Command(const Utils::FilePath &exe, const Utils::FilePath &workDir, const QStringList &args)
|
||||
: m_cmd{exe, args}
|
||||
, m_workDir{workDir}
|
||||
{}
|
||||
const Utils::CommandLine &cmdLine() const { return m_cmd; }
|
||||
const Utils::FilePath &workDir() const { return m_workDir; }
|
||||
Utils::FilePath executable() const { return m_cmd.executable(); }
|
||||
QStringList arguments() const { return m_cmd.splitArguments(); }
|
||||
QString toUserOutput() const { return m_cmd.toUserOutput(); }
|
||||
Utils::CommandLine cmdLine;
|
||||
Utils::FilePath workDir;
|
||||
};
|
||||
|
||||
class ToolWrapper
|
||||
|
||||
Reference in New Issue
Block a user