Hi,
I started developing a plugin for Qt Creator, to support the Rust language. It is in its very early stage, so there's nothing very exciting to see yet! I'll share the project page anyway:
https://bitbucket.org/olivren/rustycreator
I am a long time user of Qt Creator, but I am discovering the extensions API as I develop this plugin. I have a lot of questions to ask :)
As you may know, Rust is a compiled language, and thus my idea was to mimic how C++ compilers and build systems are declared, detected, configured and used in Qt Creator.
The Rust compiler is called rustc, and at any point in time there is a stable release, a beta release and a nightly release. Also, rustc supports cross-compilation. I would like to let the user choose the compiler version he wants, just by switching his compilation targets (it is common in Rust to compile his code against both the nightly and the stable versions). Supportting cross-compilation would be awesome, but I have no experience with this use case.
Rust has an official build tool called Cargo. I was thinking about handling the detection/configuration of Cargo in the same way the C++ build tools are handled.
I plan on supporting only Cargo-based projects. For now, my plugin can do only one thing: open a Cargo.toml file (the config file used by Cargo) as if it was a Qt Creator project file. When the Cargo.toml file is chosen, the whole content of the directory is shown in the project explorer.
Now, I am a bit stuck on how to support the compilers and build tool configurations. The Qt Creator code base is very clean and the architecture makes a lot of sense, so it is ok to navigate the code and somewhat understand how things fit together. But most of the time I really miss API docs. Anyway, my current attempt is to subclass ToolChainFactory, ToolChainConfigWidget and ToolChain, and to register my ToolChainFactory instance to the object pool. (By the way, I had a hard time finding out that ToolChainFactory could be part of the object pool, as the class name doesn't start with an "I"). This gives me a new entry in the "compilers" options panel that I can add to the list, and then this new compiler appears in the "Compiler" field of the "Kits" options panel.
So far so good! But in the end, it feels a bit clumsy to mix the Rust compilers and the C++ compilers in the same place. For example the ToolChain API has C++ specific methods (predefinedMacros, systemHeaderPaths). It feels wrong to have "Qt version", "Qt mkspec" or "CMake Tool" fields in the kit of a Rust project. I don't know where I should add the configuration for the Cargo tool. On the other hand, the concept of "Kit" seems to be very central to Qt Creator, and I am under the impression that I could not provide custom build steps without providing a dedicated Kit for Rust. I know that I can add new fields to the Kits configurations (by creating new KitInformation instances), but it seems that these new fields will be global to all kits, I don't see how to have a custom Rust Kit with only the fields I need.
I don't know where to go from here. I'm not sure I can continue without providing a Kit, but maybe I missed something in the API. Another approach I was thinking about was to remove entirely all C++ support from Qt Creator, to make it a Rust-only IDE where I'd have a full control on what is proposed to the user. Yet another way would be to not try to reuse the exising compiler/device/build tool support from ProjectExplorer, but create my own options panes. Not sure if it is possible, because most of the classes in ProjectExplorer use Kits in one way or another.
Any suggestions? Is there another compiled language that Qt Creator supports that I could borrow ideas from? I often look at the Python and Ruby plugins, but these are not compiled languages and they don't have these problems.
One last thing: there are a lot of places that require creating an Id instance. What is the purpose of this class and how should I use it?
Feel free to give even partial answers to my questions, as there is a lot to talk about, here!
Thanks,
Olivier Renaud
Olivier Renaud
_______________________________________________ Qt-creator mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/qt-creator
