[Qbs] Order of property evaluation

resurrection at centrum.cz resurrection at centrum.cz
Tue May 8 16:17:10 CEST 2018


I am a bit confused about the order in which the various variables are initialized in Qbs. For example the documentation for variable `product.name` says that it cannot depend on any other property and yet the invalid example:
 
CppApplication {
    name: "app_" + qbs.targetOS.join("_")
    // invalid
}
 
actually works just fine. When trying to use multiplexing however there are no explicit restrictions in the docs but I found out that those variables actually cannot depend on others. When set to for example probe result:
 
CppApplication {
    Probe {
        id: myprobe
        property stringList architectures: []
        configure: {
            architectures = ["x86", "x86_64"]
            found: true
        }
    }
    
    qbs.architectures: myprobe.architectures
}
 
It does not work and the multiplexing is not triggered. No error or warning is given. And that last part somewhat bother me because there is uncertainty as to the order of evaluation of properties and which properties can rely on others. I have already found out that for some properties in a product the order does not matter so this:
 
CppApplication {
    targetName: name + "_"
    name: "MyApp"
}
 
Will produce "MyApp_" as targetName however this:
 
Product {
    cpp.cxxFlags: "-myflag"
    Depends { name: "cpp" }
}
 
Will produce error saying that cpp variable was not declared.
 
It kind of reminds me of what bothered me about qmake. I would personally prefer strict top-down evaluation order. While it could add ability to "re-use" properties or change them during evaluation in different parts of the product it would in my opinion solve a lot of confusion about what is evaluated when and what can be used in what contexts, e.g. probe/properties in multiplexing properties etc.
 
Thanks,
Michael

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qbs/attachments/20180508/265fc42f/attachment.html>


More information about the Qbs mailing list