A command is what Qbs executes at build time. It is represented in the language by an object of type
Command, which runs a process, or
Command represents a process that will be invoked at build time. Its constructor arguments are the binary to run and a list of command-line arguments. For instance:
var insaneCommand = new Command("rm", ["-r", "/"]);
The Rule item documentation shows a
Command in context.
Within the source code, the special identifiers
product (giving access to project and product properties, respectively) as well as
outputs are available. As the example shows, arbitrary properties can be set on the command object and then used within the source code. This technique is typically used to forward values from the prepare script to the command. The Rule item documentation shows a
The following properties are available in both
|A message that is displayed when the command is executed.
|A detailed description that is displayed when the command is executed.
|A tag that can be used to influence how the
description is displayed. In principle, the values are arbitrary. The Qbs command-line tool understands the following values and maps them to different colors if the output device is a terminal:
All other values are mapped to the default color.
|Determines which job pool the command will use. An empty string, which is the default, stands for the global job pool. See here and here for more information on job pools.
|A flag that controls whether the
description is printed. Set it to
true for commands that users need not know about.
Note: If this property is
|Time limit for the command execution in seconds. If the command does not finish within the timeout, it is cancelled. In case of a
Command, the process is requested to terminate. If it does not terminate within three seconds, it is killed. A value below or equal to 0 means no timeout.
This property was introduced in Qbs 1.15.
|The list of arguments to invoke the command with. Explicitly setting this property overrides an argument list provided when instantiating the object.
|A list of environment variables that are added to the common build environment. They are provided as a list of strings in the form "varName=value".
|The maximum exit code from the process to interpret as success. Setting this should rarely be necessary, as all well-behaved applications use values other than zero to indicate failure.
|The binary to invoke. Explicitly setting this property overrides a path provided when instantiating the object.
|Names of environment variables that the invoked binary considers. If one of these variables changes in the build environment, the command will be re-run even if the input files are still up to date.
|32000 on Windows, -1 elsewhere
|If this value is greater than zero and less than the length of the full command line, and if
responseFileUsagePrefix is not empty, the contents of the command line are moved to a temporary file, whose path becomes the entire contents of the argument list. The program is then supposed to read the full argument list from that file. This mechanism is mainly useful to work around Windows limitations regarding the maximum length of the command line and will only work with programs that explicitly support it.
|Index of the first argument to include in the response file. For example this may be used in conjunction with a compiler wrapper where the first argument (the path to the compiler) must be included on the raw command line.
|The prefix that informs
program that the rest of the argument is a path to a file containing the actual command line.
|A function that takes as input the command's actual standard error output and returns a string that is presented to the user as the command's standard error output. If it is not set, the output is shown unfiltered.
|A function that takes as input the command's actual standard output and returns a string that is presented to the user as the command's standard output. If it is not set, the output is shown unfiltered.
|The program's working directory.
|Redirects the filtered standard output content to
stdoutFilePath is undefined, the filtered standard output is forwarded to Qbs, possibly to be printed to the console.
|Redirects the filtered standard error output content to
stderrFilePath is undefined, the filtered standard error output is forwarded to Qbs, possibly to be printed to the console.
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.