General Services

These are operations that do not fit into any of the other categories. They are automatically available in any Qbs project file.

Available Operations

getEnv

qbs.getEnv(name)

Tries to find a variable with the given name in the build environment and returns its value. If no such variable could be found, undefined is returned.

getHostOS

qbs.getHostOS(name)

Returns the name of the operating system on which Qbs is running.

Note: Do not confuse this with the qbs.targetOS property, which represents the operating system on which the binaries produced by Qbs will run.

loadFile

var MyFunctions = loadFile("myfunctions.js");
MyFunctions.doSomething();

Loads a JavaScript file and returns an object that contains the evaluated context of this file. This function is only available in JavaScript files.

loadExtension

var FileInfo = loadExtension("qbs.FileInfo");
var fileName = FileInfo.fileName(filePath);

Loads a Qbs extension and returns an object that contains all functions of that extension. This function is only available in JavaScript files.

Extensions to JavaScript Built-in Objects

Array.contains(e)

Returns true if the array contains the element e. Returns false otherwise.

Array.uniqueConcat(other)

Returns a copy of this array joined with the array other. Duplicates that would originate from the concatenation are removed. The order of elements is preserved.

String.contains(s)

Returns true if the string contains the substring s. Returns false otherwise.

String.startsWith(s)

Returns true if the string starts with the substring s. Returns false otherwise.

String.endsWith(s)

Returns true if the string ends with the substring s. Returns false otherwise.