[QBS] build configuration (apologies for accidental premature post!)

William Gallafent william at gallaf.net
Tue Oct 16 15:34:21 CEST 2012


Hi,

This may well be possible already, but I've failed to work out how
from the existing documentation! I've looked at qbs.buildVariant
route, which seems to be hardwired to debug and release when read by
the cpp module, so it's not possible for me simply to add new
buildVariant values and act on them.

I'm trying to work out how to allow for arbitrary different variants
of the build of a project. In this example, the project can be
configured to call certain services locally (by launching an
executable) or remotely using https. The behaviour is controlled at
build time by a C++ preprocessor macro used when building all products
(but might also change e.g. the system libraries which are linked, and
so on).

I would like to be able to say, for example,

$ qbs debug myproj.call=https

And for the result to be a debug build which has the appropriate
macros and other parameters set for https, or

$ qbs release myproj.call=local

… for a build with qbs.buildVariant=release and different values for
the cpp macros etc.

Then somewhere in one of my qbs files (in my heirarchy which starts
with a Product) I would have

Properties {
  condition: myproj.call === "https"
  cpp. defines: outer.concat (["MYPROJ_CALL_HTTPS"])
}

I hoped to achieve this by using a Module, but I have not yet worked
out how to do that! For example, if I declare in myprojmod.qbs:

Module {
  name: "myprojmod"
  property string call: "https"
}

Then from a product's qbs file:

import "myprojmod.qbs" as mpm

………

  Properties {
    condition: mpm.call === "https"
    cpp. defines: outer. concat (["MYPROJ_CALL_HTTPS"])
  }

… qbs reports “Error: Undefined property 'mpm'”, likewise if I try
referencing modules.mpm.call I get “Error: Property modules
property.mpm is undefined.”, and the same if I try modules.myprojmod.

So the key question here is: How do I import and get access to my own
modules, and how do I set their properties on the command line?

In addition, I would like the builds made with different values of
this property to be built in different build directories, e.g.:

build/qt-macports-debug/call-https/
build/qt-macports-debug/call-local/

Is there a correct way to do this? If so, where is it documented?

--
Bill Gallafent.



More information about the Qbs mailing list