To add on to my below mail content , when I use tc->setLanguage ( ProjectExplorer::Constants::C_Language_ID)
I find the compiler is set to GCC but I want it to be set as GCC (C, x86 64 bit in /usr/bin ) Not sure how to append x86 64 bit and the path to it . Regards Vidhya On Fri, 10 Jul 2020 at 9:42 PM, Vidhya Arun <svidhyap...@gmail.com> wrote: > Hi Antonio > > Just found the below mail thread couple of years older that helped in > setting the compiler path for my toolchain. This worked fine then for the > older version of Qt creator. > > Now I’m trying to port the same plugin to one of the latest version of Qt > creator 4.12 and I find the toolchain is not set right and the compiler C > and C++ is always empty for the new created kit. > > I used the same code as below under kit initialization. This is the same > place where Sysroot paths and device types are set successfully. > > ProjectExplorer::ToolChain *tc = new MyToolchainClass(...); > ProjectExplorer::ToolChainManager::registerToolChain(tc); > ProjectExplorer::ToolchainKitInformation::setToolChain(kit, tc ); > > > Kindly request your support to understand why this is not set right. > > Regards > Vidhya > > On Thu, 28 Dec 2017 at 10:21 PM, Antonio Di Monaco <t...@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" svidhyap...@gmail.com >> To: "Antonio Di Monaco" t...@becrux.com >> Cc: qt-creator@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@qt-project.org https://lists.qt-project.org/listinfo/qt-creator