SCons.Tool package

Module contents

SCons.Tool

SCons tool selection.

This looks for modules that define a callable object that can modify a construction environment as appropriate for a given tool (or tool chain).

Note that because this subsystem just selects a callable that can modify a construction environment, it’s possible for people to define their own “tool specification” in an arbitrary callable function. No one needs to use or tie in to this subsystem in order to roll their own tool definition.

SCons.Tool.CreateJarBuilder(env)[source]

The Jar builder expects a list of class files which it can package into a jar file.

The jar tool provides an interface for passing other types of java files such as .java, directories or swig interfaces and will build them to class files in which it can package into the jar.

SCons.Tool.CreateJavaClassDirBuilder(env)[source]
SCons.Tool.CreateJavaClassFileBuilder(env)[source]
SCons.Tool.CreateJavaFileBuilder(env)[source]
SCons.Tool.CreateJavaHBuilder(env)[source]

Physically creates symlinks. The symlinks argument must be a list in form [ (link, linktarget), … ], where link and linktarget are SCons nodes.

Used by emitters to handle (shared/versioned) library symlinks

SCons.Tool.FindAllTools(tools, env)[source]
SCons.Tool.FindTool(tools, env)[source]
SCons.Tool.Initializers(env)[source]
SCons.Tool.LibSymlinksActionFunction(target, source, env)[source]
SCons.Tool.LibSymlinksStrFun(target, source, env, *args)[source]

Converts list with pairs of nodes to list with pairs of node paths (strings). Used mainly for debugging.

class SCons.Tool.Tool(name, toolpath=None, **kw)[source]

Bases: object

_load_dotted_module_py2(short_name, full_name, searchpaths=None)[source]
_tool_module()[source]
class SCons.Tool.ToolInitializer(env, tools, names)[source]

Bases: object

A class for delayed initialization of Tools modules.

Instances of this class associate a list of Tool modules with a list of Builder method names that will be added by those Tool modules. As part of instantiating this object for a particular construction environment, we also add the appropriate ToolInitializerMethod objects for the various Builder methods that we want to use to delay Tool searches until necessary.

apply_tools(env)[source]

Searches the list of associated Tool modules for one that exists, and applies that to the construction environment.

remove_methods(env)[source]

Removes the methods that were added by the tool initialization so we no longer copy and re-bind them when the construction environment gets cloned.

class SCons.Tool.ToolInitializerMethod(name, initializer)[source]

Bases: object

This is added to a construction environment in place of a method(s) normally called for a Builder (env.Object, env.StaticObject, etc.). When called, it has its associated ToolInitializer object search the specified list of tools and apply the first one that exists to the construction environment. It then calls whatever builder was (presumably) added to the construction environment in place of this particular instance.

get_builder(env)[source]

Returns the appropriate real Builder for this method name after having the associated ToolInitializer object apply the appropriate Tool module.

class SCons.Tool._ImpLibInfoSupport[source]

Bases: object

get_lib_prefix(env, *args, **kw)[source]
get_lib_suffix(env, *args, **kw)[source]
get_lib_version(env, *args, **kw)[source]
property libtype
class SCons.Tool._LdModInfoSupport[source]

Bases: object

get_lib_prefix(env, *args, **kw)[source]
get_lib_suffix(env, *args, **kw)[source]
get_lib_version(env, *args, **kw)[source]
property libtype
class SCons.Tool._LibInfoGeneratorBase(libtype, infoname)[source]

Bases: object

Generator base class for library-related info such as suffixes for versioned libraries, symlink maps, sonames etc. It handles commonities of SharedLibrary and LoadableModule

_support_classes = {'ImpLib': <class 'SCons.Tool._ImpLibInfoSupport'>, 'LdMod': <class 'SCons.Tool._LdModInfoSupport'>, 'ShLib': <class 'SCons.Tool._ShLibInfoSupport'>}
generate_versioned_lib_info(env, args, result=None, **kw)[source]
get_lib_prefix(env, *args, **kw)[source]
get_lib_suffix(env, *args, **kw)[source]
get_lib_version(env, *args, **kw)[source]
get_versioned_lib_info_generator(**kw)[source]
property libtype
class SCons.Tool._LibNameGenerator(libtype)[source]

Bases: SCons.Tool._LibInfoGeneratorBase

Generates “unmangled” library name from a library file node.

Generally, it’s thought to revert modifications done by prefix/suffix generators (_LibPrefixGenerator/_LibSuffixGenerator) used by a library builder. For example, on gnulink the suffix generator used by SharedLibrary builder appends $SHLIBVERSION to $SHLIBSUFFIX producing node name which ends with “$SHLIBSUFFIX.$SHLIBVERSION”. Correspondingly, the implementation of _LibNameGenerator replaces “$SHLIBSUFFIX.$SHLIBVERSION” with “$SHLIBSUFFIX” in the node’s basename. So that, if $SHLIBSUFFIX is “.so”, $SHLIBVERSION is “0.1.2” and the node path is “/foo/bar/libfoo.so.0.1.2”, the _LibNameGenerator shall return “libfoo.so”. Other link tools may implement it’s own way of library name unmangling.

_support_classes = {'ImpLib': <class 'SCons.Tool._ImpLibInfoSupport'>, 'LdMod': <class 'SCons.Tool._LdModInfoSupport'>, 'ShLib': <class 'SCons.Tool._ShLibInfoSupport'>}
generate_versioned_lib_info(env, args, result=None, **kw)
get_lib_prefix(env, *args, **kw)
get_lib_suffix(env, *args, **kw)
get_lib_version(env, *args, **kw)
get_versioned_lib_info_generator(**kw)
property libtype
class SCons.Tool._LibPrefixGenerator(libtype)[source]

