ccroot

Classes and methods shared by tools providing support for C-like language such as C/C++/D/Assembly/Go (this support module is almost never used alone).

waflib.Tools.ccroot.USELIB_VARS

Mapping for features to waflib.ConfigSet.ConfigSet variables. See waflib.Tools.ccroot.propagate_uselib_vars().

waflib.Tools.ccroot.create_compiled_task(self, name, node)[source]

Task generator method

Create the compilation task: c, cxx, asm, etc. The output node is created automatically (object file with a typical .o extension). The task is appended to the list compiled_tasks which is then used by waflib.Tools.ccroot.apply_link()

Parameters:
  • name (string) – name of the task class
  • node (waflib.Node.Node) – the file to compile
Returns:

The task created

Return type:

waflib.Task.Task

waflib.Tools.ccroot.to_incnodes(self, inlst)[source]

Task generator method

Task generator method provided to convert a list of string/nodes into a list of includes folders.

The paths are assumed to be relative to the task generator path, except if they begin by # in which case they are searched from the top-level directory (bld.srcnode). The folders are simply assumed to be existing.

The node objects in the list are returned in the output list. The strings are converted into node objects if possible. The node is searched from the source directory, and if a match is found, the equivalent build directory is created and added to the returned list too. When a folder cannot be found, it is ignored.

Parameters:inlst (space-delimited string or a list of string/nodes) – list of folders
Return type:list of waflib.Node.Node
Returns:list of include folders as nodes
waflib.Tools.ccroot.apply_incpaths(self)[source]

Task generator method

Task generator method that processes the attribute includes:

tg = bld(features='includes', includes='.')

The folders only need to be relative to the current directory, the equivalent build directory is added automatically (for headers created in the build directory). This enable using a build directory or not (top == out).

This method will add a list of nodes read by waflib.Tools.ccroot.to_incnodes() in tg.env.INCPATHS, and the list of include paths in tg.env.INCLUDES.

Feature :c, cxx, d, asm, fc, includes

Bases: waflib.Task.Task

Base class for all link tasks. A task generator is supposed to have at most one link task bound in the attribute link_task. See waflib.Tools.ccroot.apply_link().

Inheritance diagram of waflib.Tools.ccroot.stlink_task, waflib.Tools.c.cprogram, waflib.Tools.c.cshlib, waflib.Tools.cxx.cxxstlib, waflib.Tools.cxx.cxxprogram, waflib.Tools.cxx.cxxshlib, waflib.Tools.d.dprogram, waflib.Tools.d.dshlib, waflib.Tools.d.dstlib, waflib.Tools.ccroot.fake_shlib, waflib.Tools.ccroot.fake_stlib, waflib.Tools.asm.asmprogram, waflib.Tools.asm.asmshlib, waflib.Tools.asm.asmstlib

Default installation path for the link task outputs, or None to disable

Default installation mode for the link task outputs

Process the target attribute to add the platform-specific prefix/suffix such as .so or .exe. The settings are retrieved from env.clsname_PATTERN

Bases: waflib.Tools.ccroot.link_task

Base for static link tasks, which use ar most of the time. The target is always removed before being written.

Task generator method

Collect the tasks stored in compiled_tasks (created by waflib.Tools.ccroot.create_compiled_task()), and use the outputs for a new instance of waflib.Tools.ccroot.link_task. The class to use is the first link task matching a name from the attribute features, for example:

def build(bld):
        tg = bld(features='cxx cxxprogram cprogram', source='main.c', target='app')

will create the task tg.link_task as a new instance of waflib.Tools.cxx.cxxprogram

Feature :c, cxx, d, fc, asm
waflib.Tools.ccroot.use_rec(self, name, **kw)[source]

Task generator method

Processes the use keyword recursively. This method is kind of private and only meant to be used from process_use

waflib.Tools.ccroot.process_use(self)[source]

Task generator method

Process the use attribute which contains a list of task generator names:

def build(bld):
        bld.shlib(source='a.c', target='lib1')
        bld.program(source='main.c', target='app', use='lib1')

See waflib.Tools.ccroot.use_rec().

Feature :c, cxx, d, use, fc

Task generator method

PRIVATE INTERNAL USE ONLY

waflib.Tools.ccroot.add_objects_from_tgen(self, tg)[source]

Task generator method

Add the objects from the depending compiled tasks as link task inputs.

Some objects are filtered: for instance, .pdb files are added to the compiled tasks but not to the link tasks (to avoid errors) PRIVATE INTERNAL USE ONLY

waflib.Tools.ccroot.get_uselib_vars(self)[source]

Task generator method

Returns:the uselib variables associated to the features attribute (see waflib.Tools.ccroot.USELIB_VARS)
Return type:list of string
waflib.Tools.ccroot.propagate_uselib_vars(self)[source]

Task generator method

Process uselib variables for adding flags. For example, the following target:

