[QBS] Just a few questions

Christian Kandeler christian.kandeler at digia.com
Tue May 27 09:20:14 CEST 2014


On 05/26/2014 07:10 PM, Kevin Chaves wrote:
> I thought I read something about qbs being able to use inheritance but
> I’m not sure if this is true. And I’m a little confused over the
> difference between Project { references: } and Project { SubProject {}
> }.

"references" is a shorter way of saying "Subproject", but without the 
ability to attach properties, for instance. See the documentation at
http://qt-project.org/doc/qbs-1.2/subproject-item.html.


> I tried using function commonCxxFlags {} at the top level directory but
> that didn't seem to be inherited by the subprojects.
>
> ---HelloWorldProject.qbs---
> Project{
>    function commonCxxFlags{
>      var flags = “-std=c++0x”
>      return flags
>    }

Does this even parse? I strongly suggest you use a property for that:
     property stringList commonCxxFlags: ["-std=c++0x"]

>    SubProject {
>      filePath: “HelloLib/HelloLib.qbs”
>    }
>    SubProject {
>      filePath: “HelloApp/HelloApp.qbs”
>    }

You could use "references" here, as you do not do anything special with 
the sub-projects.

> }
>
> ---HelloLib/HelloLib.qbs---
> StaticLibrary {
>    name: “HelloLib”
>    files: [“*.cpp”,  “*.h”]
>    Depends { name: “cpp” }
>    cpp.cxxFlags = commonCxxFlags

This should say "project.commonCxxFlags", as you are not directly under 
a Project item, but a Product item (of which StaticLibrary is a 
subtype). The magic property "project" is available in most contexts to 
refer to the next Project item (travelling up the item hierarchy).

> It looks like I might be able to do something like this in 1.3 where
> sourceDirectory can be used with… moduleSearchPath I think it was.

No idea what sourceDirectory has to do with this.

> Also
> is it possible to get the qmake and gcc being used to build a .pro
> project? We use external libraries as part of the build and they only
> support .pro for now. Converting them to qbs probably won’t be too
> difficult but if i don’t have to that would be nice.

I guess you could achieve something like that with a custom Rule or 
Transformer, but you should be aware that that part of the build will be 
opaque to qbs, so a bit of time will be wasted calling qmake/make when 
building incrementally as qbs won't be able to tell whether that is 
actually necessary.


Christian



More information about the Qbs mailing list