mmeson.meson_interface module

Module containing Meson-related classes and funtions.

class mmeson.meson_interface.ExitAction(value)

Bases: Enum

Enum for the exit action. TODO more explaination.

NOTHING = 'nothing'

Exit without saving the changed config values.

ONLY_CONFIGURE = 'only-configure'

Exit without saving the changed config values.

RECONFIGURE = 'reconfigure'

Same as ONLY_CONFIGURE but calls meson setup --reconfigure afterwards.

class mmeson.meson_interface.MesonManager(*args, **kwargs)

Bases: object

Singleton class managing Meson-related parsing and actions.

builddir

pathlib.Path containing the builddir (has to be set via set_builddir()).

meson_bin

str pointing to the Meson binary (has to be set via set_meson_bin()).

exit_action

see ExitAction for details.

set_builddir(builddir: Path)

Sets the builddir of the Meson project.

Parameters

builddirpathlib.Path pointing to the builddir.

set_meson_bin(meson_bin: str)

Sets the Meson binary to use.

Parameters

meson_bin – Name of the Meson binary in PATH or path to Meson binary as str.

get_intro_file(intro_file: str) dict

Loads and introspection file from the meson-info folder and parses the json into a dict.

Parameters

intro_file – Name of the introspection file.

Returns

The dict contained in the introspection file.

parse_buildoptions() list[mmeson.options.Option]

Parses the build options given by Meson in the builddir.

Returns

List of Option parsed from the builddir.

parse_projectinfo() tuple[str, str]

Parses the project info given by Meson in the builddir.

Returns

Tuple of strings containing the project name and project version.

parse_meson_version() str

Parses the meson version given by Meson in the builddir.

Returns

String containing the used meson version.

parse_meson_workdir() Path

Parses the meson source folder given by Meson in the builddir.

Returns

pathlib.Path containing path to the source folder.

set_exit_action(exit_action: ExitAction) None

Sets the action to be done when run_exit_action() is called.

Parameters

exit_action – see ExitAction for details.

run_exit_action() int

Runs the exit action. For exact behaviour see ExitAction for details.

Returns

Return code from the last Meson call or 0 if Meson is never called.