[QBS] How can a QBS Build Rule use a product?

Joerg Bornemann joerg.bornemann at digia.com
Wed Jun 19 18:13:28 CEST 2013

On 19/06/2013 16:29, Johannes.Matokic at microchip.com wrote:

> So far the tests work well. However one project makes heavy use of preprocessing with a tool that is built as a part of the project. So far I haven't found a way to achieve this in QBS.

It's already possible. I've attached a full example.
The project file now looks like this:

     Application {
         name: "my_tool"
         files: "my_tool.cpp"
         Depends { name: "cpp" }

     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;



Joerg Bornemann
Digia, Qt

-------------- next part --------------
A non-text attachment was scrubbed...
Name: tooldep.zip
Type: application/x-zip-compressed
Size: 940 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/qbs/attachments/20130619/c85af0d8/attachment.bin>

More information about the Qbs mailing list