[QBS] Dependency to Transformer Artifact

Christian Kandeler christian.kandeler at theqtcompany.com
Mon Jul 20 10:31:39 CEST 2015

On 07/19/2015 12:06 PM, Stephan Gatzka wrote:
> I wrote a small qbs module to generate version information from an
> version input file. So I have a Module consisting of a Transformer which
> has an Artifact item with fileTags: ["version"].
> The version.h file is correctly generated but the c file including
> version.h is not rebuild.

I cannot reproduce that. I've changed the product version, and both 
version.h and main.c were regenerated. What exactly did you try?
(But see below for some other possible improvements in your module.)

> Module {
>    Transformer {

I'd suggest using a Rule instead of a Transformer here. Working on input 
tags instead of hardcoded files gives you more flexibility. In general, 
Rules are preferable whenever inputs exist.

>      inputs: "version.h.in"
>      Artifact {
>        filePath: "version.h"
>        fileTags: ["version"]

The tag should be "hpp".

>      }
>      prepare: {
>        var cmd = new JavaScriptCommand();
>        cmd.description = "Processing '" + input.fileName + "'";
>        cmd.highlight = "codegen";
>        cmd.sourceCode = function()  {
>          var file = new TextFile(input.fileName);

You should use input.filePath here. input.fileName is really just the 
name of the file, which is not what you want.

>          var content = file.readAll();
>          file.close()
>          content = content.replace(/##VERSION_STR##/g, product.version);
>          file = new TextFile(output.fileName,  TextFile.WriteOnly);

output.filePath, as above.


More information about the Qbs mailing list