[QBS] ist it possible to have conditional artifacts?

Kurt Keller kk at parity-software.com
Mon Oct 14 17:43:34 CEST 2013


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?

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")
      fileTags: ['c']
      fileName: input.baseName + '_clnt.c'
    }

    Artifact {
      condition: product.moduleProperty(product.moduleName,"generateSVC")
      fileTags: ['c']
      fileName: input.baseName + '_svc.c'
    }
    ...

  }  
}

Thank you for any help.
-- 
Kurt Keller



More information about the Qbs mailing list