Home · Overviews · Reference · Classes |
Each rule that is examined, ultimately ends up in one of three states: Succeeded, Failed, or NothingToDo.
Rules are examined in three stages: Priming, Testing and Executing. During priming, the following steps occur:
If evaluating or invoking fails, the rule fails immediately. If an expanded prerequisite that is not marked as optional cannot be found, the rule fails immediately.
If evaluating or invoking fails, the rule fails immediately.
A freshen rule is one that has the input file as one of its output files. If a freshen rule is found, it is added as a prerequisite of the current rule. If a freshen rule cannot be found and the input file does not already exist, the rule fails immediately. If a freshen rule cannot be found and the input file already exists, the rule processing continues.
Following priming, further processing of the rule is queued until all of the prerequisite rules have completed. Once this has occured, the rule enters the testing stage. The testing stage determines whether this rule has to execute its commands.
If they exist, test functions always override the rest of the test stage steps.
Once testing is complete, the rule begins executing.
Any prerequisite not marked as hidden is set to Succeeded. Any command non marked as hidden was run.
Rule properties, such as input files, prerequisite actions and the like, are simple string lists. To pass more information about each, such as when a prerequisite is optional, modifiers are used. Modifiers are included at the start of the appropriate string by enclosing them in an "#(...)" identifier. For example, when used as an input file property,
#(fo)$$MY_FILES
will evaluate $$MY_FILES and set each returned file as an optional input file. The complete list of modifiers and their meaning in each context is outlined below.
Applies to | Modifier | Effect |
---|---|---|
Input Files (recursive) | f | Evaluate string. The returned list<string> is treated as additional input files. |
n | If freshening of this file fails, the rule doesn't necessarily fail. | |
v | Do not evaluate string (default). | |
o | Optional. If the input file does not exist and a rule cannot be found to freshen it, the rule will run. However, if a rule can be found and freshening fails the rule will still value (assuming n isn't on). | |
s | Combime with o to trigger the rule if the file does not exist. Useful for rules that change their input files after they run (eg. .d files). | |
Commands | f | Evaluate string. The returned list<string> is joined with " "'s and treated as a single command (default). |
e | Do not echo the command before running it. | |
E | Only echo the command if there is output from it. | |
h | Run the command, but this command is not counted towards the rules ran commands count. | |
n | If this command fails, the rule doesn't necessarily fail. | |
v | Do not evaluate the string. | |
t | Run the command in a virtual TTy. This allows programs to output in color (isatty() returns true instead of false). | |
s | Cancel the rest of the commands if this command fails. | |
Tests | f | Evaluate string (default). The test fails if the returned string is empty or is equal to false. The test passes in all other cases. Note that shell commands cannot be run. |
Prerequisite actions (recursive) | f | Evaluate string. The returned list<string> is treated as additional prerequisites. |
h | Run the prerequisite, but don't use the prerequisite running as reason to run this rule. | |
n | If the prerequisite fails, the rule doesn't necessarily fail. | |
v | Do not evaluate the string (default). | |
o | Optional. If the rule cannot be found, the rule will continue processing. However, if a rule can be found, and running the rule fails, the rule will still fail (assuming n isn't on). | |
c | Call the function, passing the rule name as an argument. The returned list<string> is treated as additional prerequisite actions. |
The rule name. This name will appear in the actions list in the cases where the rule has help, and is the name that other rules use to refer to the rule. The name is set when a rule is requested through the Project::rule() method.
The help description associated with this rule. Rules with help are displayed to the user when they run "qbuild -actions". Internal rules need not (and should not) have help associated with them.
List of files that form the input files for this rule.
List of files this rule generates.
List of prerequite rules for this rule. This list of rules will complete before this rule executes.
List of commands to be executed by this rule.
Tests to determine if this rule should be executed.
List of properties associated with this rule for use in the commands evaluation.
Set to true if the prerequisite actions of this rule should be executed sequentially. This should generally not be needed, and defaults to false.
This is used to group rules that use the same utilities. The user can define throttling to ensure that their system does not become bogged down due to excessive processes being run.
For example, with teambuilder, compiling code is relatively cheap but linking remains expensive so while it might be fine to have 50 compile jobs running at the same time it is probably not acceptable to have 40 linker jobs running.
This property is a list. The first value is what the GUI will display. Additional values are used for throttling matching but are not displayed in the GUI.
A basic compiler category might look like this.
rule.category = "Compiler";
To allow throttling of the host (native) and target (cross) compilers independantly the following might be used instead.
rule.category = ["Compiler", "Host Compiler"]; rule.category = ["Compiler", "Target Compiler"];
Note that a rule will be matched on any value. If you have a throttle limit of Compiler:5 and Host Compiler:3 and you have 5 target compiler instances running no new host compiler jobs will be run.
Used as a quick way to set multiple rule properties. Assigning a property map to the set property causes just the mapped properties to be set in the rule. For example, to set the inputFiles and help properties of a rule "example_rule" one might:
project.rule("example_rule").set = { inputFiles: ["inputFile1.txt", "inputFile2.txt"], help: "This is an example rule" };
If the example_rule already existed, its other properties would be left untouched.
See also Javascript Binding.
Copyright © 2009 Trolltech | Qt Extended - QBuild Maintainer Guide |