:py:mod:`anod.helper` ===================== .. py:module:: anod.helper .. autoapi-nested-parse:: Helpers classes and functions for ANOD. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: anod.helper.Make anod.helper.Configure Functions ~~~~~~~~~ .. autoapisummary:: anod.helper.text_replace Attributes ~~~~~~~~~~ .. autoapisummary:: anod.helper.log .. py:data:: log .. py:class:: 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. .. py:method:: set_var(name: str, value: str | list[str]) -> None Set a Make variable. :param name: name of the variable :param 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 .. py:method:: set_default_target(target: str) -> None Set default make target. :param target: the target name to use if __call__ is called with target=None .. py:method:: __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. :param target: the target to use (use default_target if None) :param jobs: see __init__ documentation :param exec_dir: see __init__ documentation :param timeout: timeout to pass to ex.Run .. py:method:: 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. :param target: optional target or list of targets to use (use default_target if None) :param jobs: see __init__ documentation :param exec_dir: see __init__ documentation :param timeout: timeout to pass to ex.Run :return: 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 .. py:class:: Configure(anod_instance: e3.anod.spec.Anod, src_dir: str | None = None, exec_dir: str | None = None, auto_target: bool = True) Wrapper around ./configure. .. py:method:: add(*args: str) -> None Add configure options. :param args: list of options to pass when calling configure .. py:method:: add_env(key: str, value: str) -> None Set environment variable when calling configure. :param key: environment variable name :param value: environment variable value .. py:method:: cmdline() -> dict Return the configure command line. :return: 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. .. py:method:: __call__() -> e3.os.process.Run Call. .. py:function:: text_replace(filename: str, pattern: list[tuple[bytes | str, bytes | str]]) -> list[int] Replace patterns in a file. :param filename: file path :param 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. :return: the number of substitution performed for each pattern