def build(bld):
        bld.env.AFLAGS_aaa = ['bar']
        from waflib.Tools.ccroot import USELIB_VARS
        USELIB_VARS['aaa'] = set('AFLAGS')

        tg = bld(features='aaa', aflags='test')

The aflags attribute will be processed and this method will set:

tg.env.AFLAGS = ['bar', 'test']
Feature :c, cxx, d, fc, javac, cs, uselib, asm
waflib.Tools.ccroot.apply_implib(self)[source]

Task generator method

Handle dlls and their import libs on Windows-like systems.

A .dll.a file called import library is generated. It must be installed as it is required for linking the library.

Feature :cshlib, cxxshlib, fcshlib
waflib.Tools.ccroot.apply_vnum(self)[source]

Task generator method

Enforce version numbering on shared libraries. The valid version numbers must have at most two dots:

def build(bld):
        bld.shlib(source='a.c', target='foo', vnum='14.15.16')

In this example, libfoo.so is installed as libfoo.so.1.2.3, and the following symbolic links are created:

  • libfoo.so   libfoo.so.1.2.3
  • libfoo.so.1 libfoo.so.1.2.3
Feature :cshlib, cxxshlib, dshlib, fcshlib, vnum
class waflib.Tools.ccroot.vnum(*k, **kw)[source]

Bases: waflib.Task.Task

Create the symbolic links for a versioned shared library. Instances are created by waflib.Tools.ccroot.apply_vnum()

class waflib.Tools.ccroot.fake_shlib(*k, **kw)[source]

Bases: waflib.Tools.ccroot.link_task

Task used for reading a system library and adding the dependency on it

class waflib.Tools.ccroot.fake_stlib(*k, **kw)[source]

Bases: waflib.Tools.ccroot.stlink_task

Task used for reading a system library and adding the dependency on it

waflib.Tools.ccroot.read_shlib(self, name, paths=[], export_includes=[], export_defines=[])[source]

Configuration Method bound to waflib.Configure.ConfigurationContext

Read a system shared library, enabling its use as a local library. Will trigger a rebuild if the file changes:

def build(bld):
        bld.read_shlib('m')
        bld.program(source='main.c', use='m')
waflib.Tools.ccroot.read_stlib(self, name, paths=[], export_includes=[], export_defines=[])[source]

Configuration Method bound to waflib.Configure.ConfigurationContext

Read a system static library, enabling a use as a local library. Will trigger a rebuild if the file changes.

waflib.Tools.ccroot.process_lib(self)[source]

Task generator method

Find the location of a foreign library. Used by waflib.Tools.ccroot.read_shlib and waflib.Tools.ccroot.read_stlib.

Feature :fake_lib
waflib.Tools.ccroot.conf(f)

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.Tools.ccroot.taskgen_method(func)

Decorator: register a method as a task generator method. The function must accept a task generator as first parameter:

from waflib.TaskGen import taskgen_method
@taskgen_method
def mymethod(self):
        pass
Parameters:func (function) – task generator method to add
Return type:function
waflib.Tools.ccroot.feature(*k)

Decorator: register a task generator method that will be executed when the object attribute ‘feature’ contains the corresponding key(s):

from waflib.Task import feature
@feature('myfeature')
def myfunction(self):
        print('that is my feature!')
def build(bld):
        bld(features='myfeature')
Parameters:k (list of string) – feature names
waflib.Tools.ccroot.before_method(*k)

Decorator: register a task generator method which will be executed before the functions of given name(s):

from waflib.TaskGen import feature, before
@feature('myfeature')
@before_method('fun2')
def fun1(self):
        print('feature 1!')
@feature('myfeature')
def fun2(self):
        print('feature 2!')
def build(bld):
        bld(features='myfeature')
Parameters:k (list of string) – method names
waflib.Tools.ccroot.after_method(*k)

Decorator: register a task generator method which will be executed after the functions of given name(s):

from waflib.TaskGen import feature, after
@feature('myfeature')
@after_method('fun2')
def fun1(self):
        print('feature 1!')
@feature('myfeature')
def fun2(self):
        print('feature 2!')
def build(bld):
        bld(features='myfeature')
Parameters:k (list of string) – method names
waflib.Tools.ccroot.extension(*k)

Decorator: register a task generator method which will be invoked during the processing of source files for the extension given:

from waflib import Task
class mytask(Task):
        run_str = 'cp ${SRC} ${TGT}'
@extension('.moo')
def create_maa_file(self, node):
        self.create_task('mytask', node, node.change_ext('.maa'))
def build(bld):
        bld(source='foo.moo')
waflib.Tools.ccroot.process_objs(self)[source]

Task generator method

Puts object files in the task generator outputs

Feature :fake_obj
waflib.Tools.ccroot.read_object(self, obj)[source]

Configuration Method bound to waflib.Configure.ConfigurationContext

Read an object file, enabling injection in libs/programs. Will trigger a rebuild if the file changes.

Parameters:obj – object file path, as string or Node

Features defined in this module:

Previous topic

irixcc

Next topic

c

This Page