[QBS] Execute dependent rule

Christian Kandeler christian.kandeler at theqtcompany.com
Thu Jul 23 17:25:51 CEST 2015


On 07/23/2015 04:59 PM, Waldschmidt, Stefan wrote:
> I am struggling for a while trying to trigger a Rule on completion of an
> Application.
> In any way I tried it, the Rule is never executed.
> Here is a small example, which do not work for me, because the Rule is
> never executed.
>
> import qbs 1.0
> import qbs.File
> import qbs.FileInfo
>
> Project {
>      name: "mainproject"
>      minimumQbsVersion: "1.4.0"
>
>
>      Product {
>          name: "helloworld"
>          type: "application"
>          files: "main.c"
>          Depends { name: "cpp" }
>      }
>
>      Product {
>          name: "copy"
>          type: ["custom-image"]
>          Depends { name:"helloworld" }
>
>          Rule {
>              multiplex: true
>              inputsFromDependencies: ["application"]
>
>              prepare: {
>                  var cmds = [];
>
>                  var cmd = new JavaScriptCommand();
>                  cmd.description = "deploy " + input.filePath;
>                  cmd.highlight = "codegen";
>                  cmd.sourceCode = function() {
>                      File.copy(input.filePath, "/tmp/helloworld");
>                  }
>                  cmds.push(cmd);
>                  return cmds;
>              }
>          }
>      }
> }
>
> Probably I am making a noob's mistake. I would be very glad for any hint.

Your rule is missing an output artifact. There always needs to be a 
chain of file tags leading to your product type. In your case, this 
should do the trick:
     Artifact {
         filePath: "/tmp/helloworld"
         fileTags: ["custom-image"]
     }
And then use output.filePath in the command's source code.


Christian



More information about the Qbs mailing list