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 occured in the task execution
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
Task class decorator applied to all task classes by default unless they define the attribute ‘nocache’:
from waflib import Task
class foo(Task.Task):
nocache = True
If bld.cache_global is defined and if the task instances produces output nodes, the files will be copied into a folder in the cache directory
The files may also be retrieved from that folder, if it exists
class tasks created by user scripts or Waf tools are kept in this dict name -> class object
Bases: type
Metaclass: store the task types into waflib.Task.classes. The attribute ‘run_str’ will be processed to compute a method ‘run’ on the task class The decorator waflib.Task.cache_outputs() is also applied to the 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
Base class for all Waf tasks, which should be seen as an interface. For illustration purposes, instances of this class will execute the attribute ‘fun’ in waflib.Task.TaskBase.run(). When in doubt, create subclasses of waflib.Task.Task instead.
Subclasses should override these methods:
Color for the console display, see waflib.Logs.colors_lst
File extensions that objects of this task class might use
File extensions that objects of this task class might 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
The base task class requires a task generator, which will be itself if missing
Very fast hashing scheme but not persistent (replace/implement in subclasses and see waflib.Task.Task.uid())
Wrapper for waflib.Context.Context.exec_command() which sets a current working directory to build.variant_dir
Returns: | the return code |
---|---|
Return type: | int |
State of the task
Returns: | a task state in waflib.Task.RUN_ME, waflib.Task.SKIP_ME or waflib.Task.ASK_LATER. |
---|---|
Return type: | int |
Return an execution status for the console, the progress bar, or the IDE output.
Return type: | string |
---|
Retrieve an attribute from the instance or from the class.
Parameters: |
|
---|
Bases: waflib.Task.TaskBase
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).
Variables to depend on (class attribute used for waflib.Task.Task.sig_vars())
Execute the command with the shell (class attribute)
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
Execute the task (executed by threads). Override in subclasses.
Return type: | int |
---|
Return an identifier used to determine if tasks are up-to-date. Since the identifier will be stored between executions, it must be:
- unique: 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 |
Append the nodes to the inputs
Parameters: | inp (node or list of nodes) – input nodes |
---|
Append the nodes to the outputs
Parameters: | out (node or list of nodes) – output nodes |
---|
Run this task only after task. Affect waflib.Task.runnable_status()
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()
Override waflib.Task.TaskBase.runnable_status() to determine if the task is ready to be run (waflib.Task.Task.run_after)
Used by waflib.Task.Task.signature(), hash waflib.Task.Task.inputs and waflib.Task.Task.dep_nodes signatures.
Return type: | hash value |
---|
Used by waflib.Task.Task.signature(), hash waflib.Task.Task.env variables/values
Return type: | hash value |
---|
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 are stored in waflib.Build.BuildContext.node_deps and waflib.Build.BuildContext.raw_deps respectively.
Used by waflib.Task.Task.signature() hashes node signatures obtained by scanning for dependencies (waflib.Task.Task.scan()).
The exception waflib.Errors.TaskRescan is thrown when a file has changed. When this occurs, waflib.Task.Task.signature() is called once again, and this method will be executed once again, this time calling waflib.Task.Task.scan() for searching the dependencies.
Return type: | hash value |
---|
Used by waflib.Task.Task.sig_implicit_deps() for computing the actual hash of the waflib.Node.Node returned by the scanner.
Returns: | hash value |
---|---|
Return type: | string |
For each node returned by the scanner, see if there is a task behind it, and force the build order
The performance impact on null builds is nearly invisible (1.66s->1.86s), but this is due to agressive caching (1.86s->28s)
Used by waflib.Task.cache_outputs()
Retrieve build nodes from the cache update the file timestamps to help cleaning the least used entries from the cache additionally, set an attribute ‘cached’ to avoid re-creating the same cache files
Suppose there are files in cache/dir1/file1 and cache/dir2/file2:
Used by waflib.Task.cache_outputs() to store the build files in the cache
Return 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: |
|
---|
Adds tasks to the task ‘run_after’ attribute based on the task inputs and outputs
Parameters: | tasks (list of waflib.Task.TaskBase) – tasks |
---|
Add tasks to the task ‘run_after’ attribute based on the after/before/ext_out/ext_in attributes
Parameters: | tasks (list of waflib.Task.TaskBase) – tasks |
---|
Compile a function by ‘exec’
Parameters: | c (string) – function to compile |
---|---|
Returns: | the function ‘f’ declared in the input string |
Return type: | function |
Create a compiled function to execute a process with the shell WARNING: this method may disappear anytime, so use compile_fun instead
Create a compiled function to execute a process without the shell WARNING: this method may disappear anytime, so use compile_fun instead
Parse a string expression such as “${CC} ${SRC} -o ${TGT}” and return 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 (order) The reserved keywords TGT and SRC represent the task input and output nodes
Return a new task subclass with the function run compiled from the line given. Provided for compatibility with waf 1.4-1.5, when we did not use metaclasses to register new objects.
Parameters: |
|
---|---|
Return type: |