forked from qt-creator/qt-creator
Meson: Start generalizing again
Change-Id: I9fc18edb0e159c448193b4cc7c4bd82b2d5f409a Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -120,10 +120,10 @@ bool MesonProjectParser::configure(const FilePath &sourcePath,
|
|||||||
m_srcDir = sourcePath;
|
m_srcDir = sourcePath;
|
||||||
m_buildDir = buildPath;
|
m_buildDir = buildPath;
|
||||||
m_outputParser.setSourceDirectory(sourcePath);
|
m_outputParser.setSourceDirectory(sourcePath);
|
||||||
auto cmd = MesonTools::mesonWrapper(m_meson)->configure(sourcePath, buildPath, args);
|
auto cmd = MesonTools::toolById(m_meson, ToolType::Meson)->configure(sourcePath, buildPath, args);
|
||||||
// see comment near m_pendingCommands declaration
|
// see comment near m_pendingCommands declaration
|
||||||
m_pendingCommands.enqueue(
|
m_pendingCommands.enqueue(
|
||||||
std::make_tuple(MesonTools::mesonWrapper(m_meson)->regenerate(sourcePath, buildPath),
|
std::make_tuple(MesonTools::toolById(m_meson, ToolType::Meson)->regenerate(sourcePath, buildPath),
|
||||||
false));
|
false));
|
||||||
return run(cmd, m_env, m_projectName);
|
return run(cmd, m_env, m_projectName);
|
||||||
}
|
}
|
||||||
@@ -147,7 +147,7 @@ bool MesonProjectParser::setup(const FilePath &sourcePath,
|
|||||||
auto cmdArgs = args;
|
auto cmdArgs = args;
|
||||||
if (forceWipe || isSetup(buildPath))
|
if (forceWipe || isSetup(buildPath))
|
||||||
cmdArgs << "--wipe";
|
cmdArgs << "--wipe";
|
||||||
auto cmd = MesonTools::mesonWrapper(m_meson)->setup(sourcePath, buildPath, cmdArgs);
|
auto cmd = MesonTools::toolById(m_meson, ToolType::Meson)->setup(sourcePath, buildPath, cmdArgs);
|
||||||
return run(cmd, m_env, m_projectName);
|
return run(cmd, m_env, m_projectName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +169,7 @@ bool MesonProjectParser::parse(const FilePath &sourcePath)
|
|||||||
m_srcDir = sourcePath;
|
m_srcDir = sourcePath;
|
||||||
m_introType = IntroDataType::stdo;
|
m_introType = IntroDataType::stdo;
|
||||||
m_outputParser.setSourceDirectory(sourcePath);
|
m_outputParser.setSourceDirectory(sourcePath);
|
||||||
return run(MesonTools::mesonWrapper(m_meson)->introspect(sourcePath),
|
return run(MesonTools::toolById(m_meson, ToolType::Meson)->introspect(sourcePath),
|
||||||
m_env,
|
m_env,
|
||||||
m_projectName,
|
m_projectName,
|
||||||
true);
|
true);
|
||||||
@@ -310,11 +310,10 @@ bool MesonProjectParser::matchesKit(const KitData &kit)
|
|||||||
bool MesonProjectParser::usesSameMesonVersion(const FilePath &buildPath)
|
bool MesonProjectParser::usesSameMesonVersion(const FilePath &buildPath)
|
||||||
{
|
{
|
||||||
auto info = MesonInfoParser::mesonInfo(buildPath);
|
auto info = MesonInfoParser::mesonInfo(buildPath);
|
||||||
auto meson = MesonTools::mesonWrapper(m_meson);
|
auto meson = MesonTools::toolById(m_meson, ToolType::Meson);
|
||||||
return info && meson && info->mesonVersion == meson->version();
|
return info && meson && info->mesonVersion == meson->version();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool MesonProjectParser::run(const Command &command,
|
bool MesonProjectParser::run(const Command &command,
|
||||||
const Environment &env,
|
const Environment &env,
|
||||||
const QString &projectName,
|
const QString &projectName,
|
||||||
|
@@ -3,51 +3,51 @@
|
|||||||
|
|
||||||
#include "mesontools.h"
|
#include "mesontools.h"
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace MesonProjectManager {
|
namespace MesonProjectManager::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
MesonTools::Tool_t tool(const Id &id,
|
std::vector<MesonTools::Tool_t> s_tools;
|
||||||
const std::vector<MesonTools::Tool_t> &tools,
|
|
||||||
ToolType toolType)
|
static MesonTools::Tool_t findTool(const Id &id, ToolType toolType)
|
||||||
{
|
{
|
||||||
const auto tool = std::find_if(std::cbegin(tools),
|
const auto tool = std::find_if(std::cbegin(s_tools),
|
||||||
std::cend(tools),
|
std::cend(s_tools),
|
||||||
[&id](const MesonTools::Tool_t &tool) {
|
[&id](const MesonTools::Tool_t &tool) {
|
||||||
return tool->id() == id;
|
return tool->id() == id;
|
||||||
});
|
});
|
||||||
if (tool != std::cend(tools) && (*tool)->toolType() == toolType)
|
if (tool != std::cend(s_tools) && (*tool)->toolType() == toolType)
|
||||||
return *tool;
|
return *tool;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static MesonTools::Tool_t autoDetected(const std::vector<MesonTools::Tool_t> &tools, ToolType toolType)
|
MesonTools::Tool_t autoDetectedTool(ToolType toolType)
|
||||||
{
|
{
|
||||||
for (const auto &tool : tools) {
|
for (const auto &tool : s_tools) {
|
||||||
if (tool->autoDetected() && tool->toolType() == toolType)
|
if (tool->autoDetected() && tool->toolType() == toolType)
|
||||||
return tool;
|
return tool;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fixAutoDetected(std::vector<MesonTools::Tool_t> &tools, ToolType toolType)
|
static void fixAutoDetected(ToolType toolType)
|
||||||
{
|
{
|
||||||
MesonTools::Tool_t autoDetectedTool = autoDetected(tools, toolType);
|
MesonTools::Tool_t autoDetected = autoDetectedTool(toolType);
|
||||||
if (!autoDetectedTool) {
|
if (!autoDetected) {
|
||||||
QStringList exeNames;
|
QStringList exeNames;
|
||||||
QString toolName;
|
QString toolName;
|
||||||
if (toolType == ToolType::Meson) {
|
if (toolType == ToolType::Meson) {
|
||||||
if (std::optional<FilePath> path = findMesonTool()) {
|
if (std::optional<FilePath> path = findTool(toolType)) {
|
||||||
tools.emplace_back(
|
s_tools.emplace_back(
|
||||||
std::make_shared<ToolWrapper>(toolType,
|
std::make_shared<ToolWrapper>(toolType,
|
||||||
QString("System %1 at %2").arg("Meson").arg(path->toString()), *path, true));
|
QString("System %1 at %2").arg("Meson").arg(path->toString()), *path, true));
|
||||||
}
|
}
|
||||||
} else if (toolType == ToolType::Ninja) {
|
} else if (toolType == ToolType::Ninja) {
|
||||||
if (std::optional<FilePath> path = findNinjaTool()) {
|
if (std::optional<FilePath> path = findTool(toolType)) {
|
||||||
tools.emplace_back(
|
s_tools.emplace_back(
|
||||||
std::make_shared<ToolWrapper>(toolType,
|
std::make_shared<ToolWrapper>(toolType,
|
||||||
QString("System %1 at %2").arg("Ninja").arg(path->toString()), *path, true));
|
QString("System %1 at %2").arg("Ninja").arg(path->toString()), *path, true));
|
||||||
}
|
}
|
||||||
@@ -76,26 +76,28 @@ void MesonTools::addTool(const Id &itemId, const QString &name, const FilePath &
|
|||||||
|
|
||||||
void MesonTools::addTool(Tool_t meson)
|
void MesonTools::addTool(Tool_t meson)
|
||||||
{
|
{
|
||||||
auto self = instance();
|
s_tools.emplace_back(std::move(meson));
|
||||||
self->m_tools.emplace_back(std::move(meson));
|
emit instance()->toolAdded(s_tools.back());
|
||||||
emit self->toolAdded(self->m_tools.back());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MesonTools::setTools(std::vector<MesonTools::Tool_t> &&tools)
|
void MesonTools::setTools(std::vector<MesonTools::Tool_t> &&tools)
|
||||||
{
|
{
|
||||||
auto self = instance();
|
std::swap(s_tools, tools);
|
||||||
std::swap(self->m_tools, tools);
|
fixAutoDetected(ToolType::Meson);
|
||||||
fixAutoDetected(self->m_tools, ToolType::Meson);
|
fixAutoDetected(ToolType::Ninja);
|
||||||
fixAutoDetected(self->m_tools, ToolType::Ninja);
|
}
|
||||||
|
|
||||||
|
const std::vector<MesonTools::Tool_t> &MesonTools::tools()
|
||||||
|
{
|
||||||
|
return s_tools;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MesonTools::updateTool(const Id &itemId, const QString &name, const FilePath &exe)
|
void MesonTools::updateTool(const Id &itemId, const QString &name, const FilePath &exe)
|
||||||
{
|
{
|
||||||
auto self = instance();
|
auto item = std::find_if(std::begin(s_tools),
|
||||||
auto item = std::find_if(std::begin(self->m_tools),
|
std::end(s_tools),
|
||||||
std::end(self->m_tools),
|
|
||||||
[&itemId](const Tool_t &tool) { return tool->id() == itemId; });
|
[&itemId](const Tool_t &tool) { return tool->id() == itemId; });
|
||||||
if (item != std::end(self->m_tools)) {
|
if (item != std::end(s_tools)) {
|
||||||
(*item)->setExe(exe);
|
(*item)->setExe(exe);
|
||||||
(*item)->setName(name);
|
(*item)->setName(name);
|
||||||
} else {
|
} else {
|
||||||
@@ -105,31 +107,20 @@ void MesonTools::updateTool(const Id &itemId, const QString &name, const FilePat
|
|||||||
|
|
||||||
void MesonTools::removeTool(const Id &id)
|
void MesonTools::removeTool(const Id &id)
|
||||||
{
|
{
|
||||||
auto self = instance();
|
auto item = Utils::take(s_tools, [&id](const auto &item) { return item->id() == id; });
|
||||||
auto item = Utils::take(self->m_tools, [&id](const auto &item) { return item->id() == id; });
|
|
||||||
QTC_ASSERT(item, return );
|
QTC_ASSERT(item, return );
|
||||||
emit self->toolRemoved(*item);
|
emit instance()->toolRemoved(*item);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ToolWrapper> MesonTools::ninjaWrapper(const Id &id)
|
std::shared_ptr<ToolWrapper> MesonTools::toolById(const Id &id, ToolType toolType)
|
||||||
{
|
{
|
||||||
return tool(id, MesonTools::instance()->m_tools, ToolType::Ninja);
|
return findTool(id, toolType);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ToolWrapper> MesonTools::mesonWrapper(const Id &id)
|
MesonTools *MesonTools::instance()
|
||||||
{
|
{
|
||||||
return tool(id, MesonTools::instance()->m_tools, ToolType::Meson);
|
static MesonTools inst;
|
||||||
|
return &inst;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ToolWrapper> MesonTools::autoDetectedNinja()
|
} // MesonProjectManager::Internal
|
||||||
{
|
|
||||||
return autoDetected(MesonTools::instance()->m_tools, ToolType::Ninja);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<ToolWrapper> MesonTools::autoDetectedMeson()
|
|
||||||
{
|
|
||||||
return autoDetected(MesonTools::instance()->m_tools, ToolType::Meson);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace MesonProjectManager
|
|
||||||
|
@@ -5,12 +5,9 @@
|
|||||||
|
|
||||||
#include "toolwrapper.h"
|
#include "toolwrapper.h"
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace MesonProjectManager {
|
namespace MesonProjectManager::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class MesonTools : public QObject
|
class MesonTools : public QObject
|
||||||
{
|
{
|
||||||
@@ -32,31 +29,21 @@ public:
|
|||||||
|
|
||||||
static void setTools(std::vector<Tool_t> &&tools);
|
static void setTools(std::vector<Tool_t> &&tools);
|
||||||
|
|
||||||
static inline const std::vector<Tool_t> &tools() { return instance()->m_tools; }
|
static const std::vector<Tool_t> &tools();
|
||||||
|
|
||||||
static void updateTool(const Utils::Id &itemId,
|
static void updateTool(const Utils::Id &itemId,
|
||||||
const QString &name,
|
const QString &name,
|
||||||
const Utils::FilePath &exe);
|
const Utils::FilePath &exe);
|
||||||
static void removeTool(const Utils::Id &id);
|
static void removeTool(const Utils::Id &id);
|
||||||
|
|
||||||
static std::shared_ptr<ToolWrapper> ninjaWrapper(const Utils::Id &id);
|
static std::shared_ptr<ToolWrapper> toolById(const Utils::Id &id, ToolType toolType);
|
||||||
static std::shared_ptr<ToolWrapper> mesonWrapper(const Utils::Id &id);
|
|
||||||
|
|
||||||
static std::shared_ptr<ToolWrapper> autoDetectedNinja();
|
static std::shared_ptr<ToolWrapper> autoDetectedTool(ToolType toolType);
|
||||||
static std::shared_ptr<ToolWrapper> autoDetectedMeson();
|
|
||||||
|
|
||||||
Q_SIGNAL void toolAdded(const Tool_t &tool);
|
Q_SIGNAL void toolAdded(const Tool_t &tool);
|
||||||
Q_SIGNAL void toolRemoved(const Tool_t &tool);
|
Q_SIGNAL void toolRemoved(const Tool_t &tool);
|
||||||
|
|
||||||
static MesonTools *instance()
|
static MesonTools *instance();
|
||||||
{
|
|
||||||
static MesonTools inst;
|
|
||||||
return &inst;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::vector<Tool_t> m_tools;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // MesonProjectManager::Internal
|
||||||
} // namespace MesonProjectManager
|
|
||||||
|
@@ -34,7 +34,7 @@ static const QList<projectData> projectList{
|
|||||||
{ \
|
{ \
|
||||||
QTemporaryFile _intro_file; \
|
QTemporaryFile _intro_file; \
|
||||||
_intro_file.open(); \
|
_intro_file.open(); \
|
||||||
const auto tool = findMesonTool(); \
|
const auto tool = findTool(ToolType::Meson); \
|
||||||
QVERIFY(tool.has_value()); \
|
QVERIFY(tool.has_value()); \
|
||||||
const ToolWrapper _meson(ToolType::Meson, "name", *tool); \
|
const ToolWrapper _meson(ToolType::Meson, "name", *tool); \
|
||||||
run_meson(_meson.introspect(Utils::FilePath::fromString(_source_dir)), &_intro_file); \
|
run_meson(_meson.introspect(Utils::FilePath::fromString(_source_dir)), &_intro_file); \
|
||||||
@@ -53,7 +53,7 @@ private slots:
|
|||||||
Utils::LauncherInterface::setPathToLauncher(qApp->applicationDirPath() + '/'
|
Utils::LauncherInterface::setPathToLauncher(qApp->applicationDirPath() + '/'
|
||||||
+ QLatin1String(TEST_RELATIVE_LIBEXEC_PATH));
|
+ QLatin1String(TEST_RELATIVE_LIBEXEC_PATH));
|
||||||
|
|
||||||
const auto path = findMesonTool();
|
const auto path = findTool(ToolType::Meson);
|
||||||
if (!path)
|
if (!path)
|
||||||
QSKIP("Meson not found");
|
QSKIP("Meson not found");
|
||||||
}
|
}
|
||||||
@@ -76,7 +76,7 @@ private slots:
|
|||||||
{
|
{
|
||||||
QTemporaryDir build_dir{"test-meson"};
|
QTemporaryDir build_dir{"test-meson"};
|
||||||
FilePath buildDir = FilePath::fromString(build_dir.path());
|
FilePath buildDir = FilePath::fromString(build_dir.path());
|
||||||
const auto tool = findMesonTool();
|
const auto tool = findTool(ToolType::Meson);
|
||||||
QVERIFY(tool.has_value());
|
QVERIFY(tool.has_value());
|
||||||
ToolWrapper meson(ToolType::Meson, "name", *tool);
|
ToolWrapper meson(ToolType::Meson, "name", *tool);
|
||||||
run_meson(meson.setup(FilePath::fromString(src_dir), buildDir));
|
run_meson(meson.setup(FilePath::fromString(src_dir), buildDir));
|
||||||
|
@@ -30,21 +30,21 @@ private slots:
|
|||||||
Utils::LauncherInterface::setPathToLauncher(qApp->applicationDirPath() + '/'
|
Utils::LauncherInterface::setPathToLauncher(qApp->applicationDirPath() + '/'
|
||||||
+ QLatin1String(TEST_RELATIVE_LIBEXEC_PATH));
|
+ QLatin1String(TEST_RELATIVE_LIBEXEC_PATH));
|
||||||
|
|
||||||
const auto path = findMesonTool();
|
const auto path = findTool(ToolType::Meson);
|
||||||
if (!path)
|
if (!path)
|
||||||
QSKIP("Meson not found");
|
QSKIP("Meson not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
void shouldFindMesonFromPATH()
|
void shouldFindMesonFromPATH()
|
||||||
{
|
{
|
||||||
const auto path = findMesonTool();
|
const auto path = findTool(ToolType::Meson);
|
||||||
QVERIFY(path);
|
QVERIFY(path);
|
||||||
QVERIFY(path->exists());
|
QVERIFY(path->exists());
|
||||||
}
|
}
|
||||||
|
|
||||||
void shouldReportMesonVersion()
|
void shouldReportMesonVersion()
|
||||||
{
|
{
|
||||||
ToolWrapper meson(ToolType::Meson, "name", *findMesonTool());
|
ToolWrapper meson(ToolType::Meson, "name", *findTool(ToolType::Meson));
|
||||||
QVERIFY(meson.isValid());
|
QVERIFY(meson.isValid());
|
||||||
QVERIFY(meson.version().major == 0);
|
QVERIFY(meson.version().major == 0);
|
||||||
QVERIFY(meson.version().minor >= 50);
|
QVERIFY(meson.version().minor >= 50);
|
||||||
@@ -65,7 +65,7 @@ private slots:
|
|||||||
{
|
{
|
||||||
QFETCH(QString, src_dir);
|
QFETCH(QString, src_dir);
|
||||||
QTemporaryDir build_dir{"test-meson"};
|
QTemporaryDir build_dir{"test-meson"};
|
||||||
const ToolWrapper meson(ToolType::Meson, "name", *findMesonTool());
|
const ToolWrapper meson(ToolType::Meson, "name", *findTool(ToolType::Meson));
|
||||||
QVERIFY(run_meson(meson.setup(Utils::FilePath::fromString(src_dir),
|
QVERIFY(run_meson(meson.setup(Utils::FilePath::fromString(src_dir),
|
||||||
Utils::FilePath::fromString(build_dir.path()))));
|
Utils::FilePath::fromString(build_dir.path()))));
|
||||||
QVERIFY(
|
QVERIFY(
|
||||||
@@ -86,7 +86,7 @@ private slots:
|
|||||||
{
|
{
|
||||||
QFETCH(QString, src_dir);
|
QFETCH(QString, src_dir);
|
||||||
QTemporaryDir build_dir{"test-meson"};
|
QTemporaryDir build_dir{"test-meson"};
|
||||||
const ToolWrapper meson(ToolType::Meson, "name", *findMesonTool());
|
const ToolWrapper meson(ToolType::Meson, "name", *findTool(ToolType::Meson));
|
||||||
QVERIFY(run_meson(meson.setup(Utils::FilePath::fromString(src_dir),
|
QVERIFY(run_meson(meson.setup(Utils::FilePath::fromString(src_dir),
|
||||||
Utils::FilePath::fromString(build_dir.path()))));
|
Utils::FilePath::fromString(build_dir.path()))));
|
||||||
QVERIFY(run_meson(meson.configure(Utils::FilePath::fromString(src_dir),
|
QVERIFY(run_meson(meson.configure(Utils::FilePath::fromString(src_dir),
|
||||||
|
@@ -138,11 +138,7 @@ void MesonToolKitAspectImpl::loadTools()
|
|||||||
|
|
||||||
void MesonToolKitAspectImpl::setToDefault()
|
void MesonToolKitAspectImpl::setToDefault()
|
||||||
{
|
{
|
||||||
const MesonTools::Tool_t autoDetected = [this] {
|
const MesonTools::Tool_t autoDetected = MesonTools::autoDetectedTool(m_type);
|
||||||
if (m_type == ToolType::Meson)
|
|
||||||
return MesonTools::autoDetectedMeson();
|
|
||||||
return MesonTools::autoDetectedNinja();
|
|
||||||
}();
|
|
||||||
|
|
||||||
if (autoDetected) {
|
if (autoDetected) {
|
||||||
const auto index = indexOf(autoDetected->id());
|
const auto index = indexOf(autoDetected->id());
|
||||||
@@ -172,7 +168,7 @@ Id MesonToolKitAspect::mesonToolId(const Kit *kit)
|
|||||||
|
|
||||||
std::shared_ptr<ToolWrapper> MesonToolKitAspect::mesonTool(const Kit *kit)
|
std::shared_ptr<ToolWrapper> MesonToolKitAspect::mesonTool(const Kit *kit)
|
||||||
{
|
{
|
||||||
return MesonTools::mesonWrapper(MesonToolKitAspect::mesonToolId(kit));
|
return MesonTools::toolById(MesonToolKitAspect::mesonToolId(kit), ToolType::Meson);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MesonToolKitAspect::isValid(const Kit *kit)
|
bool MesonToolKitAspect::isValid(const Kit *kit)
|
||||||
@@ -208,7 +204,7 @@ public:
|
|||||||
{
|
{
|
||||||
const auto tool = MesonToolKitAspect::mesonTool(k);
|
const auto tool = MesonToolKitAspect::mesonTool(k);
|
||||||
if (!tool) {
|
if (!tool) {
|
||||||
const auto autoDetected = MesonTools::autoDetectedMeson();
|
const auto autoDetected = MesonTools::autoDetectedTool(ToolType::Meson);
|
||||||
if (autoDetected)
|
if (autoDetected)
|
||||||
MesonToolKitAspect::setMesonTool(k, autoDetected->id());
|
MesonToolKitAspect::setMesonTool(k, autoDetected->id());
|
||||||
}
|
}
|
||||||
@@ -253,7 +249,7 @@ Id NinjaToolKitAspect::ninjaToolId(const Kit *kit)
|
|||||||
|
|
||||||
std::shared_ptr<ToolWrapper> NinjaToolKitAspect::ninjaTool(const Kit *kit)
|
std::shared_ptr<ToolWrapper> NinjaToolKitAspect::ninjaTool(const Kit *kit)
|
||||||
{
|
{
|
||||||
return MesonTools::ninjaWrapper(NinjaToolKitAspect::ninjaToolId(kit));
|
return MesonTools::toolById(NinjaToolKitAspect::ninjaToolId(kit), ToolType::Ninja);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NinjaToolKitAspect::isValid(const Kit *kit)
|
bool NinjaToolKitAspect::isValid(const Kit *kit)
|
||||||
@@ -289,7 +285,7 @@ public:
|
|||||||
{
|
{
|
||||||
const auto tool = NinjaToolKitAspect::ninjaTool(k);
|
const auto tool = NinjaToolKitAspect::ninjaTool(k);
|
||||||
if (!tool) {
|
if (!tool) {
|
||||||
const auto autoDetected = MesonTools::autoDetectedNinja();
|
const auto autoDetected = MesonTools::autoDetectedTool(ToolType::Ninja);
|
||||||
if (autoDetected)
|
if (autoDetected)
|
||||||
NinjaToolKitAspect::setNinjaTool(k, autoDetected->id());
|
NinjaToolKitAspect::setNinjaTool(k, autoDetected->id());
|
||||||
}
|
}
|
||||||
|
@@ -102,17 +102,6 @@ Store ToolWrapper::toVariantMap() const
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::optional<FilePath> findTool(const QStringList &exeNames)
|
|
||||||
{
|
|
||||||
Environment systemEnvironment = Environment::systemEnvironment();
|
|
||||||
for (const auto &exe : exeNames) {
|
|
||||||
const FilePath exe_path = systemEnvironment.searchInPath(exe);
|
|
||||||
if (exe_path.exists())
|
|
||||||
return exe_path;
|
|
||||||
}
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename First>
|
template<typename First>
|
||||||
void impl_option_cat(QStringList &list, const First &first)
|
void impl_option_cat(QStringList &list, const First &first)
|
||||||
{
|
{
|
||||||
@@ -212,14 +201,25 @@ bool isSetup(const Utils::FilePath &buildPath)
|
|||||||
Constants::MESON_INTRO_BUILDSYSTEM_FILES);
|
Constants::MESON_INTRO_BUILDSYSTEM_FILES);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<FilePath> findMesonTool()
|
static std::optional<FilePath> findToolHelper(const QStringList &exeNames)
|
||||||
{
|
{
|
||||||
return findTool({"meson.py", "meson"});
|
Environment systemEnvironment = Environment::systemEnvironment();
|
||||||
|
for (const auto &exe : exeNames) {
|
||||||
|
const FilePath exe_path = systemEnvironment.searchInPath(exe);
|
||||||
|
if (exe_path.exists())
|
||||||
|
return exe_path;
|
||||||
|
}
|
||||||
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<FilePath> findNinjaTool()
|
std::optional<FilePath> findTool(ToolType toolType)
|
||||||
{
|
{
|
||||||
return findTool({"ninja", "ninja-build"});
|
if (toolType == ToolType::Meson)
|
||||||
|
return findToolHelper({"meson.py", "meson"});
|
||||||
|
if (toolType == ToolType::Ninja)
|
||||||
|
return findToolHelper({"ninja", "ninja-build"});
|
||||||
|
QTC_CHECK(false);
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -81,8 +81,7 @@ bool run_meson(const Command &command, QIODevice *output = nullptr);
|
|||||||
|
|
||||||
bool isSetup(const Utils::FilePath &buildPath);
|
bool isSetup(const Utils::FilePath &buildPath);
|
||||||
|
|
||||||
std::optional<Utils::FilePath> findMesonTool();
|
std::optional<Utils::FilePath> findTool(ToolType toolType);
|
||||||
std::optional<Utils::FilePath> findNinjaTool();
|
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace MesonProjectManager
|
} // namespace MesonProjectManager
|
||||||
|
Reference in New Issue
Block a user