[Qt-creator] Plugin development - Anubis language support
JeremY Larrieu
adrenalinedj at gmail.com
Wed May 3 18:37:07 CEST 2017
Hello,
As you can see in the new screenshot attached, the Anubis compiler is auto
detected.
Here is the code to "auto-detect" kits based on the "auto detected Anubis
toolchains" (it's based on what i found in the android plugin):
const QList<ProjectExplorer::Kit*> existingKits =
Utils::filtered(ProjectExplorer::KitManager::kits(), [](const
ProjectExplorer::Kit *k) {
return k->isAutoDetected();
});
QList<ProjectExplorer::Kit*> newKits;
const QList<ProjectExplorer::ToolChain *> filteredToolchains =
ProjectExplorer::ToolChainManager::toolChains([](const
ProjectExplorer::ToolChain *tc) {
return tc->isAutoDetected()
&& tc->isValid()
&& tc->typeId() == Constants::AnubisToolchainId;
});
const QList<AnubisToolChain*> toolchains =
Utils::transform(filteredToolchains, [](ProjectExplorer::ToolChain *tc) {
return static_cast<AnubisToolChain *>(tc);
});
for (AnubisToolChain *tc : toolchains) {
ProjectExplorer::Kit *newKit = new ProjectExplorer::Kit;
newKit->setAutoDetected(true);
newKit->setAutoDetectionSource("PyramIDEConfiguration");
auto findExistingKit = [newKit](const ProjectExplorer::Kit *k) {
return matchKits(newKit, k); };
ProjectExplorer::Kit *existingKit =
Utils::findOrDefault(existingKits, findExistingKit);
if (existingKit) {
ProjectExplorer::KitManager::deleteKit(newKit);
newKit = existingKit;
}
auto keys = newKit->allKeys();
for (Core::Id key : keys) {
qDebug("key => " + key.toString().toLatin1() + " | value => " +
newKit->value(key).toString().toLatin1());
}
auto toto = newKit->toHtml();
qDebug("html:\n" + toto.toLatin1() + "\n");
newKit->makeSticky();
newKit->setUnexpandedDisplayName(QObject::tr("Anubis
%1").arg(tc->compilerVersion()));
if (!existingKit)
{
ProjectExplorer::KitManager::registerKit(newKit);
}
}
It's triggered in the plugin entry point (initialize method) on the
"kitsLoaded" signal of KitManager:
connect(KitManager::instance(), &KitManager::kitsLoaded, this,
&PyramIDEPlugin::kitsRestored);
void PyramIDEPlugin::kitsRestored()
{
PyramIDEConfigurations::updateAutomaticKitList();
disconnect(KitManager::instance(), &KitManager::kitsChanged, this,
&PyramIDEPlugin::kitsRestored);
}
Thanks for your help.
Jeremy
2017-05-03 15:14 GMT+02:00 Tobias Hunger <Tobias.Hunger at qt.io>:
> Hi JeremY,
>
> Based on your screenshot: My guess is that Qt Creator does not have any
> compiler defined for your language.
>
> What does the Tool chains tab show? Is there an anubis compiler listed
> there?
>
> Best Regards,
> Tobias
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20170503/0283c3ce/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Capture du 2017-05-03 18-23-17.png
Type: image/png
Size: 123095 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20170503/0283c3ce/attachment.png>
More information about the Qt-creator
mailing list