2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2020 Alexis Jeandet.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2020-05-01 18:20:56 +02:00
|
|
|
|
|
|
|
|
#include "mesontoolkitaspect.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
|
|
|
|
2020-05-01 18:20:56 +02:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
2023-08-17 18:12:06 +02:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
2023-08-10 16:20:25 +02:00
|
|
|
namespace MesonProjectManager::Internal {
|
2020-05-01 18:20:56 +02:00
|
|
|
|
2023-08-17 18:12:06 +02:00
|
|
|
const char TOOL_ID[] = "MesonProjectManager.MesonKitInformation.Meson";
|
2020-05-01 18:20:56 +02:00
|
|
|
|
2023-08-17 18:12:06 +02:00
|
|
|
void MesonToolKitAspect::setMesonTool(Kit *kit, Utils::Id id)
|
2020-05-01 18:20:56 +02:00
|
|
|
{
|
2023-08-17 18:12:06 +02:00
|
|
|
QTC_ASSERT(kit && id.isValid(), return );
|
|
|
|
|
kit->setValue(TOOL_ID, id.toSetting());
|
2020-05-01 18:20:56 +02:00
|
|
|
}
|
|
|
|
|
|
2023-08-17 18:12:06 +02:00
|
|
|
Utils::Id MesonToolKitAspect::mesonToolId(const Kit *kit)
|
2020-05-01 18:20:56 +02:00
|
|
|
{
|
2023-08-17 18:12:06 +02:00
|
|
|
QTC_ASSERT(kit, return {});
|
|
|
|
|
return Utils::Id::fromSetting(kit->value(TOOL_ID));
|
2020-05-01 18:20:56 +02:00
|
|
|
}
|
|
|
|
|
|
2023-08-17 18:12:06 +02:00
|
|
|
// MesonToolKitAspectFactory
|
|
|
|
|
|
|
|
|
|
class MesonToolKitAspectFactory final : public KitAspectFactory
|
2020-05-01 18:20:56 +02:00
|
|
|
{
|
2023-08-17 18:12:06 +02:00
|
|
|
public:
|
|
|
|
|
MesonToolKitAspectFactory()
|
|
|
|
|
{
|
|
|
|
|
setId(TOOL_ID);
|
|
|
|
|
setDisplayName(Tr::tr("Meson Tool"));
|
|
|
|
|
setDescription(Tr::tr("The Meson tool to use when building a project with Meson.<br>"
|
|
|
|
|
"This setting is ignored when using other build systems."));
|
|
|
|
|
setPriority(9000);
|
2020-05-01 18:20:56 +02:00
|
|
|
}
|
|
|
|
|
|
2023-08-17 18:12:06 +02:00
|
|
|
Tasks validate(const Kit *k) const final
|
|
|
|
|
{
|
|
|
|
|
Tasks tasks;
|
|
|
|
|
const auto tool = MesonToolKitAspect::mesonTool(k);
|
|
|
|
|
if (tool && !tool->isValid())
|
|
|
|
|
tasks << BuildSystemTask{Task::Warning, Tr::tr("Cannot validate this meson executable.")};
|
|
|
|
|
return tasks;
|
|
|
|
|
}
|
2020-05-01 18:20:56 +02:00
|
|
|
|
2023-08-17 18:12:06 +02:00
|
|
|
void setup(Kit *k) final
|
|
|
|
|
{
|
|
|
|
|
const auto tool = MesonToolKitAspect::mesonTool(k);
|
|
|
|
|
if (!tool) {
|
|
|
|
|
const auto autoDetected = MesonTools::mesonWrapper();
|
|
|
|
|
if (autoDetected)
|
|
|
|
|
MesonToolKitAspect::setMesonTool(k, autoDetected->id());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void fix(Kit *k) final
|
|
|
|
|
{
|
|
|
|
|
setup(k);
|
|
|
|
|
}
|
2020-05-01 18:20:56 +02:00
|
|
|
|
2023-11-14 14:24:48 +01:00
|
|
|
KitAspect *createKitAspect(Kit *k) const override
|
2023-08-17 18:12:06 +02:00
|
|
|
{
|
|
|
|
|
return new ToolKitAspectWidget{k, this, ToolKitAspectWidget::ToolType::Meson};
|
|
|
|
|
}
|
2020-05-01 18:20:56 +02:00
|
|
|
|
2023-11-14 14:24:48 +01:00
|
|
|
ItemList toUserOutput(const Kit *k) const override
|
2023-08-17 18:12:06 +02:00
|
|
|
{
|
|
|
|
|
const auto tool = MesonToolKitAspect::mesonTool(k);
|
|
|
|
|
if (tool)
|
|
|
|
|
return {{Tr::tr("Meson"), tool->name()}};
|
|
|
|
|
return {{Tr::tr("Meson"), Tr::tr("Unconfigured")}};
|
|
|
|
|
}
|
|
|
|
|
};
|
2020-05-01 18:20:56 +02:00
|
|
|
|
2023-08-17 18:12:06 +02:00
|
|
|
const MesonToolKitAspectFactory theMesonKitAspectFactory;
|
2023-08-10 16:20:25 +02:00
|
|
|
|
|
|
|
|
} // MesonProjectManager::Internal
|