[QBS] ist it possible to have conditional artifacts?

Kurt Keller kk at parity-software.com
Tue Oct 15 14:58:59 CEST 2013


Am Dienstag, den 15.10.2013
schrieb Christian Kandeler <christian.kandeler at digia.com>:

> On 10/14/2013 05:43 PM, Kurt Keller wrote:
> > rpcgen generates up to three .c source files and a .h header file
> > out of a single .x file. I want to create a module for qbs which
> > conditionally creates only those .c / .h files which are wanted by the
> > product. Is something like this possible?
> 
> This looks very much like 
> https://bugreports.qt-project.org/browse/QBS-370. The tentative plan is 
> to have this working in a generic way in qbs 1.2.
> However, if the maximum number as well as the actual number of outputs 
> are known statically (which seems to be the case here), it could work 
> already.
> 
> > Product {
> >    name: 'myrpcclient'
> >    Depends { name: 'rpcgen' }
> >    rpcgen.generateHDR:  true
> >    rpcgen.generateCLNT: true
> >    rpcgen.generateXDR:  true
> >    rpcgen.generateSVC:  false
> >    files: ['myrpcsrc.x']
> >    ...
> > }
> >
> > Product {
> >    name: 'myrpcserver'
> >    Depends { name: 'rpcgen' }
> >    rpcgen.generateHDR:  true
> >    rpcgen.generateCLNT: false
> >    rpcgen.generateXDR:  true
> >    rpcgen.generateSVC:  true
> >    files: ['myrpcsrc.x']
> >    ...
> > }
> >
> > %< ------ >%
> >
> > Module {
> >    ...
> >    property bool generateHDR:  true
> >    property bool generateXDR:  true
> >    property bool generateCLNT: true
> >    property bool generateSVC:  true
> >
> >    FileTagger {
> >      pattern "*.x"
> >      fileTags: ['rpcsrc']
> >    }
> >
> >    Rule {
> >      inputs: ['rpcsrc']
> >      Artifact {
> >        condition:
> > product.moduleProperty(product.moduleName,"generateCLNT")
> 
> This looks like the right approach. Have you tried it?

Yes now I have tried it. Qbs alway generates all 4 files. No matter, how
the properties generateSVC, generateCLNT, ... are set. When I test the
properties (generateSVC, generateCLNT, ...) inside the Artifact as shown
and test it again inside the Rule { ... } to avoid to create the
correspondent command - no file will be generated, but QBS creates
automatically a compiler call for the non existent file. So I get a
compiler complain about a non existant source file.

It seems, that the 'condition:' statement in the Artifact block does not do
anything. Even when I have 'condition: false' in one of the Artifact
blocks qbs creates the correspondent outputs object. Example:

   Artifact {
      condition: false
      fileTags: ['c','rpc_xdr_c']
      fileName: input.baseName + '_xdr.c'
   }
   ...
   prepare: {
      var commands = [];
      if (outputs.hasOwnProperty('rpc_xdr_c')) {
        print("oops");
        var cmd = new Command('rpcgen',.....)
        commands.push(cmd);
      }
      ....
      return commands;
   }

qbs creates outputs['rpc_xdr_c'] whether there is condition:false or
condition:true inside the Artifact { ... } block.

I found this Artifact / condition stuff in qbs ..../modules/cpp/GenericGCC
and I was wondering, whether I can use it too.

-- 
Kurt Keller



More information about the Qbs mailing list