fab.tools.tool#

This file contains the base class for all tools, i.e. compiler, preprocessor, linker, archiver, Psyclone, rsync, versioning tools.

Each tool belongs to one category (e.g. FORTRAN_COMPILER). This category is used when adding a tool to a ToolRepository or ToolBox. It provides basic support for running a binary, and keeping track if a tool is actually available.

Classes

CompilerSuiteTool(name, exec_name, suite, ...)

A tool that is part of a compiler suite (typically compiler and linker).

Tool(name, exec_name[, category, ...])

This is the base class for all tools.

class fab.tools.tool.Tool(name, exec_name, category=Category.MISC, availablility_option=None)#

This is the base class for all tools. It stores the name of the tool, the name of the executable, and provides a run method.

Parameters:
  • name (str) – name of the tool.

  • exec_name (Union[str, Path]) – name or full path of the executable to start.

  • category (Category) – the Category to which this tool belongs. (default: <Category.MISC: 12>)

  • availability_option – a command line option for the tool to test if the tool is available on the current system. Defaults to –version.

check_available()#

Run a ‘test’ command to check if this tool is available in the system. :rtype: bool :returns: whether the tool is working (True) or not.

property is_available: bool#

Checks if the tool is available or not. It will call a tool-specific function check_available to determine this, but will cache the results to avoid testing a tool more than once.

Returns:

whether the tool is available (i.e. installed and working).

property is_compiler: bool#

Returns whether this tool is a (Fortran or C) compiler or not.

property exec_name: str#
Returns:

the name of the executable.

property name: str#
Returns:

the name of the tool.

property category: Category#
Returns:

the category of this tool.

property flags: Flags#
Returns:

the flags to be used with this tool.

property logger: Logger#
Returns:

a logger object for convenience.

run(additional_parameters=None, env=None, cwd=None, capture_output=True)#

Run the binary as a subprocess.

Parameters:
  • additional_parameters (Union[str, List[Union[Path, str]], None]) – List of strings to be sent to subprocess.run() as the command. (default: None)

  • env (Optional[Dict[str, str]]) – Optional env for the command. By default it will use the current session’s environment. (default: None)

  • capture_output – If True, capture and return stdout. If False, the command will print its output directly to the console. (default: True)

Raises:
Return type:

str

class fab.tools.tool.CompilerSuiteTool(name, exec_name, suite, category)#

A tool that is part of a compiler suite (typically compiler and linker).

Parameters:
  • name (str) – name of the tool.

  • exec_name (Union[str, Path]) – name of the executable to start.

  • suite (str) – name of the compiler suite.

  • category (Category) – the Category to which this tool belongs.

property suite: str#
Returns:

the compiler suite of this tool.