[Qt-creator] Update QtCreator kits thru plugin

Vidhya Arun svidhyapria at gmail.com
Fri Jan 5 14:34:05 CET 2018


Is there a possibility to update the additional startup and attach commands
too under debugger->gdb of Options in QtCreator ?

I find some variables related to it in debugger plugjn but couldn't locate
any specific methods exposed for this purpose.

-Vidhya

On Wed, 3 Jan 2018 at 12:49 PM, Vidhya Arun <svidhyapria at gmail.com> wrote:

> Thank you Eike. This was the issue.
> It works fine when I try mapping with some action instead of initialize or
> delayInitialize methods.
>
> -Vidhya
>
> On Tue, 2 Jan 2018 at 2:20 PM, Eike Ziller <Eike.Ziller at qt.io> wrote:
>
>>
>>
>> > On 2. Jan 2018, at 03:40, Vidhya Arun <svidhyapria at gmail.com> wrote:
>> >
>> > Yes Antonio , I did create in initialize methods only. I have created
>> the kit, registered the toolchain and set the device type Id and left out
>> the rest of steps to initially check if kit is loaded with some dummy data.
>> > I find the code getting executed but also I find below soft assert
>> statements during execution. Not sure if these cause failure on listing the
>> kits after execution
>> >
>> > Starting /opt/qtcreator-4.4.1/bin/qtcreator...
>> > QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to
>> '/tmp/runtime-root'
>> > libGL error: pci id for fd 6: 80ee:beef, driver (null)
>> > libGL error: core dri or dri2 extension not found
>> > libGL error: failed to load driver: vboxvideo
>> > SOFT ASSERT: "ToolChainManager::isLoaded()" in file
>> /work/build/qt-creator/src/plugins/projectexplorer/kitinformation.cpp, line
>> 385
>> > SOFT ASSERT: "isLanguageSupported(tc->language())" in file
>> /work/build/qt-creator/src/plugins/projectexplorer/toolchainmanager.cpp,
>> line 408
>> > SOFT ASSERT: "isLoaded()" in file
>> /work/build/qt-creator/src/plugins/projectexplorer/kitmanager.cpp, line 440
>> > SOFT ASSERT: "DeviceManager::instance()->isLoaded()" in file
>> /work/build/qt-creator/src/plugins/projectexplorer/kitinformation.cpp, line
>> 727
>> > SOFT ASSERT: "QtVersionManager::isLoaded()" in file
>> /work/build/qt-creator/src/plugins/qtsupport/qtkitinformation.cpp, line 76
>> > SOFT ASSERT: "isLoaded()" in file
>> /work/build/qt-creator/src/plugins/qtsupport/qtversionmanager.cpp, line 529
>> > SOFT ASSERT: "isLoaded()" in file
>> /work/build/qt-creator/src/plugins/qtsupport/qtversionmanager.cpp, line 529
>> > SOFT ASSERT: "ToolChainManager::isLoaded()" in file
>> /work/build/qt-creator/src/plugins/projectexplorer/kitinformation.cpp, line
>> 385
>> > SOFT ASSERT: "ToolChainManager::isLoaded()" in file
>> /work/build/qt-creator/src/plugins/projectexplorer/kitinformation.cpp, line
>> 385
>> > SOFT ASSERT: "isLoaded()" in file
>> /work/build/qt-creator/src/plugins/qtsupport/qtversionmanager.cpp, line 529
>> > SOFT ASSERT: "isLoaded()" in file
>> /work/build/qt-creator/src/plugins/qtsupport/qtversionmanager.cpp, line 529
>> > SOFT ASSERT: "ToolChainManager::isLoaded()" in file
>> /work/build/qt-creator/src/plugins/projectexplorer/kitinformation.cpp, line
>> 385
>> > SOFT ASSERT: "ToolChainManager::isLoaded()" in file
>> /work/build/qt-creator/src/plugins/projectexplorer/kitinformation.cpp, line
>> 385
>> > SOFT ASSERT: "DeviceManager::instance()->isLoaded()" in file
>> /work/build/qt-creator/src/plugins/projectexplorer/kitinformation.cpp, line
>> 727
>> > SOFT ASSERT: "QtVersionManager::isLoaded()" in file
>> /work/build/qt-creator/src/plugins/qtsupport/qtkitinformation.cpp, line 76
>> > SOFT ASSERT: "isLoaded()" in file
>> /work/build/qt-creator/src/plugins/qtsupport/qtversionmanager.cpp, line 529
>> > SOFT ASSERT: "isLoaded()" in file
>> /work/build/qt-creator/src/plugins/qtsupport/qtversionmanager.cpp, line 529
>> > SOFT ASSERT: "ToolChainManager::isLoaded()" in file
>> /work/build/qt-creator/src/plugins/projectexplorer/kitinformation.cpp, line
>> 385
>> > SOFT ASSERT: "ToolChainManager::isLoaded()" in file
>> /work/build/qt-creator/src/plugins/projectexplorer/kitinformation.cpp, line
>> 385
>> > SOFT ASSERT: "isLoaded()" in file
>> /work/build/qt-creator/src/plugins/qtsupport/qtversionmanager.cpp, line 529
>> > SOFT ASSERT: "isLoaded()" in file
>> /work/build/qt-creator/src/plugins/qtsupport/qtversionmanager.cpp, line 529
>> > SOFT ASSERT: "ToolChainManager::isLoaded()" in file
>> /work/build/qt-creator/src/plugins/projectexplorer/kitinformation.cpp, line
>> 385
>> > SOFT ASSERT: "ToolChainManager::isLoaded()" in file
>> /work/build/qt-creator/src/plugins/projectexplorer/kitinformation.cpp, line
>> 385
>> > SOFT ASSERT: "DeviceManager::instance()->isLoaded()" in file
>> /work/build/qt-creator/src/plugins/projectexplorer/kitinformation.cpp, line
>> 727
>> > SOFT ASSERT: "ToolChainManager::isLoaded()" in file
>> /work/build/qt-creator/src/plugins/projectexplorer/kitinformation.cpp, line
>> 385
>> > SOFT ASSERT: "isLoaded()" in file
>> /work/build/qt-creator/src/plugins/qtsupport/qtversionmanager.cpp, line 529
>> > No build configuration factory found for target id 'MyKit'.
>> > SOFT ASSERT: "ToolChainManager::isLoaded()" in file
>> /work/build/qt-creator/src/plugins/projectexplorer/kitinformation.cpp, line
>> 385
>> > SOFT ASSERT: "DeviceManager::instance()->isLoaded()" in file
>> /work/build/qt-creator/src/plugins/projectexplorer/kitinformation.cpp, line
>> 727
>> > SOFT ASSERT: "DeviceManager::instance()->isLoaded()" in file
>> /work/build/qt-creator/src/plugins/projectexplorer/kitinformation.cpp, line
>> 727
>> > SOFT ASSERT: "DeviceManager::instance()->isLoaded()" in file
>> /work/build/qt-creator/src/plugins/projectexplorer/kitinformation.cpp, line
>> 727
>> > No tool chain set up in kit "target" for "C".
>> > No tool chain set up in kit "target" for "C”.
>>
>> These asserts mean that you are trying to do things with tool chains and
>> kits too early. The kits are only restored in the ProjectExplorer plugin’s
>> delayedInitialize() (
>> http://doc-snapshots.qt.io/qtcreator-extending/plugin-lifecycle.html),
>> so if you can not work with kits/toolchains in your initialize().
>> A sensible way for you to delay the actions that you take is probably to
>> connect to ProjectExplorer::KitManager::kitsLoaded() and do it there.
>>
>> Br, Eike
>>
>> > Regards
>> > Vidhya
>> >
>> >
>> >
>> > On Tue, 2 Jan 2018 at 1:49 AM, Antonio Di Monaco <tony at becrux.com>
>> wrote:
>> > Hi Arun,
>> >
>> > my kits are created when the project is loaded. My code starts in
>> Project::fromMap method.
>> >
>> > In case you'd like to create your kits at plugin startup, then you need
>> a different method, i.e. YourPluginClass::extensionsInitialized or
>> YourPluginClass::initialize (I assume the first one is better).
>> >
>> > Of course, you cannot create any target, just kits, toolchains and
>> tools.
>> >
>> > Thanks,
>> > A.
>> >
>> >
>> > From: "Vidhya Arun" svidhyapria at gmail.com
>> > To: "Antonio Di Monaco" tony at becrux.com
>> > Cc: qt-creator at qt-project.org
>> > Date: Mon, 1 Jan 2018 22:51:15 +0530
>> > Subject: Re: [Qt-creator] Update QtCreator kits thru plugin
>> >
>> > Hi Antonio
>> >
>> > Tried your steps and built the plugin. Is the kit expected to be listed
>> automatically under Tools/Options/Build &Run/Kits once the plugin is built
>> and loaded successfully in Qt creator ?
>> > Unfortunately I dont see my kit listed there when i execute the plugin ?
>> >
>> > Meanwhile are all the steps mandatory to be followed. Initially I just
>> wanted to check if the kit gets created with the registered kit name and
>> toolchain, sysroot details added in plugin.
>> > Thats not happening yet. Any hints on what could have gone wrong here ?
>> >
>> > -Vidhya
>> >
>> >
>> > On Thu, Dec 28, 2017 at 10:21 PM, Antonio Di Monaco <tony at becrux.com>
>> wrote:
>> > Hi Arun,
>> >
>> > unfortunately I cannot share the code, but I can provide you some basic
>> steps in order to do that. Please note that what I'm posting is just the
>> result of my understanding of the Qt Creator code, so I could be not
>> correct 100%. I was not able to find any kind of documentation, so YMMV.
>> >
>> > Basically, you need to create a toolchain first. You can subclass from
>> ProjectExplorer::GccToolchain, in order to create a GCC/Clang toolchain, or
>> ProjectExplorer::Internal::AbstractMsvcToolchain, for MSVC compiler (yeah,
>> that should not be allowed, but there are no MSVC base classes that are
>> exported through the PROJECTEXPLORER_EXPORT macro. Anyway, it works, you
>> just need some code from MsvcToolchain class).
>> >
>> > Once you have it, create a Kit in your Project class. You can do it in
>> the fromMap method, for example (called when your project is loaded):
>> >
>> > ProjectExplorer::Kit *kit = new ProjectExplorer::Kit(YOUR_ID);
>> > kit->setUnexpandedDisplayName(YOUR_DISPLAY_NAME);
>> > kit->setAutoDetected(false);
>> >
>> > You can add your personal values too, using:
>> >
>> > kit->setValueSilently(KEY, VALUE);
>> >
>> > that you can access later calling kit->value(KEY).
>> >
>> > Then, you can add all the required information:
>> >
>> > - sysroot:
>> >
>> > ProjectExplorer::SysRootKitInformation::setSysRoot(kit,
>> PATH_OF_THE_SYSROOT);
>> >
>> >
>> > - toolchain:
>> >
>> > ProjectExplorer::ToolChain *tc = new Your_ToolChain_Class(...);
>> > ProjectExplorer::ToolChainManager::registerToolChain(tc);
>> > ProjectExplorer::ToolChainKitInformation::setToolChain(kit, tc);
>> >
>> > you can add one for C, and one for C++, according to the LanguageId
>> that you specify in Your_ToolChain_Class.
>> >
>> >
>> > - If you have a CMake configuration for your kit, you can add it too:
>> >
>> > /* vvvvv do this group once vvvvv */
>> > CMakeProjectManager::CMakeTool *cmakeTool = new
>> CMakeProjectManager::CMakeTool(CMakeProjectManager::CMakeTool::ManualDetection,
>> THE_ID_OF_YOUR_CMAKE_COMMAND);
>> > cmakeTool->setAutorun(false);
>> > cmakeTool->setCMakeExecutable("....");
>> > cmakeTool->setDisplayName("....");
>> >
>> > CMakeProjectManager::CMakeToolManager::registerCMakeTool(cmakeTool);
>> > /* ^^^^^ do this group once ^^^^^^ */
>> >
>> > CMakeProjectManager::CMakeKitInformation::setCMakeTool(kit,
>> THE_ID_OF_YOUR_CMAKE_COMMAND);
>> > CMakeProjectManager::CMakeGeneratorKitInformation::setGenerator(kit,
>> "...");
>> >
>> CMakeProjectManager::CMakeGeneratorKitInformation::setExtraGenerator(kit,
>> "....");
>> >
>> CMakeProjectManager::CMakeConfigurationKitInformation::setConfiguration(kit,
>> CMakeProjectManager::CMakeConfig(...));
>> >
>> >
>> > - Qt can be set up in a similar way. Unfortunately, I don't know how,
>> cause I'm not using Qt libraries for my kit, so I clear out the information
>> in the kit:
>> >
>> >  QmakeProjectManager::QmakeKitInformation::setMkspec(kit,
>> Utils::FileName());
>> >  QtSupport::QtKitInformation::setQtVersionId(kit, 0);
>> >
>> > Maybe you can have a look at those function calls, and specify
>> different parameters.
>> >
>> >
>> > - Debugger:
>> >
>> > Debugger::DebuggerItem debugger;
>> >
>> > debugger.setCommand("...");
>> > debugger.setEngineType(Debugger::GdbEngineType or
>> Debugger::CdbEngineType);
>> >
>> > debugger.setUnexpandedDisplayName("...");
>> > debugger.setAutoDetected(true);
>> > debugger.setAbi(tc->targetAbi());
>> > debugger.setWorkingDirectory("...");
>> > debugger.reinitializeFromFile();
>> >
>> > Debugger::DebuggerKitInformation::setDebugger(kit,
>> Debugger::DebuggerItemManager::registerDebugger(debugger));
>> >
>> >
>> > - Device type (Desktop in my case):
>> >
>> > ProjectExplorer::DeviceTypeKitInformation::setDeviceTypeId(kit,
>> ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
>> >
>> >
>> > When you're done, you register the kit:
>> >
>> > ProjectExplorer::KitManager::registerKit(kit);
>> >
>> >
>> > In order to consume it, you need a target:
>> >
>> > ProjectExplorer::Target *tgt = createTarget(kit);
>> > tgt->setDefaultDisplayName("...");
>> > tgt->setDisplayName("...");
>> > addTarget(tgt);
>> >
>> > That's it.
>> >
>> >
>> >
>> > Toolchains can be unregistered using:
>> >
>> > ProjectExplorer::ToolChainKitInformation::clearToolChain(kit,
>> tc->language());
>> > ProjectExplorer::ToolChainManager::deregisterToolChain(tc);
>> >
>> > So the debugger:
>> >
>> > const Debugger::DebuggerItem *dbgItem =
>> Debugger::DebuggerKitInformation::debugger(kit);
>> >
>> > if (dbgItem)
>> >   Debugger::DebuggerItemManager::deregisterDebugger(dbgItem->id());
>> >
>> > the kit:
>> >
>> > ProjectExplorer::KitManager::deregisterKit(kit);
>> >
>> > and your CMake tool:
>> >
>> >
>> CMakeProjectManager::CMakeToolManager::deregisterCMakeTool(THE_ID_OF_YOUR_CMAKE_COMMAND);
>> >
>> >
>> >
>> > Those are the basics. If you need more help, please ask for a specific
>> topic, cause it's very wide to be fully explained.
>> >
>> > Hope that this will help you.
>> >
>> > BR,
>> > Antonio
>> >
>> >
>> > From: "Vidhya Arun" svidhyapria at gmail.com
>> > To: "Antonio Di Monaco" tony at becrux.com
>> > Cc: qt-creator at qt-project.org
>> > Date: Wed, 27 Dec 2017 16:45:01 +0000
>> > Subject: [Qt-creator] Update QtCreator kits thru plugin
>> >
>> > Hi
>> >
>> > I am trying to create my plugin to create the kit to update sysroot,
>> target connection details,etc.
>> >
>> > But I couldn't locate how to update sysroot and other details of Qt
>> creator thru plugin.  Any suggestions would be appreciated.
>> >
>> >
>> >
>> > _______________________________________________
>> > Qt-creator mailing list
>> > Qt-creator at qt-project.org
>> > http://lists.qt-project.org/mailman/listinfo/qt-creator
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20180105/7d979f82/attachment.html>


More information about the Qt-creator mailing list