[Qbs] Multiple "favored" binaries from one product
Christian Kandeler
christian.kandeler at qt.io
Mon May 8 09:55:32 CEST 2017
[Re-routing to mailing list]
On 05/06/2017 01:14 PM, Thomas Ballenthin wrote:
>>> As I understand, each product outputs a single file. What is the most convenient way to produce two binaries with different compiler switches from the same source files?
>>
>> At the moment, the only way to really multiplex on the product level is
>> using (external) profiles. See the "profiles" entry in
>> https://doc.qt.io/qbs/product-item.html. As far as I can tell, this
>> would more or less map to the "flavor" thing if the profile contents
>> could be specified in-place, correct?
>
> Profiles seem like a workaround, but as I understand it, I have to
> execute be qbs file once with every profile... If this is the case, I
> also could just use variables to do the job.
I don't understand what you mean by "execute the qbs file once with
every profile". Could you clarify? qbs is invoked exactly once.
>>> I would like to reduce code duplication and not specify several CppApplications per unit test. Is there a way to have a "product factory", or rules that process groups of files and output binaries.
>> A less general way that might be sufficient for your needs would be to
>> move most of the product specification into a base item and instantiate
>> it twice:
>> // In TestX.qbs
>> CppApplication {
>> // Depends { // ... }
>> // files: [ ... ]
>> // etc
>> }
>>
>> // In your project file
>> Project {
>> TestX {
>> name: "testx1"
>> cpp.defines: ["VARIANT1"]
>> }
>> TestX {
>> name: "testx2"
>> cpp.defines: ["VARIANT2"]
>> }
>> }
>>
> I haven't tried this yet... If TestX.qbs can contain several CPP
> Applikations, then it would be very close to what I'm looking for.
If you want that, then the top-level item in there needs to be a
Project, which means the instantiations will look different from the
example above. The details depend on what exactly you want to do there.
Christian
More information about the Qbs
mailing list