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