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
= ['distclean', 'configure', 'build', 'install', 'clean', 'uninstall', 'check', 'dist', 'distcheck']¶ 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()
.
-
waflib.Options.
envvars
= []¶ List of environment variable declarations placed after the Waf executable name. These are detected by searching for “=” in the rest arguments.
-
class
waflib.Options.
opt_parser
(ctx)[source]¶ Bases:
optparse.OptionParser
Command-line options parser.
-
__doc__
= '\n\tCommand-line options parser.\n\t'¶
-
__module__
= 'waflib.Options'¶
-
-
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
andwaflib.Options.options
values.-
cmd
= 'options'¶
-
fun
= 'options'¶
-
parser
= None¶ Instance of
waflib.Options.opt_parser
-
__doc__
= '\n\tCollect custom options from wscript files and parses the command line.\n\tSet the global :py:const:`waflib.Options.commands` and :py:const:`waflib.Options.options` values.\n\t'¶
-
__module__
= 'waflib.Options'¶
-
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): gr = 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
-