[QBS] Building Qt with QBS

Andrew Knight qt at panimo.net
Tue Mar 31 02:17:59 CEST 2015


tl;dr: For those experimental types looking for a good time, give the 
repo at https://github.com/intopalo/qt5-qbs a spin to try building 
[quite a bit of] Qt using QBS.

For the past few months, I've been tinkering with using QBS to build the 
Qt libs we use in our projects. Given that the current focus is embedded 
Linux (and the expected "slimming down" of Qt which comes with the 
territory), that is the most likely platform to be working at any given 
moment. However, I've been testing a bit on Windows as well, and do plan 
to hit the other platforms in time. Certainly, this is still early days 
with few modules/plugins yet ported, but it's a start.

The reason I'm posting is to just make it known that we (meaning my 
colleagues and I) are actively working on this, and it would be good to 
get a discussion going about how things might be changed now, before 
it's too late and we have a steaming pile of code that nobody (myself 
included) is interested in.

So, here's a description of how things work, including some notes on how 
I see them evolving:

- The repository itself is just a collection of QBS files (and maybe a 
few JS files as well as some pre-built artifacts I haven't bothered 
writing rules for yet). That means it is designed to work with a 
separate checkout (or even tarballs) of Qt sources (e.g. qt5.git). I 
would also like to see it not tied to any particular Qt version, but to 
support a range of Qt releases to allow quick switching between Qt 
sources (read: branching of the repo is not tightly tied to the Qt version).

- There are two "prerequisite" steps to building Qt modules: (1) build 
the host tools (using the host's profile) and (2) create a configuration 
file with all the various switches. Host tools can be reused for every 
target profile you decide to build the framework for. The configuration 
file (let's call it qtconfig.json) is basically a portable configure 
command line. It can be generated by a separate QBS project (which may 
or may not be any good at auto-detecting a useful set of configuration 
flags) and edited by hand.

These might eventually be logically combined into the same step (sort of 
like how qtbase's configure works today, creating both a configuration 
and building qmake), but I'm not sure how useful that is.
It would at least be cool, to see this step also install the Qt module 
configurations into a new QBS profile (perhaps as a replacement to 
qbs-setup-qt, see [0]), as that might allow reusing more of QBS's 
existing Qt module support.

- Qt is then built for the target profile using the host tools (i.e. 
moc, rcc, uic) in your PATH (or those set by qtchooser) and the 
configuration file you gave. If all goes well, you end up with a build 
that works with qbs-setup-qt. Oh yeah, qmake isn't even built with this 
setup, but a stand-in binary called qhost pacifies the need for querying 
qmake variables.

- Currently, only the top-level project (qt.qbs) can be used to build 
modules, but I would be interested in shifting over to using QBS's 
built-in Qt module support (by invoking qbs-setup-qt early and building 
with that profile, as noted above). That would allow us to open module 
projects independently and build them against the installed Qt version.

- QBS 1.4 is required, but you might be able to change a few things and 
get it to work again with 1.3. I moved away from 1.3 recently due to 
some perceived benefits. Check the messy git history for insights.

If you think this looks useful, perhaps it would be worth setting up a 
playground project in Gerrit to make this a more collaborative effort. 
If you think this looks insane, please chime in too. Either way, let's 
continue the discussion.


[0] [QBS] A more general replacement for qbs-setup-xxx utilites - 

Oh, since someone will ask:
time qbs -f qt.qbs --jobs 8 project.sourcePath:$QT_SOURCE profile:clang 

real    8m3.322s
user    60m20.664s
sys     1m27.588s

That's with all projects/options enabled on Linux 3.16 x64 + i7 3770S + 
SSD source + tmpfs build, excluding the host-tools/configure steps. Take 
this with plenty of salt; this builds a (sort of strange) subset of Qt only.

More information about the Qbs mailing list