From 381110143493ef12b62e79931002cc77dd47a182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Fri, 19 Jul 2019 14:34:16 +0400 Subject: meson: handle nested disabler Fixes #5659 --- mesonbuild/interpreterbase.py | 21 +++++++++++++-------- test cases/common/164 disabler/meson.build | 1 + 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py index 71a4ef3..b5510cf 100644 --- a/mesonbuild/interpreterbase.py +++ b/mesonbuild/interpreterbase.py @@ -337,20 +337,25 @@ class Disabler(InterpreterObject): def found_method(self, args, kwargs): return False -def is_disabler(i): +def is_disabler(i) -> bool: return isinstance(i, Disabler) -def is_disabled(args, kwargs): +def is_arg_disabled(arg) -> bool: + if is_disabler(arg): + return True + if isinstance(arg, list): + for i in arg: + if is_arg_disabled(i): + return True + return False + +def is_disabled(args, kwargs) -> bool: for i in args: - if isinstance(i, Disabler): + if is_arg_disabled(i): return True for i in kwargs.values(): - if isinstance(i, Disabler): + if is_arg_disabled(i): return True - if isinstance(i, list): - for j in i: - if isinstance(j, Disabler): - return True return False class InterpreterBase: diff --git a/test cases/common/164 disabler/meson.build b/test cases/common/164 disabler/meson.build index a1763d2..9437ace 100644 --- a/test cases/common/164 disabler/meson.build +++ b/test cases/common/164 disabler/meson.build @@ -33,6 +33,7 @@ assert(number == 2, 'If found handled incorrectly, value should be 2 but is @0@' dep = dependency('notfounddep', required : false, disabler : true) app = executable('myapp', 'notfound.c', dependencies : [dep]) +app = executable('myapp', 'notfound.c', dependencies : [[dep]]) cc = meson.get_compiler('c') dep = cc.find_library('notfounddep', required : false, disabler : true) -- cgit v1.1