Classes and functions required for waf commands
Constant updated on new releases
Constant updated on new releases
Constant updated on new releases
Version of the build data cache file format (used in waflib.Context.DBFILE)
Name of the pickle file for storing the build data
Default application name (used by waf dist)
Default application version (used by waf dist)
The variable name for the top-level directory in wscript files
The variable name for the output directory in wscript files
Name of the waf script files
Directory from which waf has been called
Location of the wscript file to use as the entry point
Location of the project directory (top), if the project was configured
Location of the build directory (out), if the project was configured
Directory containing the waf modules
Local repository containing additional Waf tools (plugins)
Remote directory containing downloadable waf tools. The missing tools can be downloaded by using:
$ waf configure --download
Remote directories for use with waflib.Context.remote_repo
Module representing the main wscript file (see waflib.Context.run_dir)
List of waflib.Context.Context subclasses that can be used as waf commands. The classes are added automatically by a metaclass.
Create a new waflib.Context.Context instance corresponding to the given command. Used in particular by waflib.Scripting.run_command()
Parameters: |
|
---|
Bases: type
Metaclass for storing the command classes into the list waflib.Context.classes Context classes must provide an attribute ‘cmd’ representing the command to execute
Bases: object
Base class for the waflib.Context.Context classes
Bases: waflib.Context.ctx
Default context for waf commands, and base class for new command contexts.
Context objects are passed to top-level functions:
def foo(ctx):
print(ctx.__class__.__name__) # waflib.Context.Context
Subclasses must define the attribute ‘cmd’:
Parameters: |
|
---|
Shortcut to waflib.Errors provided for convenience
A cache for modules (wscript files) read by Context.Context.load()
Return a hash value for storing context objects in dicts or sets. The value is not persistent.
Returns: | hash value |
---|---|
Return type: | int |
Load a Waf tool as a module, and try calling the function named waflib.Context.Context.fun from it. A tooldir value may be provided as a list of module paths.
Parameters: | tool_list (list of string or space-separated string) – list of Waf tools to use |
---|
Method executed immediately before a folder is read by waflib.Context.Context.recurse(). The node given is set as an attribute self.cur_script, and as the current path self.path
Parameters: | node (waflib.Node.Node) – script |
---|
Restore self.cur_script and self.path right after waflib.Context.Context.recurse() terminates.
Parameters: | node (waflib.Node.Node) – script |
---|
Run user code from the supplied list of directories. The directories can be either absolute, or relative to the directory of the wscript file. The methods waflib.Context.Context.pre_recurse() and waflib.Context.Context.post_recurse() are called immediately before and after a script has been executed.
Parameters: |
|
---|
Execute a command and return the exit status. If the context has the attribute ‘log’, capture and log the process stderr/stdout for logging purposes:
def run(tsk):
ret = tsk.generator.bld.exec_command('touch foo.txt')
return ret
Do not confuse this method with waflib.Context.Context.cmd_and_log() which is used to return the standard output/error values.
Parameters: |
|
---|
Execute a command and return stdout if the execution is successful. An exception is thrown when the exit status is non-0. In that case, both stderr and stdout will be bound to the WafError object:
def configure(conf):
out = conf.cmd_and_log(['echo', 'hello'], output=waflib.Context.STDOUT, quiet=waflib.Context.BOTH)
(out, err) = conf.cmd_and_log(['echo', 'hello'], output=waflib.Context.BOTH)
try:
conf.cmd_and_log(['which', 'someapp'], output=waflib.Context.BOTH)
except Exception as e:
print(e.stdout, e.stderr)
Parameters: |
|
---|
Raise a configuration error to interrupt the execution immediately:
def configure(conf):
conf.fatal('a requirement is missing')
Parameters: |
|
---|
Log some information to the logger (if present), or to stderr. If the message is empty, it is not printed:
def build(bld):
bld.to_log('starting the build')
When in doubt, override this method, or provide a logger on the context class.
Parameters: | msg (string) – message |
---|
Print a configuration message of the form msg: result. The second part of the message will be in colors. The output can be disabled easly by setting in_msg to a positive value:
def configure(conf):
self.in_msg = 1
conf.msg('Checking for library foo', 'ok')
# no output
Parameters: |
|
---|
Print the beginning of a ‘Checking for xxx’ message. See waflib.Context.Context.msg()
Print the end of a ‘Checking for’ message. See waflib.Context.Context.msg()
Dictionary holding already loaded modules, keyed by their absolute path. The modules are added automatically by waflib.Context.load_module()
Load a source file as a python module.
Parameters: | path (string) – file path |
---|---|
Returns: | Loaded Python module |
Return type: | module |
Import a Waf tool (python module), and store it in the dict waflib.Context.Context.tools
Parameters: |
|
---|