Options

Support for waf command-line options

Provides default and command-line options, as well the command that reads the options wscript function.

waflib.Options.options = <waflib.Options.OptionValues object>

A global dictionary representing user-provided 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 by waflib.Scripting.run_commands().

waflib.Options.lockfile = '.lock-waf_linux_build'

Name of the lock file that marks a project as configured

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

Command-line options parser.

_get_formatter()[source]

Initialize the argument parser to the adequate terminal width

get_usage()[source]

Builds the message to print on waf --help

Return type

string

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

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

cmd = 'options'
fun = 'options'
parser

Instance of waflib.Options.ArgParser

jobs()[source]

Finds the optimal amount of cpu cores to use for parallel jobs. 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_argument(*k, **kw)[source]

Wraps argparse.add_argument:

def options(ctx):
        ctx.add_option('-u', '--use', dest='use', default=False,
                action='store_true', help='a boolean option')
Return type

argparse option object

add_option_group(*k, **kw)[source]

Wraps optparse.add_option_group:

def options(ctx):
        gr = ctx.add_option_group('some options')
        gr.add_option('-u', '--use', dest='use', default=False, action='store_true')
Return type

optparse option group object

get_option_group(opt_str)[source]

Wraps 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')
Return type

optparse option group object

parse_cmd_args(_args=None, cwd=None, allow_unknown=False)[source]

Just parse the arguments

parse_args(_args=None)[source]

Parses arguments from a list which is not necessarily the command-line. Initializes the module variables options and commands If help is requested, prints it and exit the application

Parameters

_args (list of strings) – arguments

execute()[source]

See waflib.Context.Context.execute()