diff options
| author | Xavier Claessens <xclaessens@netflix.com> | 2025-10-13 15:49:24 -0400 |
|---|---|---|
| committer | Xavier Claessens <xclaesse@gmail.com> | 2025-10-15 12:15:39 -0400 |
| commit | 569fe981b08f8fa38ff3533651ceff414decadf4 (patch) | |
| tree | 75dc96f5ba8fce8bbc8da7d0ce027b573ed20bce /mesonbuild/programs.py | |
| parent | bd33265b04ca609afe6bb895453c5757bbbbb27d (diff) | |
| download | meson-569fe981b08f8fa38ff3533651ceff414decadf4.tar.gz | |
Add common ABC for ExternalProgram and LocalProgram
Diffstat (limited to 'mesonbuild/programs.py')
| -rw-r--r-- | mesonbuild/programs.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/mesonbuild/programs.py b/mesonbuild/programs.py index 80acb98c8..16c12c85a 100644 --- a/mesonbuild/programs.py +++ b/mesonbuild/programs.py @@ -13,6 +13,7 @@ import sys import re import typing as T from pathlib import Path +from abc import ABCMeta, abstractmethod from . import mesonlib from . import mlog @@ -23,7 +24,33 @@ if T.TYPE_CHECKING: from .interpreter import Interpreter -class ExternalProgram(mesonlib.HoldableObject): +class BaseProgram(mesonlib.HoldableObject, metaclass=ABCMeta): + ''' A base class for LocalProgram and ExternalProgram.''' + + name: str + + @abstractmethod + def found(self) -> bool: + pass + + @abstractmethod + def get_version(self, interpreter: T.Optional[Interpreter] = None) -> str: + pass + + @abstractmethod + def get_command(self) -> T.List[str]: + pass + + @abstractmethod + def get_path(self) -> T.Optional[str]: + pass + + @abstractmethod + def description(self) -> str: + '''Human friendly description of the command''' + + +class ExternalProgram(BaseProgram): """A program that is found on the system. :param name: The name of the program |
