Special Property Values
Depending on the context, Qbs provides the following special values for use in property bindings and JavaScript code:
base
This value is useful when making use of inheritance. It stands for the value of the respective property in the item one level up in the inheritance chain. For instance:
Product {
Depends { name: "mymodule" }
mymodule.someProperty: ["value1"]
}
MyProduct {
mymodule.someProperty: base.concat(["value2"]) // (1)
}
["value1", "value2"]
exportingProduct
Within an Export item, you can use the exportingProduct
variable to refer to
the product which defines the Export item:
Product {
Export {
Depends { name: "cpp" }
cpp.includePaths: exportingProduct.sourceDirectory
}
}
filePath
This value holds the full file path to the .qbs
file it appears in. This property is
rarely used, but might be useful when debugging:
Product {
property bool dummy: {
console.info("I'm located at " + filePath);
}
}
importingProduct
Within an Export item, you can use the importingProduct
variable to refer to
the product that pulls in the resulting module:
Product {
Export {
Depends { name: "cpp" }
cpp.includePaths: importingProduct.buildDirectory
}
}
module
This value holds the properties of the module that contains the current item:
Module {
property bool enableGroup
property bool enableRule
Group {
condition: enableGroup // (1)
Rule {
condition: module.enableRule // (2)
// ...
}
}
}
- Available without qualification because Module is a direct parent item.
- Shortcut for
product.<module name>.enableRule
original
On the right-hand side of a module property binding, this refers to the value of the property in the module itself (possibly overridden from a profile). Use it to set a module property conditionally:
Module {
property string aProperty: "z"
}
Product {
Depends { name: "mymodule" }
Depends { name: "myothermodule" }
// `y` if myothermodule.anotherProperty is `x`, `z` otherwise:
mymodule.aProperty: myothermodule.anotherProperty === "x" ? "y" : original
}
Note
In all but the most exotic cases, a Properties item is the preferred way to achieve the same result:
Product {
Depends { name: "mymodule" }
Depends { name: "myothermodule" }
Properties {
condition: myothermodule.anotherProperty === "x"
mymodule.aProperty: "y"
}
}
outer
This value is used in nested items, where it refers to the value of the respective property in the surrounding item. It is only valid in Group and Properties items:
Product {
Depends { name: "mymodule" }
mymodule.someProperty: ["value1"]
Group {
name: "special files"
files: ["somefile1", "somefile2"]
mymodule.someProperty: outer.concat(["value"]) // (1)
}
}
["value1", "value2"]
path
This value holds the path to the folder where the .qbs
file is located. Use it to e.g. add
the product's directory to file paths:
Product {
Depends { name: "cpp" }
cpp.includePaths: path
}
product
This value holds the properties of the product that contains the current item or pulls in the current module:
Module {
Rule {
Artifact {
fileTags: product.type
filePath: {
var result = input.fileName;
// module properties are available as well
if (product.qbs.buildVariant === "debug")
result = result + "_debug";
result = result + ".out";
return result;
}
}
}
}
project
This value holds the properties of the project that references the current item or pulls in the current module:
Project {
property bool enableProduct: true
Product {
name: "theProduct"
condition: project.enableProduct
}
}