Options

Support for waf command-line options

Provides default command-line options, as well as custom ones, used by the options wscript function.

waflib.Options.cmds

Constant representing the default waf commands displayed in:

$ waf --help
waflib.Options.options

A dictionary representing the command-line options:

$ waf --foo=bar
waflib.Options.commands

List of commands to execute extracted from the command-line. This list is consumed during the execution, see waflib.Scripting.run_commands().

class waflib.Options.opt_parser(ctx)[source]

Bases: optparse.OptionParser

Command-line options parser.

get_usage()[source]

Return the message to print on waf --help

class waflib.Options.OptionsContext(**kw)[source]

Bases: waflib.Context.Context

Collect custom options from wscript files and parses the command line. Set the global waflib.Options.commands and waflib.Options.options values.

parser

Instance of waflib.Options.opt_parser

jobs()[source]

Find the amount of cpu cores to set the default amount of tasks executed in parallel. At runtime the options can be obtained from waflib.Options.options

from waflib.Options import options
njobs = options.jobs
Returns:the amount of cpu cores
Return type:int
add_option(*k, **kw)[source]

Wrapper for optparse.add_option:

def options(ctx):
        ctx.add_option('-u', '--use', dest='use', default=False, action='store_true',
                help='a boolean option')
add_option_group(*k, **kw)[source]

Wrapper for optparse.add_option_group:

def options(ctx):
        ctx.add_option_group('some options')
        gr.add_option('-u', '--use', dest='use', default=False, action='store_true')
get_option_group(opt_str)[source]

Wrapper for optparse.get_option_group:

def options(ctx):
        gr = ctx.get_option_group('configure options')
        gr.add_option('-o', '--out', action='store', default='',
                help='build dir for the project', dest='out')
parse_args(_args=None)[source]

Parse arguments from a list (not bound to the command-line).

Parameters:_args (list of strings) – arguments
execute()[source]

See waflib.Context.Context.execute()

Previous topic

Node

Next topic

Runner

This Page