[QBS] How to generate 2 objects from the same source file

Ch'Gans chgans at gna.org
Fri Jul 29 10:51:54 CEST 2016

On 29 July 2016 at 20:04, Ch'Gans <chgans at gna.org> wrote:
> On 29 July 2016 at 01:20, Christian Kandeler <christian.kandeler at qt.io> wrote:
>> On 07/28/2016 03:07 PM, Ch'Gans wrote:
>>> For testing the clang DB generator[1] I would like to generate 2
>>> objects from the same source file (clang tools should normally check
>>> the same source file twice with the 2 different compile commands).
>>> Is there a simple way to do that?
>>> To keep it simple i would like first.o and second.o to be generated
>>> with different preprocessor flags.
>> You can
>>     - put the files into different products or
>>     - make a copy of the file or
>>     - parameterize the respective properties (e.g. cpp.defines)
>>       and call the generate command twice with different values
>>       for that parameter.
> I think that what I need is different products with different cpp.defines.
> Any way, right now i'm fighting hard to get the test project "loaded".
> My first step is simply to get the generator running, i have several choices:
> - 1 run qbs with a QProcess like TestBlackbox::runQbs()
> - 2 use CommandLineFrontend
> - 3 instantiate Project "manually" like TestApi::doBuildProject()
> But i'm a bit overwhelmed by the amount of boiler plate i have to write!
> Solution 1 seems the less-difficult of all...
> Which profile should i use? How to retrieve the profile that has been
> used for building Qbs itself? Does it even make sense to attempt to
> retrieve it?
> Surely, there is to be a way to get a ready-to-use profile for the
> auto-tests, still searching tho...
> I would highly appreciate if someone could shed some light on how to
> get started.

Actually, I thinnk i found my way, running Qbs with QProcess is not
that difficult in my case, i don't need all the details I saw in
tst_api and tst_buildgraph.
For the profile (my user's config doesn't have a default profile), i'm
simply capturing the profile name in my test's cpp.defines, and re-use
it to call qbs from within the test suite...
It feels like a gross hack tho, this won't work if the user built qbs
with other important command line arguments, like settings-dir, etc...
Anyway, at least i can generate the clang db from within the tests!


> Chris
>> Christian
>> _______________________________________________
>> QBS mailing list
>> QBS at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/qbs

More information about the Qbs mailing list