How can QSL build a rule to use a product

I want to use Qbs to compile an existing project. This project already contains a code conversion tool (my_tool) that is heavily used in this project.

So far I (simplified):

import qbs 1.0 Project { Application { name: "my_tool" files: "my_tool/main.cpp" Depends { name: "cpp" } } Application { name: "my_app" Group { files: 'main.cpp.in' fileTags: ['cpp_in'] } Depends { name: "cpp" } Rule { inputs: ["cpp_in"] Artifact { fileName: input.baseName fileTags: "cpp" } prepare: { var mytool = /* Reference to my_tool */; var cmd = new Command(mytool, input.fileName, output.fileName); cmd.description = "Generate\t" + input.baseName; cmd.highlight = "codegen"; return cmd; } } } } 

How can I get a link to my_tool for a command?

+4
source share
2 answers

This answer is based on a letter from Qbs author JΓΆrg Bornemann, who allowed me to bring it here.

The usings rule property allows you to add artifacts from product dependencies on input data. In this case, we are interested in application artifacts.

After that, the list of applications can be obtained as input.application .

 Application { name: "my_app" Group { files: 'main.cpp.in' fileTags: ['cpp_in'] } Depends { name: "cpp" } // we need this dependency to make sure that my_tool exists before building my_app Depends { name: "my_tool" } Rule { inputs: ["cpp_in"] usings: ["application"] // dependent "application" products appear in inputs Artifact { fileName: input.completeBaseName fileTags: "cpp" } prepare: { // inputs["application"] is a list of "application" products var mytool = inputs["application"][0].fileName; var cmd = new Command(mytool, [inputs["cpp_in"][0].fileName, output.fileName]); cmd.description = "Generate\t" + input.baseName; cmd.highlight = "codegen"; return cmd; } } } 
+7
source

Unfortunately, the usings property in Rule deprecated since QBS 1.5.0. At the moment I have the same requirement. Using a product artifact in non - Rule multiplexing.

The problem with the Rule multiplex is that if one file in the input set changes, all input artifacts will be processed. This is quite a lot of time in my case.

0
source

Source: https://habr.com/ru/post/1486869/


All Articles