[QBS] Referencing Rule properties

Dennis Tomas den.t at gmx.de
Wed Aug 10 15:05:39 CEST 2016


Am Mon, 8 Aug 2016 11:37:10 +0200
schrieb Christian Kandeler <christian.kandeler at qt.io>:

> On 08/05/2016 06:45 PM, Dennis Tomas wrote:
> > I've hacked Qbs to make the rule available to the output artifact
> > and the prepare function:
> > https://github.com/dtomas/qbs/commit/716cc901b124903866a3ba1370e1085804342d8d
> >
> > What do you think of it?
> 
> I'm not sure. The evaluation depends on whether we think of multiplex 
> rules whose output artifact has a fixed name, but is not a product 
> target artifact, as exotic or not.
Passing a file name is one use case for parametrizing a rule, but there
might be others, such as passing different command line flags etc.

> You might want to file a
> suggestion in JIRA about making user-provided rule properties
> available at rule execution time.
Done: https://bugreports.qt.io/browse/QBS-1003

> Meanwhile, here's another idea for your concrete use case: Let the 
> product provide a mapping between file tags and output file names:
> 
> Product {
>      property var tagMap: ({ qm: "translations", assets: "assets", /* 
> ... */})
>      // ...
> }
> 
> Rule {
>      Artifact {
>          filePath: product.tagMap[Object.keys(inputs)[0]] + ".qrc"
>          fileTags: "qrc"
>      }
>      // ...
> }
> 
> Ths should be exactly what you want, I think.
> 
Thank you. It feels somewhat dirty, but seems to work.
Another approach I've tried, but which hasn't worked, was putting the
rule into a module named "qrc":

Product {
    Group {
        fileTags: "qm"
        qrc.inputs: "qm"
        qrc.baseName: "translations"
    }
    Group {
        files: "assets/**"
        fileTags: "asset"
        qrc.inputs: "asset"
        qrc.baseName: "assets"
    }
    Depends { name: "qrc" }
[...]
}

I thought that module properties could be overridden per Group like
that (like qbs.installDir), but it seems I'm wrong here. When trying to
access them in the output Artifact of the module's rule (using
product.moduleProperty()) they are always undefined. Or is this a
similar problem as with the Rule properties?

Regards,
Dennis




More information about the Qbs mailing list