Your problem is not mainly the output file path, but that you need to create 
the mapping first, because qbs cannot know about it.
As for the concrete solution, the first thing to understand is that you need to 
create a multiplex rule:
Rule {
    multiplex: true

This is because otherwise, the rule would be invoked per input artifact, but 
you need to see several inputs at once.

Then, derive the output file paths:

    outputArtifacts: {
        var list = [];
        // Iterate over one of inputs["a_binary"] or inputs["b_binary"] and 
       // add the tuple { <derived file path>, "c_binary" } to list.
       return list;
    }

Finally, in the prepare script, you create tuples { <input1>, <input2>, 
<output> } of matching artifacts from all the inputs and outputs and create one 
copy command per such tuple.

As you can see, there is a bit of "manual labor" involved, because qbs has no 
information about which two input artifacts belong together.


Christian

________________________________________
From: Denis Shienkov <denis.shien...@gmail.com>
Sent: Wednesday, October 11, 2017 10:38 AM
To: qbs@qt-project.org; Christian Kandeler; Jake Petroules
Subject: Rule with merging of inputs tuples (pairs)

Hi all,

is it possible to do something this?

I have following set of files as inputs:

1) a1.bin, a2.bin, a3.bin, ..., aN.bin
2) b1.bin, b2.bin, b3.bin, ..., bN.bin

I need to do some processing for this files to have on outputs
like:

c1.bin = a1.bin + b1.bin
c2.bin = a2.bin + b2.bin
c3.bin = a3.bin + b3.bin
...
cN.bin = aN.bin + bN.bin

A numbers of input A and B files are equal,
so, a number of output C files should be too equal.

The processing it is an usual 'copy' command, like:

copy /b aN.bin + bN.bin cN.bin

I have created a Rule:

Rule {

        inputs: ["a_binary", "b_binary"]


        Artifact {

            fileTags: ["c_binary"]

            filePath: "c.bin";

        }


        prepare: {

                    // Do something to call the
                    // copy /b aN.bin + bN.bin cN.bin command.

        }

    }

but is is unclear how to define an output artifact's file pach, because it 
should be different
for each input, e.g. should be c1.bin, c2.bin and so on.?

Or, maybe it is better solution, and I'm wrong?

BR,
Denis

_______________________________________________
Qbs mailing list
Qbs@qt-project.org
http://lists.qt-project.org/mailman/listinfo/qbs

Reply via email to