SCons.Tool package#

Module contents#

SCons tool selection.

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 specifications.

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]#
SCons.Tool.FindAllTools(tools, env)[source]#
SCons.Tool.FindTool(tools, env)[source]#
SCons.Tool.Initializers(env) None[source]#
class SCons.Tool.Tool(name, toolpath=None, **kwargs)[source]#

Bases: object

_tool_module()[source]#

Try to load a tool module.

This will hunt in the toolpath for both a Python file (toolname.py) and a Python module (toolname directory), then try the regular import machinery, then fallback to try a zipfile.

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) None[source]#

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

remove_methods(env) None[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.

__call__(env, *args, **kw)[source]#
get_builder(env)[source]#

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

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, loadable_module_suffix: str = '$_LDMODULESUFFIX')[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.

Parameters:

loadable_module_suffix – The suffix specified for the loadable module builder

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, shlib_suffix: str = '$_SHLIBSUFFIX')[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.

Parameters:

shlib_suffix – The suffix specified for the shared library builder

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, add_path: bool = False) str | 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.

  • add_path – If true, add path found if it was from default_paths.

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