class Target(Generic[
Constructor: Target(item, *dependencies, state, name, cmd)
Represents a target with an item to create, its dependencies, how to compute its state (hashed content, fingerprint), how to (re-)create it and an optional nice name.
| Method | __init__ |
Creates a new Target. |
| Method | __str__ |
Readable short form for a Target |
| Method | show |
Suggest to tools like toGraphviz not to show a string representation of the item, but instead only use the name. If no explicit name was provided, calling this function is silly, as in that case the name is ... |
| Instance Variable | cmd |
Function to (re-)create the target. |
| Instance Variable | dependencies |
The target's dependencies. |
| Instance Variable | force |
If set to True before the build starts, the target is assumed to be out-of-date, independent of the computed state hash. This can be used to force rebuilding a target. |
| Instance Variable | item |
The item of the target, often a file or directory path. |
| Instance Variable | name |
The target's name, defaulting to str(item). |
| Instance Variable | name |
Setting this to True means that a representation of the item should typically not be shown in output. Currently used only when the dependency graph is drawn. |
| Instance Variable | recreated |
Set during updateTargets if this target was out-of-date and its command was run. |
| Instance Variable | started |
Set during updateTargets as soon as this target is considered for updating. |
| Instance Variable | state |
State generator for the target. |
| Instance Variable | updated |
Set during updateTargets as soon as all dependencies are done. |
T, *dependencies: Target[ Any], state: str | Callable[ [ T], str] | None = None, name: str | None = None, cmd: Callable[ Concatenate[ T, ...], None] | None = None):
¶
Creates a new Target.
An "input target", for example a source code directory, may be created with just an item, as it has no dependencies, the state generator is derived automatically, because it is an existing directory, and nothing needs to be done, so it has no command.
| Parameters | |
item:T | represents the item to keep up-to-date, like a file or directory name |
*dependencies:Target[ | the dependencies of this target |
state:str | Callable[ | describes how to generate a state (checksum, fingerprint) for this target's item. The function must generate a small fingerprint string from the target's item. If state is not provided, the If given as a string, it must be "dir", "file", "new",
"fixed" or "value" for Otherwise it must be a function with parameter T to be called with the Target's item to create the checksum. |
name:str | None | A nice name for the target to use, for example, on the command line. The default is name is str(item). |
cmd:Callable[ | the command to run to (re-)create the target. Its parameters will be the target's item as well as the items of all dependencies. |
Suggest to tools like toGraphviz not to show a string representation of the
item, but instead only use the name. If no explicit name was provided, calling this
function is silly, as in that case the name is str(item) anyway.
This is typically used for targets whose string representation reveals a developers local setup, like environment variables. If the representation ends up committed, like the dependency graph, targets which change frequently, like file names containing a version, may also opt to use showNameOnly().
If set to True before the build starts, the target is assumed to be out-of-date, independent of the computed state hash. This can be used to force rebuilding a target.
Setting this to True means that a representation of the item should typically not be shown in output. Currently used only when the dependency graph is drawn.
Set during updateTargets if this target was out-of-date and its
command was run.
This does not say whether the target was actually changed by running its cmd, it merely informs that the command was run.
Set during updateTargets as soon as all dependencies are done.
The target's command may or may not be run subsequently.