From 137ed6cf9da11a23084aeedfce1a5816b72d70ee Mon Sep 17 00:00:00 2001 From: Christophe Gouiran Date: Sun, 7 Jan 2018 12:56:14 +0100 Subject: [PATCH] Change handling of not found external programs --- mesonbuild/dependencies/__init__.py | 2 +- mesonbuild/dependencies/base.py | 11 +++++++++++ mesonbuild/interpreter.py | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/mesonbuild/dependencies/__init__.py b/mesonbuild/dependencies/__init__.py index 4dc2b2756..69235dac8 100644 --- a/mesonbuild/dependencies/__init__.py +++ b/mesonbuild/dependencies/__init__.py @@ -13,7 +13,7 @@ # limitations under the License. from .base import ( # noqa: F401 - Dependency, DependencyException, DependencyMethods, ExternalProgram, + Dependency, DependencyException, DependencyMethods, ExternalProgram, NonExistingExternalProgram, ExternalDependency, ExternalLibrary, ExtraFrameworkDependency, InternalDependency, PkgConfigDependency, find_external_dependency, get_dep_identifier, packages, _packages_accept_language) from .dev import GMockDependency, GTestDependency, LLVMDependency, ValgrindDependency diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 0ef33722f..b77c20eea 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -753,6 +753,17 @@ class ExternalProgram: def get_name(self): return self.name +class NonExistingExternalProgram(ExternalProgram): + + def __init__(self): + super().__init__(name = 'nonexistingprogram', silent = True) + + def __repr__(self): + r = '<{} {!r} -> {!r}>' + return r.format(self.__class__.__name__, self.name, self.command) + + def found(self): + return False class ExternalLibrary(ExternalDependency): def __init__(self, name, link_args, environment, language, silent=False): diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 56aee5d4a..b848a6991 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2119,7 +2119,7 @@ to directly access options of other subprojects.''') if required and (progobj is None or not progobj.found()): raise InvalidArguments('Program "%s" not found or not executable' % args[0]) if progobj is None: - return ExternalProgramHolder(dependencies.ExternalProgram('nonexistingprogram')) + return ExternalProgramHolder(dependencies.NonExistingExternalProgram()) return progobj def func_find_library(self, node, args, kwargs):