2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2020 Alexis Jeandet.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2020-05-01 18:20:56 +02:00
|
|
|
|
|
|
|
|
#include "ninjatoolkitaspect.h"
|
2020-10-29 10:20:14 +01:00
|
|
|
|
2022-10-10 09:14:04 +02:00
|
|
|
#include "mesonprojectmanagertr.h"
|
2020-05-01 18:20:56 +02:00
|
|
|
#include "toolkitaspectwidget.h"
|
2020-10-29 10:20:14 +01:00
|
|
|
|
|
|
|
|
#include <utils/qtcassert.h>
|
2020-05-01 18:20:56 +02:00
|
|
|
|
|
|
|
|
namespace MesonProjectManager {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
static const char TOOL_ID[] = "MesonProjectManager.MesonKitInformation.Ninja";
|
|
|
|
|
|
|
|
|
|
NinjaToolKitAspect::NinjaToolKitAspect()
|
|
|
|
|
{
|
|
|
|
|
setObjectName(QLatin1String("NinjaKitAspect"));
|
|
|
|
|
setId(TOOL_ID);
|
2022-10-10 09:14:04 +02:00
|
|
|
setDisplayName(Tr::tr("Ninja Tool"));
|
|
|
|
|
setDescription(Tr::tr("The Ninja tool to use when building a project with Meson.<br>"
|
|
|
|
|
"This setting is ignored when using other build systems."));
|
2020-05-01 18:20:56 +02:00
|
|
|
setPriority(9000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::Tasks NinjaToolKitAspect::validate(const ProjectExplorer::Kit *k) const
|
|
|
|
|
{
|
|
|
|
|
ProjectExplorer::Tasks tasks;
|
|
|
|
|
const auto tool = ninjaTool(k);
|
|
|
|
|
if (tool && !tool->isValid())
|
|
|
|
|
tasks << ProjectExplorer::BuildSystemTask{ProjectExplorer::Task::Warning,
|
2022-10-10 09:14:04 +02:00
|
|
|
Tr::tr("Cannot validate this Ninja executable.")};
|
2020-05-01 18:20:56 +02:00
|
|
|
return tasks;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NinjaToolKitAspect::setup(ProjectExplorer::Kit *k)
|
|
|
|
|
{
|
|
|
|
|
const auto tool = ninjaTool(k);
|
|
|
|
|
if (!tool) {
|
|
|
|
|
const auto autoDetected = MesonTools::ninjaWrapper();
|
|
|
|
|
if (autoDetected)
|
|
|
|
|
setNinjaTool(k, autoDetected->id());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NinjaToolKitAspect::fix(ProjectExplorer::Kit *k)
|
|
|
|
|
{
|
|
|
|
|
setup(k);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::KitAspect::ItemList NinjaToolKitAspect::toUserOutput(
|
|
|
|
|
const ProjectExplorer::Kit *k) const
|
|
|
|
|
{
|
|
|
|
|
const auto tool = ninjaTool(k);
|
|
|
|
|
if (tool)
|
2022-10-10 09:14:04 +02:00
|
|
|
return {{Tr::tr("Ninja"), tool->name()}};
|
|
|
|
|
return {{Tr::tr("Ninja"), Tr::tr("Unconfigured")}};
|
2020-05-01 18:20:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::KitAspectWidget *NinjaToolKitAspect::createConfigWidget(ProjectExplorer::Kit *k) const
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(k, return nullptr);
|
|
|
|
|
return new ToolKitAspectWidget{k, this, ToolKitAspectWidget::ToolType::Ninja};
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-26 13:59:38 +02:00
|
|
|
void NinjaToolKitAspect::setNinjaTool(ProjectExplorer::Kit *kit, Utils::Id id)
|
2020-05-01 18:20:56 +02:00
|
|
|
{
|
|
|
|
|
QTC_ASSERT(kit && id.isValid(), return );
|
|
|
|
|
kit->setValue(TOOL_ID, id.toSetting());
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-26 13:59:38 +02:00
|
|
|
Utils::Id NinjaToolKitAspect::ninjaToolId(const ProjectExplorer::Kit *kit)
|
2020-05-01 18:20:56 +02:00
|
|
|
{
|
|
|
|
|
QTC_ASSERT(kit, return {});
|
2020-06-26 13:59:38 +02:00
|
|
|
return Utils::Id::fromSetting(kit->value(TOOL_ID));
|
2020-05-01 18:20:56 +02:00
|
|
|
}
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace MesonProjectManager
|