anod.helper
¶
Helpers classes and functions for ANOD.
Module Contents¶
Classes¶
Wrapper around GNU Make. |
|
Wrapper around ./configure. |
Functions¶
|
Replace patterns in a file. |
Attributes¶
- anod.helper.log¶
- class anod.helper.Make(anod_instance: e3.anod.spec.Anod, makefile: str | None = None, exec_dir: str | None = None, jobs: int | None = None, make_exe: str = 'make')¶
Wrapper around GNU Make.
- set_var(name: str, value: str | list[str]) None ¶
Set a Make variable.
- Parameters:
name – name of the variable
value – value of the variable, can be a string or a list if it’s the list, it will be stored in a string with each value separated by a space character
- set_default_target(target: str) None ¶
Set default make target.
- Parameters:
target – the target name to use if __call__ is called with target=None
- __call__(target: str | None = None, jobs: int | None = None, exec_dir: str | None = None, timeout: float | None = None) e3.os.process.Run ¶
Call a make target.
- Parameters:
target – the target to use (use default_target if None)
jobs – see __init__ documentation
exec_dir – see __init__ documentation
timeout – timeout to pass to ex.Run
- cmdline(target: str | list[str] | None = None, jobs: int | None = None, exec_dir: str | None = None, timeout: float | None = None) dict[str, list[str] | dict] ¶
Return the make command line.
- Parameters:
target – optional target or list of targets to use (use default_target if None)
jobs – see __init__ documentation
exec_dir – see __init__ documentation
timeout – timeout to pass to ex.Run
- Returns:
a dictionary with the following keys - cmd: containing the command line to pass to gnatpython.ex.Run - options: options to pass to gnatpython.ex.Run
- class anod.helper.Configure(anod_instance: e3.anod.spec.Anod, src_dir: str | None = None, exec_dir: str | None = None, auto_target: bool = True)¶
Wrapper around ./configure.
- add(*args: str) None ¶
Add configure options.
- Parameters:
args – list of options to pass when calling configure
- add_env(key: str, value: str) None ¶
Set environment variable when calling configure.
- Parameters:
key – environment variable name
value – environment variable value
- cmdline() dict ¶
Return the configure command line.
- Returns:
a dictionary with the following keys - cmd: containing the command line to pass to gnatpython.ex.Run - options: options to pass to gnatpython.ex.Run
If CONFIG_SHELL environment variable is set, the configure will be called with this shell.
- __call__() e3.os.process.Run ¶
- anod.helper.text_replace(filename: str, pattern: list[tuple[bytes | str, bytes | str]]) list[int] ¶
Replace patterns in a file.
- Parameters:
filename – file path
pattern – list of tuple (pattern, replacement)
Do not modify the file if no substitution is done. Note that substitutions are applied sequentially (order provided by the list pattern) and this is done line per line.
- Returns:
the number of substitution performed for each pattern