[Qbs] Qbs Rule for a tool like syncqt.pl

Christian Kandeler Christian.Kandeler at qt.io
Mon Jan 21 11:55:52 CET 2019


On Mon, 21 Jan 2019 08:45:30 +0100
Christian Gudrian <christian.gudrian at aucos.de> wrote:

> I'm struggling with writing a Rule for a tool like Qt's syncqt.pl script 
> which automatically generates a set of API headers from the source code 
> with the source itself already referencing these generated headers (that 
> basically implies that the Rule needs to execute before compilation 
> starts).
> 
> The naïve attempt would be to write Rule that consumes files tagged 
> "hpp" and outputs files tagged "hpp". For obvious reasons that's not 
> going to work.
> 
> So instead of outputting files tagged "hpp" I tried to output files 
> tagged "api_hpp". But with no other Rule consuming files tagged 
> "api_hpp" this Rule did not execute. (Can I declare additional input 
> dependencies for the compilation step?)

No. The outputs of your rule need to have the hpp tag.

> The next attempt was to consume files tagged "src_hpp" and output files 
> tagged "hpp". That implies that one has to put all header files in a 
> special group to override the built-in "hpp" tag which is kind of hacky. 

Actually, it does not: You could also provide your own file tagger and set a priority, overriding the one from the cpp module.

> Furthermore with the "real" header files now tagged "src_hpp" instead of 
> "hpp" QtCreator's code model seemed to get confused, as some of the 
> header files did not belong to any project anymore.

But technically, they aren't the "real" headers, since they are not what you include.

> Is there a clean Qbs way? How has this problem been addressed in the 
> days when Qbs was supposed to be the Next Build Tool for Qt?

For Qt, we've collected the headers in extra products. That was necessary because there were products that had a dependency on the installed headers of some product, but could not have a dependency on the product itself.


Christian


More information about the Qbs mailing list