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 = <Values at 0x7fe5a67dac20: {}>

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.envvars = []

List of environment variable declarations placed after the Waf executable name. These are detected by searching for “=” in the remaining arguments. You probably do not want to use this.

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

Name of the lock file that marks a project as configured

class waflib.Options.opt_parser(ctx, allow_unknown=False)[source]

Bases: optparse.OptionParser

Command-line options parser.

_process_args(largs, rargs, values)[source]

Custom _process_args to allow unknown options according to the allow_unknown status

get_usage()[source]

Builds the message to print on waf --help

Return type:string
class waflib.Options.OptionsContext(**kw)[source]

Bases: waflib.Context.Context

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 = None

Instance of waflib.Options.opt_parser

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_option(*k, **kw)[source]

Wraps optparse.add_option:

def options(ctx):
        ctx.add_option('-u', '--use', dest='use', default=False,
                action='store_true', help='a boolean option')
Return type:optparse 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, commands and envvars If help is requested, prints it and exit the application

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

See waflib.Context.Context.execute()