Tasks represent atomic operations such as processes.
The task was not executed yet
The task has been executed but the files have not been created
The task execution returned a non-zero exit status
An exception occurred in the task execution
A dependency for the task is missing so it was cancelled
The task did not have to be executed
The task was successfully executed
The task is not ready to be executed
The task does not need to be executed
The task must be executed
The task cannot be executed because of a dependency problem
The metaclass waflib.Task.store_task_type stores all class tasks created by user scripts or Waf tools to this dict. It maps class names to class objects.
Bases: type
Metaclass: store the task classes into the dict pointed by the class attribute ‘register’ which defaults to waflib.Task.classes,
The attribute ‘run_str’ is compiled into a method ‘run’ bound to the task class.
Bases: object
Base class provided to avoid writing a metaclass, so the code can run in python 2.6 and 3.x unmodified
Bases: waflib.Task.evil
This class deals with the filesystem (waflib.Node.Node). The method waflib.Task.Task.runnable_status uses a hash value (from waflib.Task.Task.signature) which is persistent from build to build. When the value changes, the task has to be executed. The method waflib.Task.Task.post_run will assign the task signature to the output nodes (if present).
ConfigSet variables that should trigger a rebuild (class attribute used for waflib.Task.Task.sig_vars())
Specify whether task instances must always be executed or not (class attribute)
Execute the command with the shell (class attribute)
Color for the console display, see waflib.Logs.colors_lst
File extensions that objects of this task class may use
File extensions that objects of this task class may create
List of task class names to execute before instances of this class
List of task class names to execute after instances of this class
String representing an additional hash for the class representation
Whether to keep the last command executed on the instance after execution. This may be useful for certain extensions but it can a lot of memory.
Optional weight to tune the priority for task instances. The higher, the earlier. The weight only applies to single task objects.
Optional weight to tune the priority of task instances and whole subtrees. The higher, the earlier.
Priority order set by the scheduler on instances during the build phase. You most likely do not need to set it.
waflib.ConfigSet.ConfigSet object (make sure to provide one)
List of input nodes, which represent the files used by the task instance
List of output nodes, which represent the files created by the task instance
List of additional nodes to depend on
Set of tasks that must be executed before this one
Returns: | current working directory |
---|---|
Return type: | waflib.Node.Node |
Surround a process argument by quotes so that a list of arguments can be written to a file
Parameters: | x (string) – flag |
---|---|
Returns: | quoted flag |
Return type: | string |
Priority of execution; the higher, the earlier
Returns: | the priority value |
---|---|
Return type: | a tuple of numeric values |
Splits a list of process commands into the executable part and its list of arguments
Returns: | a tuple containing the executable first and then the rest of arguments |
---|---|
Return type: | tuple |
Wrapper for waflib.Context.Context.exec_command(). This version set the current working directory (build.variant_dir), applies PATH settings (if self.env.PATH is provided), and can run long commands through a temporary @argfile.
Parameters: | cmd (list of string (best) or string (process will use a shell)) – process command to execute |
---|---|
Returns: | the return code |
Return type: | int |
Returns an execution status for the console, the progress bar, or the IDE output.
Return type: | string |
---|
Identifies a task type for all the constraints relevant for the scheduler: precedence, file production
Returns: | a hash value |
---|---|
Return type: | string |
Returns an error message to display the build failure reasons
Return type: | string |
---|
Enable scriptlet expressions of the form ${FOO_ST:FOO} If the first variable (FOO_ST) is empty, then an empty list is returned
The results will be slightly different if FOO_ST is a list, for example:
env.FOO = ['p1', 'p2']
env.FOO_ST = '-I%s'
# ${FOO_ST:FOO} returns
['-Ip1', '-Ip2']
env.FOO_ST = ['-a', '-b']
# ${FOO_ST:FOO} returns
['-a', '-b', 'p1', '-a', '-b', 'p2']
Returns an identifier used to determine if tasks are up-to-date. Since the identifier will be stored between executions, it must be:
- unique for a task: no two tasks return the same value (for a given build context)
- the same for a given task instance
By default, the node paths, the class name, and the function are used as inputs to compute a hash.
The pointer to the object (python built-in ‘id’) will change between build executions, and must be avoided in such hashes.
Returns: | hash value |
---|---|
Return type: | string |
Appends the nodes to the inputs list
Parameters: | inp (node or list of nodes) – input nodes |
---|
Appends the nodes to the outputs list
Parameters: | out (node or list of nodes) – output nodes |
---|
Run this task only after the given task.
Parameters: | task (waflib.Task.Task) – task |
---|
Task signatures are stored between build executions, they are use to track the changes made to the input nodes (not to the outputs!). The signature hashes data from various sources:
If the signature is expected to give a different result, clear the cache kept in self.cache_sig:
from waflib import Task
class cls(Task.Task):
def signature(self):
sig = super(Task.Task, self).signature()
delattr(self, 'cache_sig')
return super(Task.Task, self).signature()
Returns: | the signature value |
---|---|
Return type: | string or bytes |
Returns the Task status
Returns: | a task state in waflib.Task.RUN_ME, waflib.Task.SKIP_ME, waflib.Task.CANCEL_ME or waflib.Task.ASK_LATER. |
---|---|
Return type: | int |
Used by waflib.Task.Task.signature(); it hashes waflib.Task.Task.inputs and waflib.Task.Task.dep_nodes signatures.
Used by waflib.Task.Task.signature(); it hashes waflib.Task.Task.env variables/values
This method, when provided, returns a tuple containing:
For example:
from waflib.Task import Task
class mytask(Task):
def scan(self, node):
return ([], [])
The first and second lists in the tuple are stored in waflib.Build.BuildContext.node_deps and waflib.Build.BuildContext.raw_deps respectively.
Used by waflib.Task.Task.signature(); it hashes node signatures obtained by scanning for dependencies (waflib.Task.Task.scan()).
The exception waflib.Errors.TaskRescan is thrown when a file has changed. In this case, the method waflib.Task.Task.signature() is called once again, and return here to call waflib.Task.Task.scan() and searching for dependencies.
Used by waflib.Task.Task.sig_implicit_deps() for computing the actual hash of the waflib.Node.Node returned by the scanner.
Returns: | a hash value for the implicit dependencies |
---|---|
Return type: | string or bytes |
Returns a non-zero value if task t1 is to be executed before task t2:
t1.ext_out = '.h'
t2.ext_in = '.h'
t2.after = ['t1']
t1.before = ['t2']
waflib.Task.is_before(t1, t2) # True
Parameters: |
|
---|
Updates the run_after attribute of all tasks based on the task inputs and outputs
Parameters: | tasks (list of waflib.Task.Task) – tasks |
---|
Bases: object
Wrap nxm task order constraints into a single object to prevent the creation of large list/set objects
This is an optimization
Updates the run_after attribute of all tasks based on the after/before/ext_out/ext_in attributes
Parameters: | tasks (list of waflib.Task.Task) – tasks |
---|
Compiles a scriptlet expression into a Python function
Parameters: | c (string) – function to compile |
---|---|
Returns: | the function ‘f’ declared in the input string |
Return type: | function |
Creates a compiled function to execute a process through a sub-shell
Creates a compiled function to execute a process without a sub-shell
Parses a string expression such as ‘${CC} ${SRC} -o ${TGT}’ and returns a pair containing:
for example:
from waflib.Task import compile_fun
compile_fun('cxx', '${CXX} -o ${TGT[0]} ${SRC} -I ${SRC[0].parent.bldpath()}')
def build(bld):
bld(source='wscript', rule='echo "foo\${SRC[0].name}\bar"')
The env variables (CXX, ..) on the task must not hold dicts so as to preserve a consistent order. The reserved keywords TGT and SRC represent the task input and output nodes
Returns a new task subclass with the function run compiled from the line given.
Parameters: |
|
---|---|
Return type: |