[Qbs] How to use 'qbs' in a JavaScript function?
Christian Kandeler
christian.kandeler at qt.io
Tue Sep 5 18:06:15 CEST 2023
On 9/5/23 12:08, Jochen Becher wrote:
> until qbs 1.9 the following works:
Not on purpose, though.
Quite a number of things "worked" that shouldn't have, as there was a
lot of scope pollution.
> import qbs 1.0
> import import 'utils.js' as Utils
> Probe {
> id: workspaceRootDetector
> property path rootDir
> configure: {
> rootDir = Utils.detectWorkspaceRoot(qbs)
> }
> }
>
> Since qbs 2.0.2 (from QtCreator 10.0.2), I get the following error
> message from calling Utils.detectWorkspaceRoot:
>
> 'qbs' is not defined
>
> 'qbs' is used within Utils.detectWorkspaceRoot to access some
> properties from qbs, e.g.,
>
> return qbs.targetOS.contains("windows") ? "D:/projects" : "/projects"
>
> How can I achieve the same with qbs 2.0.2?
Store the data you are interested in as input properties:
Probe {
id: workspaceRootDetector
// Inputs:
property stringList targetOS: qbs.targetOS
// ...
// Outputs:
property path rootDir
configure: {
rootDir = Utils.detectWorkspaceRoot(targetOS/*, ...*/)
}
}
Christian
More information about the Qbs
mailing list