From 569fe981b08f8fa38ff3533651ceff414decadf4 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Mon, 13 Oct 2025 15:49:24 -0400 Subject: Add common ABC for ExternalProgram and LocalProgram --- mesonbuild/programs.py | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'mesonbuild/programs.py') 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 -- cgit v1.2.3