xpybuild.utils.compilers

Support classes for the C/C++ native compiler chain, used by the xpybuild.targets.native module.

Process

class xpybuild.utils.compilers.Process(environs=None)[source]

Bases: object

Parent type for compiler/tool chain process classes, contain helper method for calling the compiler process

getExpandedEnvirons(context, environs=None)[source]

Return the environment variables to be used for this process, either passed explicitly into this method, or passed into the constructor, or else empty.

Any ${…} substitution vars are expanded automatically.

Compiler

class xpybuild.utils.compilers.Compiler(environs=None)[source]

Bases: xpybuild.utils.compilers.Process

A compiler (of some sort or other)

compile(context, output, src, options, flags=None, includes=None)[source]

output: The object file to create

src: A list of source file paths

options: an options dictionary to override global options

flags: additional flags to pass to the compiler

includes: a list of include directory paths

Depends

class xpybuild.utils.compilers.Depends(environs=None)[source]

Bases: xpybuild.utils.compilers.Process

The command to use to generate a list of dependencies from a list of source files

depends(context, src, options, flags=None, includes=None)[source]

src: A list of source file paths

options: an options dictionary to override global options

flags: additional flags to pass to the compiler

includes: a list of include directory paths

Linker

class xpybuild.utils.compilers.Linker(environs=None)[source]

Bases: xpybuild.utils.compilers.Process

Link a set of object files into an executable or a shared library

output: The library/executable to create

src: A list of object file paths

options: an options dictionary to override global options

flags: additional flags to pass to the compiler

libs: A list of libraries to link against

libdirs: A list of paths to directories that contain libraries

Archiver

class xpybuild.utils.compilers.Archiver(environs=None)[source]

Bases: xpybuild.utils.compilers.Process

A tool to put a set of object files into an archive for static linking. Typically only used on unix.

archive(context, output, src, options)[source]

output: The archive file path to create

src: A list of source object file paths

options: an options dictionary to override global options

ToolChain

class xpybuild.utils.compilers.ToolChain(depends, ccompiler, cxxcompiler, linker, archiver)[source]

Bases: object

A collection of compilers, linkers and other tools which represents a complete native tool chain

depends: A Depends object to get a list of dependencies from a list of source files

ccompiler: A Compiler object for compiling C files

cxxcompiler: A Compiler object for compiling C++ files

linker: A Linker object for linking object files to a shared library or executable

archiver: An Archiver object for making static-link archives

UnixCompiler

class xpybuild.utils.compilers.UnixCompiler(command, outputHandler=None, environs=None)[source]

Bases: xpybuild.utils.compilers.Compiler

A compiler using standard Unix compiler arguments/syntax

command: The path to the compiler

outputHandler: a ProcessOutputHandler to parse the output of the compiler

UnixLinker

class xpybuild.utils.compilers.UnixLinker(command, outputHandler=None, environs=None)[source]

Bases: xpybuild.utils.compilers.Linker

A linker using standard Unix linker arguments/syntax

command: The path to the linker

outputHandler: a ProcessOutputHandler to parse the output of the linker

UnixArchiver

class xpybuild.utils.compilers.UnixArchiver(command, outputHandler=None, environs=None)[source]

Bases: xpybuild.utils.compilers.Archiver

A archiver using standard Unix archiver arguments/syntax

command: The path to the archiver

outputHandler: a ProcessOutputHandler to parse the output of the archiver

GccProcessOutputHandler

class xpybuild.utils.compilers.GccProcessOutputHandler(name, treatStdErrAsErrors=True, **kwargs)[source]

Bases: xpybuild.utils.outputhandler.ProcessOutputHandler

A ProcessOutputHandler than can parse the output of GCC tools

Subclasses must pass any **kwargs down to the super() constructor to allow for new functionality to be added in future.

Parameters
  • name – a short display name for this process or target, used as a prefix for log lines.

  • treatStdErrAsErrors – controls whether all content on stderr (rather than stdout) is treated as an error by default. The correct setting depends on how the process being invoked uses stdout/err.

  • options – a dictionary of resolved option values, in case aspects of this handler are customizable. Available to implementations as self.options (if None is passed, self.options will be an empty dictionary)

GCC

class xpybuild.utils.compilers.GCC(environs=None)[source]

Bases: xpybuild.utils.compilers.ToolChain, xpybuild.utils.compilers.UnixCompiler, xpybuild.utils.compilers.UnixLinker, xpybuild.utils.compilers.Depends

A tool chain based on the GNU Compiler Collection

VisualStudioProcessOutputHandler

class xpybuild.utils.compilers.VisualStudioProcessOutputHandler(name, treatStdErrAsErrors=True, **kwargs)[source]

Bases: xpybuild.utils.outputhandler.ProcessOutputHandler

A ProcessOutputHandler that can parse the output of Visual Studio tools

Subclasses must pass any **kwargs down to the super() constructor to allow for new functionality to be added in future.

Parameters
  • name – a short display name for this process or target, used as a prefix for log lines.

  • treatStdErrAsErrors – controls whether all content on stderr (rather than stdout) is treated as an error by default. The correct setting depends on how the process being invoked uses stdout/err.

  • options – a dictionary of resolved option values, in case aspects of this handler are customizable. Available to implementations as self.options (if None is passed, self.options will be an empty dictionary)

VisualStudio

class xpybuild.utils.compilers.VisualStudio(vsbin)[source]

Bases: xpybuild.utils.compilers.Compiler, xpybuild.utils.compilers.Linker, xpybuild.utils.compilers.Depends, xpybuild.utils.compilers.Archiver, xpybuild.utils.compilers.ToolChain

A ToolChain representing using Visual Studio compilers et al