Bases: SCons.Tool._LibInfoGeneratorBase

Library prefix generator, used as target_prefix in SharedLibrary and LoadableModule builders

_support_classes = {'ImpLib': <class 'SCons.Tool._ImpLibInfoSupport'>, 'LdMod': <class 'SCons.Tool._LdModInfoSupport'>, 'ShLib': <class 'SCons.Tool._ShLibInfoSupport'>}
generate_versioned_lib_info(env, args, result=None, **kw)
get_lib_prefix(env, *args, **kw)
get_lib_suffix(env, *args, **kw)
get_lib_version(env, *args, **kw)
get_versioned_lib_info_generator(**kw)
property libtype
class SCons.Tool._LibSonameGenerator(libtype)[source]

Bases: SCons.Tool._LibInfoGeneratorBase

Library soname generator. Returns library soname (e.g. libfoo.so.0) for a given node (e.g. /foo/bar/libfoo.so.0.1.2)

_support_classes = {'ImpLib': <class 'SCons.Tool._ImpLibInfoSupport'>, 'LdMod': <class 'SCons.Tool._LdModInfoSupport'>, 'ShLib': <class 'SCons.Tool._ShLibInfoSupport'>}
generate_versioned_lib_info(env, args, result=None, **kw)
get_lib_prefix(env, *args, **kw)
get_lib_suffix(env, *args, **kw)
get_lib_version(env, *args, **kw)
get_versioned_lib_info_generator(**kw)
property libtype
class SCons.Tool._LibSuffixGenerator(libtype)[source]

Bases: SCons.Tool._LibInfoGeneratorBase

Library suffix generator, used as target_suffix in SharedLibrary and LoadableModule builders

_support_classes = {'ImpLib': <class 'SCons.Tool._ImpLibInfoSupport'>, 'LdMod': <class 'SCons.Tool._LdModInfoSupport'>, 'ShLib': <class 'SCons.Tool._ShLibInfoSupport'>}
generate_versioned_lib_info(env, args, result=None, **kw)
get_lib_prefix(env, *args, **kw)
get_lib_suffix(env, *args, **kw)
get_lib_version(env, *args, **kw)
get_versioned_lib_info_generator(**kw)
property libtype
class SCons.Tool._LibSymlinkGenerator(libtype)[source]

Bases: SCons.Tool._LibInfoGeneratorBase

Library symlink map generator. It generates a list of symlinks that should be created by SharedLibrary or LoadableModule builders

_support_classes = {'ImpLib': <class 'SCons.Tool._ImpLibInfoSupport'>, 'LdMod': <class 'SCons.Tool._LdModInfoSupport'>, 'ShLib': <class 'SCons.Tool._ShLibInfoSupport'>}
generate_versioned_lib_info(env, args, result=None, **kw)
get_lib_prefix(env, *args, **kw)
get_lib_suffix(env, *args, **kw)
get_lib_version(env, *args, **kw)
get_versioned_lib_info_generator(**kw)
property libtype
class SCons.Tool._ShLibInfoSupport[source]

Bases: object

get_lib_prefix(env, *args, **kw)[source]
get_lib_suffix(env, *args, **kw)[source]
get_lib_version(env, *args, **kw)[source]
property libtype
SCons.Tool._call_env_subst(env, string, *args, **kw)[source]
SCons.Tool._call_linker_cb(env, callback, args, result=None)[source]

Returns the result of env[‘LINKCALLBACKS’][callback](args) if env[‘LINKCALLBACKS’] is a dictionary and env[‘LINKCALLBACKS’][callback] is callable. If these conditions are not met, return the value provided as the *result argument. This function is mainly used for generating library info such as versioned suffixes, symlink maps, sonames etc. by delegating the core job to callbacks configured by current linker tool

SCons.Tool.createCFileBuilders(env)[source]

This is a utility function that creates the CFile/CXXFile Builders in an Environment if they are not there already.

If they are there already, we return the existing ones.

This is a separate function because soooo many Tools use this functionality.

The return is a 2-tuple of (CFile, CXXFile)

SCons.Tool.createLoadableModuleBuilder(env)[source]

This is a utility function that creates the LoadableModule Builder in an Environment if it is not there already.

If it is already there, we return the existing one.

SCons.Tool.createObjBuilders(env)[source]

This is a utility function that creates the StaticObject and SharedObject Builders in an Environment if they are not there already.

If they are there already, we return the existing ones.

This is a separate function because soooo many Tools use this functionality.

The return is a 2-tuple of (StaticObject, SharedObject)

SCons.Tool.createProgBuilder(env)[source]

This is a utility function that creates the Program Builder in an Environment if it is not there already.

If it is already there, we return the existing one.

SCons.Tool.createSharedLibBuilder(env)[source]

This is a utility function that creates the SharedLibrary Builder in an Environment if it is not there already.

If it is already there, we return the existing one.

SCons.Tool.createStaticLibBuilder(env)[source]

This is a utility function that creates the StaticLibrary Builder in an Environment if it is not there already.

If it is already there, we return the existing one.

SCons.Tool.find_program_path(env, key_program, default_paths=None)[source]

Find the location of a tool using various means.

Mainly for windows where tools aren’t all installed in /usr/bin, etc.

Parameters
  • env – Current Construction Environment.

  • key_program – Tool to locate.

  • default_paths – List of additional paths this tool might be found in.

SCons.Tool.tool_list(platform, env)[source]