[QBS] Get property from parent project

Tim Hutt tdhutt at gmail.com
Fri May 23 11:05:35 CEST 2014


Ah it seems to work now, weird. I may have typo'd "project" instead of
"product". Also, good news! I have found a reliable way to trigger the
qbs-isn't-updated bug:

1. Create a new C++ QBS project in QtCreator.
2. Rename main.cpp to foo.txt
3. Paste this in the QBS file:

import qbs

Product {
 type: "foo"
 Group {
 files: "foo.txt"
 fileTags: "foo-source"
 }
 property string foo: "baz"
 Rule {
 inputs: "foo-source"
 Artifact {
 fileName: "foo.out"
 fileTags: "foo"
 }
 prepare: {
 foobar;
 var a = product.foo;
 var cmd = new JavaScriptCommand();
 cmd.silent = true;
 cmd.a = a;
 cmd.sourceCode = function() { console.log(a); }
 return cmd;
 }
 }
}

4. Try and build it, it will say foobar not found (or whatever).
5. Change foobar to foobar2, but DON'T SAVE THE QBS FILE!
6. Now right-click on the project in the project pane and select rebuilt.
7. Lo! It still says 'foobar not found', not foobar2.
8. Now change it to foobar3, and this time save the QBS file before
building.
9. Rebuild. It will still say 'foobar not found'.

Perhaps some kind of race condition between QtCreator saving the file for a
rebuild (because I have the "save all files before building" option
enabled) and QBS checking the timestamps (or whatever it does).

Cheers,

Tim


On 23 May 2014 08:28, Christian Kandeler <christian.kandeler at digia.com>wrote:

> On 05/22/2014 06:07 PM, Tim Hutt wrote:
> > Product {
> >     property string foo: "baz"
> >     Rule {
> >        prepare: {
> >            var a = product.foo;
> >
>
> Sure it does. We use that all the time. Try again ;)
> Here is a full example that I just tested:
>
> $ cat > project.qbs
> import qbs
>
> Product {
>      type: "foo"
>      Group {
>          files: "foo.txt"
>          fileTags: "foo-source"
>      }
>      property string foo: "baz"
>      Rule {
>          inputs: "foo-source"
>          Artifact {
>              fileName: "foo.out"
>              fileTags: "foo"
>          }
>          prepare: {
>              var a = product.foo;
>              var cmd = new JavaScriptCommand();
>              cmd.silent = true;
>              cmd.a = a;
>              cmd.sourceCode = function() { print(a); }
>              return cmd;
>          }
>      }
> }
> $ qbs -q
> baz
> $
>
>
> Christian
> _______________________________________________
> QBS mailing list
> QBS at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qbs
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qbs/attachments/20140523/eb5fc6b6/attachment.html>


More information about the Qbs mailing list