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
|
A tool that is part of a compiler suite (typically compiler and linker). |
|
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).
- 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 tosubprocess.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:
RuntimeError – if the code is not available.
RuntimeError – if the return code of the executable is not 0.
- Return type:
- class fab.tools.tool.CompilerSuiteTool(name, exec_name, suite, category)#
A tool that is part of a compiler suite (typically compiler and linker).
- Parameters: