Feature reference¶
The Waf features are names linked to specific functions by the decorator
waflib.TaskGen.feature()
. The functions
are mapped to the class waflib.TaskGen.task_gen
as methods.
The association between feature names and methods is many-to-many, which means that a method may be involved in several features, and that a feature may be bound to several methods.
Here is how to create and use a new feature named foo:
from waflib.TaskGen import feature
@feature('foo')
def print_hello(self):
print("Hello, World!")
The function print_hello is now associated with the waflib.TaskGen.task_gen
class, which means
that it may be used directly:
def build(bld):
tg = bld()
tg.print_hello()
The method may be called directly, and several times. If a method creates task, the same tasks will be created more than once, which may cause build errors. The feature attribute is used to have the associated methods called exactly once before the build starts:
def build(bld):
bld(features='foo')
Here is a more complete example with two methods:
from waflib.TaskGen import feature, after_method
@feature('foo')
@after_method('print_bar')
def print_hello(self):
print("Hello, Foo!")
@feature('bar')
def print_bar(self):
print("Hello, Bar!")
def build(bld):
bld(features='foo bar')
The order of method execution is unrelated to the order of the features given. For instance,
this example will print “Hello, Bar!” then “Hello, Foo!”. The decorators
waflib.TaskGen.after()
and waflib.TaskGen.before()
are
enforcing partial order constraints on the methods to execute.
The following maps represent the associations betwen feature methods (represented in yellow) and methods associated to other feature names.
Feature *¶
Feature asm¶
Feature c¶
Feature cprogram¶
Feature cs¶
Feature cshlib¶
Feature cxx¶
Feature cxxprogram¶
Feature cxxshlib¶
Feature d¶
Feature dshlib¶
Feature fake_lib¶
Feature fake_obj¶
Feature fc¶
Feature fcprogram¶
Feature fcprogram_test¶
Feature fcshlib¶
Feature fcstlib¶
Feature glib2¶
Feature grep_for_endianness¶
Feature gresource¶
Feature includes¶
Feature intltool_in¶
Feature intltool_po¶
Feature jar¶
Feature javac¶
Feature javadoc¶
Feature link_lib_test¶
Feature link_main_routines_func¶
Feature msgfmt¶
Feature perlext¶
Feature py¶
Feature pyembed¶
Feature pyext¶
Feature qt4¶
Feature qt5¶
Feature rubyext¶
Feature seq¶
Feature subst¶
Feature test¶
Feature test_exec¶
Feature tex¶
Feature use¶
Feature uselib¶
Feature vnum¶
Feature winapp¶
Feature winphoneapp¶