Discussion:
[Qt-creator] Clang Model plugin interface
Antonio Di Monaco
2017-12-15 16:11:04 UTC
Permalink
Hi,

I'm writing a Qt Creator plugin to support our own custom build process.

My issue is that I cannot find a way to interact with the Clang Code Model plugin, in order to pass to it specific compile options (in my case, it's --gcc-toolchain).

In detail, my plugin automates the kit creation, in order to find out the custom compiler, debugger, and all other stuff we need to build, including our build tool. I'm populating the CppTools::RawProjectsParts data structure according
to the specific toolchain that has been selected by the user (that could be a Clang, GCC or MSVC compiler), and everything works fine, as long as I work with the built-in C++ Code Model.

When I activate the Clang Code Model and GCC profile is activated, as the same CppTools::RawProjectsParts data is accessed (is it true or did I miss something?), I encounter a failure, cause if I add the "--gcc-toolchain" parameter, Clang model works, but the built-in fails. And if not, of course the opposite happens, and I'd like to have both running.

I'd like just to interact with the Clang Code Model at "run-time" and, behind the scene, add my mandatory options to it, without asking the user for a UI settings change (also cause the path passed to the "gcc-toolchain" parameter changes according to the profile selected by the user).

My question is: is there an interface, or anything similar, that I can use in order to add such parameters to clang model only? I could also change the Qt Creator code, but I'd like to go for the clean way, if there's any.

Thanks for your help!
A. 
Bryan Bennetts
2017-12-15 16:26:16 UTC
Permalink
Hi Antonio,

FWIW I raised QTCREATORBUG-18402
<https://bugreports.qt.io/browse/QTCREATORBUG-18402> which *might* address
your needs, if implemented - I have yet to even think about how it'd be
done though.

Cheers, Bryan.
Post by Antonio Di Monaco
Hi,
I'm writing a Qt Creator plugin to support our own custom build process.
My issue is that I cannot find a way to interact with the Clang Code Model
plugin, in order to pass to it specific compile options (in my case, it's
--gcc-toolchain).
In detail, my plugin automates the kit creation, in order to find out the
custom compiler, debugger, and all other stuff we need to build, including
our build tool. I'm populating the CppTools::RawProjectsParts data
structure according
to the specific toolchain that has been selected by the user (that could
be a Clang, GCC or MSVC compiler), and everything works fine, as long as I
work with the built-in C++ Code Model.
When I activate the Clang Code Model and GCC profile is activated, as the
same CppTools::RawProjectsParts data is accessed (is it true or did I miss
something?), I encounter a failure, cause if I add the "--gcc-toolchain"
parameter, Clang model works, but the built-in fails. And if not, of course
the opposite happens, and I'd like to have both running.
I'd like just to interact with the Clang Code Model at "run-time" and,
behind the scene, add my mandatory options to it, without asking the user
for a UI settings change (also cause the path passed to the "gcc-toolchain"
parameter changes according to the profile selected by the user).
My question is: is there an interface, or anything similar, that I can use
in order to add such parameters to clang model only? I could also change
the Qt Creator code, but I'd like to go for the clean way, if there's any.
Thanks for your help!
A.
_______________________________________________
Qt-creator mailing list
http://lists.qt-project.org/mailman/listinfo/qt-creator
Antonio Di Monaco
2017-12-15 18:19:10 UTC
Permalink
Hi Bryan,

yes, that could be a start, even if I cannot use the JSON compile database.

What I'd like to have is just an interface class for clang parameters, that I can subclass and register in the Clang Model, in order to pass such options dynamically.

Maybe the bug proves that I did not miss anything, and indeed there's no support for that yet. As I have to work on it in any case, cause it's a showstopper for me, I'll do my change proposal, when it's completed.

Thanks,

BR,
A.



⁣Sent from BlueMail ​


-------- Original Message --------
From: Bryan Bennetts <***@gmail.com>
Sent: Fri Dec 15 17:26:16 GMT+01:00 2017
To: Antonio Di Monaco <***@becrux.com>
Cc: qt-***@qt-project.org
Subject: Re: [Qt-creator] Clang Model plugin interface

Hi Antonio,

FWIW I raised QTCREATORBUG-18402
<https://bugreports.qt.io/browse/QTCREATORBUG-18402> which *might* address
your needs, if implemented - I have yet to even think about how it'd be
done though.

Cheers, Bryan.
Post by Antonio Di Monaco
Hi,
I'm writing a Qt Creator plugin to support our own custom build process.
My issue is that I cannot find a way to interact with the Clang Code Model
plugin, in order to pass to it specific compile options (in my case, it's
--gcc-toolchain).
In detail, my plugin automates the kit creation, in order to find out the
custom compiler, debugger, and all other stuff we need to build, including
our build tool. I'm populating the CppTools::RawProjectsParts data
structure according
to the specific toolchain that has been selected by the user (that could
be a Clang, GCC or MSVC compiler), and everything works fine, as long as I
work with the built-in C++ Code Model.
When I activate the Clang Code Model and GCC profile is activated, as the
same CppTools::RawProjectsParts data is accessed (is it true or did I miss
something?), I encounter a failure, cause if I add the "--gcc-toolchain"
parameter, Clang model works, but the built-in fails. And if not, of course
the opposite happens, and I'd like to have both running.
I'd like just to interact with the Clang Code Model at "run-time" and,
behind the scene, add my mandatory options to it, without asking the user
for a UI settings change (also cause the path passed to the "gcc-toolchain"
parameter changes according to the profile selected by the user).
My question is: is there an interface, or anything similar, that I can use
in order to add such parameters to clang model only? I could also change
the Qt Creator code, but I'd like to go for the clean way, if there's any.
Thanks for your help!
A.
_______________________________________________
Qt-creator mailing list
http://lists.qt-project.org/mailman/listinfo/qt-creator
Nikolai Kosjar
2018-01-02 09:16:28 UTC
Permalink
Post by Antonio Di Monaco
Hi,
I'm writing a Qt Creator plugin to support our own custom build process.
My issue is that I cannot find a way to interact with the Clang Code
Model plugin, in order to pass to it specific compile options (in my
case, it's --gcc-toolchain).
In detail, my plugin automates the kit creation, in order to find out
the custom compiler, debugger, and all other stuff we need to build,
including our build tool. I'm populating the CppTools::RawProjectsParts
data structure according
to the specific toolchain that has been selected by the user (that could
be a Clang, GCC or MSVC compiler), and everything works fine, as long as
I work with the built-in C++ Code Model.
When I activate the Clang Code Model and GCC profile is activated, as
the same CppTools::RawProjectsParts data is accessed (is it true or did
I miss something?), I encounter a failure, cause if I add the
"--gcc-toolchain" parameter, Clang model works, but the built-in fails.
And if not, of course the opposite happens, and I'd like to have both
running.
I'd like just to interact with the Clang Code Model at "run-time" and,
behind the scene, add my mandatory options to it, without asking the
user for a UI settings change (also cause the path passed to the
"gcc-toolchain" parameter changes according to the profile selected by
the user).
My question is: is there an interface, or anything similar, that I can
use in order to add such parameters to clang model only? I could also
change the Qt Creator code, but I'd like to go for the clean way, if
there's any.
Thanks for your help!
A.
Hi!

There is no interface for this right now. All the information for the
libclang command line come from the RawProjectsParts and the diagnostic
options the user has configured. Currently, no concrete options are
forwardable directly with RawProjectsPart because libclang might now
understand them, depending on your toolchain....

There is CppModelManager::updateCompilerCallDataForProject(), which
basically allows to set a command line, but it's used for the clang
static analyzer plugin (not the clang code model) and the qbs project
only so far.

I suggest that you modify the Qt Creator code to suit your needs and
then push it for review.

Nikolai

Loading...