Configure

Configuration system

A waflib.Configure.ConfigurationContext instance is created when waf configure is called, it is used to:

  • create data dictionaries (ConfigSet instances)
  • store the list of modules to import
  • hold configuration routines such as find_program, etc
waflib.Configure.BREAK

In case of a configuration error, break

waflib.Configure.CONTINUE

In case of a configuration error, continue

waflib.Configure.WAF_CONFIG_LOG

Name of the configuration log file

waflib.Configure.autoconfig

Execute the configuration automatically

waflib.Configure.download_check(node)[source]

Hook to check for the tools which are downloaded. Replace with your function if necessary.

waflib.Configure.download_tool(tool, force=False, ctx=None)[source]

Download a Waf tool from the remote repository defined in waflib.Context.remote_repo:

$ waf configure --download
class waflib.Configure.ConfigurationContext(**kw)[source]

Bases: waflib.Context.Context

Configure the project.

Waf tools may bind new methods to this class:

from waflib.Configure import conf
@conf
def myhelper(self):
        print("myhelper")

def configure(ctx):
        ctx.myhelper()
error_handlers

Additional functions to handle configuration errors

setenv(name, env=None)[source]

Set a new config set for conf.env. If a config set of that name already exists, recall it without modification.

The name is the filename prefix to save to c4che/NAME_cache.py, and it is also used as variants by the build commands. Though related to variants, whatever kind of data may be stored in the config set:

def configure(cfg):
        cfg.env.ONE = 1
        cfg.setenv('foo')
        cfg.env.ONE = 2

def build(bld):
        2 == bld.env_of_name('foo').ONE
Parameters:
  • name (string) – name of the configuration set
  • env (waflib.ConfigSet.ConfigSet) – ConfigSet to copy, or an empty ConfigSet is created
get_env()[source]

Getter for the env property

set_env(val)[source]

Setter for the env property

env

Getter for the env property

init_dirs()[source]

Initialize the project directory and the build directory

execute()[source]

See waflib.Context.Context.execute()

prepare_env(env)[source]

Insert PREFIX, BINDIR and LIBDIR values into env

Parameters:env (waflib.ConfigSet.ConfigSet) – a ConfigSet, usually conf.env
store()[source]

Save the config results into the cache file

load(input, tooldir=None, funs=None, download=True)[source]

Load Waf tools, which will be imported whenever a build is started.

Parameters:
  • input (list of string) – waf tools to import
  • tooldir (list of string) – paths for the imports
  • funs (list of string) – functions to execute from the waf tools
  • download (bool) – whether to download the tool from the waf repository
post_recurse(node)[source]

Records the path and a hash of the scripts visited, see waflib.Context.Context.post_recurse()

Parameters:node (waflib.Node.Node) – script
eval_rules(rules)[source]

Execute the configuration tests. The method waflib.Configure.ConfigurationContext.err_handler() is used to process the eventual exceptions

Parameters:rules (list of string) – list of configuration method names
err_handler(fun, error)[source]

Error handler for the configuration tests, the default is to let the exception raise

Parameters:
  • fun (method) – configuration test
  • error (exception) – exception
waflib.Configure.conf(f)[source]

Decorator: attach new configuration functions to waflib.Build.BuildContext and waflib.Configure.ConfigurationContext. The methods bound will accept a parameter named ‘mandatory’ to disable the configuration errors:

def configure(conf):
        conf.find_program('abc', mandatory=False)
Parameters:f (function) – method to bind
waflib.Configure.add_os_flags(self, var, dest=None)[source]

Import operating system environment values into conf.env dict:

def configure(conf):
        conf.add_os_flags('CFLAGS')
Parameters:
  • var (string) – variable to use
  • dest (string) – destination variable, by default the same as var
waflib.Configure.cmd_to_list(self, cmd)[source]

Detect if a command is written in pseudo shell like ccache g++ and return a list.

Parameters:cmd (a string or a list of string) – command
waflib.Configure.check_waf_version(self, mini='1.6.0', maxi='1.7.0')[source]

check for the waf version

Versions should be supplied as hex. 0x01000000 means 1.0.0, 0x010408 means 1.4.8, etc.

Parameters:
  • mini (number, tuple or string) – Minimum required version
  • maxi (number, tuple or string) – Maximum allowed version
waflib.Configure.find_file(self, filename, path_list=[])[source]

Find a file in a list of paths

Parameters:
  • filename – name of the file to search for
  • path_list – list of directories to search
Returns:

the first occurrence filename or ‘’ if filename could not be found

waflib.Configure.find_program(self, filename, **kw)[source]

Search for a program on the operating system

When var is used, you may set os.environ[var] to help find a specific program version, for example:

$ VALAC=/usr/bin/valac_test waf configure
Parameters:
  • path_list – paths to use for searching
  • var (string) – store the result to conf.env[var], by default use filename.upper()
  • ext (list of string) – list of extensions for the binary (do not add an extension for portability)
waflib.Configure.find_perl_program(self, filename, path_list=[], var=None, environ=None, exts='')[source]

Search for a perl program on the operating system

Parameters:
  • filename (string) – file to search for
  • path_list (list of string) – list of paths to look into
  • var (string) – store the results into conf.env.var
  • environ (dict) – operating system environment to pass to waflib.Configure.find_program()
  • exts (list) – extensions given to waflib.Configure.find_program()

Previous topic

ConfigSet

Next topic

Context

This Page