Blob Blame History Raw
From 7d25a2d488f56876988ed6cb648f4d65a7ef5ce1 Mon Sep 17 00:00:00 2001
From: Nirbheek Chauhan <nirbheek@centricular.com>
Date: Wed, 25 Jul 2018 18:33:53 +0530
Subject: [PATCH 4/5] Add a feature-new entry for UserFeatureOption

Since we can't detect it in meson_options.txt, detect it when the
option is used.

(cherry picked from commit 0ea21d7aea28c56f37fc37bda31031a6ecb5d6ae)
---
 mesonbuild/interpreter.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 833e982e..29686f4e 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -92,12 +92,13 @@ class FeatureOptionHolder(InterpreterObject, ObjectHolder):
     def auto_method(self, args, kwargs):
         return self.held_object.is_auto()
 
-def extract_required_kwarg(kwargs):
+def extract_required_kwarg(kwargs, subproject):
     val = kwargs.get('required', True)
     disabled = False
     required = False
     feature = None
     if isinstance(val, FeatureOptionHolder):
+        FeatureNew('User option "feature"', '0.47.0').use(subproject)
         option = val.held_object
         feature = val.name
         if option.is_disabled():
@@ -1412,7 +1413,7 @@ class CompilerHolder(InterpreterObject):
         if not isinstance(libname, str):
             raise InterpreterException('Library name not a string.')
 
-        disabled, required, feature = extract_required_kwarg(kwargs)
+        disabled, required, feature = extract_required_kwarg(kwargs, self.subproject)
         if disabled:
             mlog.log('Library', mlog.bold(libname), 'skipped: feature', mlog.bold(feature), 'disabled')
             lib = dependencies.ExternalLibrary(libname, None,
@@ -2458,7 +2459,7 @@ external dependencies (including libraries) must go to "dependencies".''')
     @permittedKwargs(permitted_kwargs['add_languages'])
     @stringArgs
     def func_add_languages(self, node, args, kwargs):
-        disabled, required, feature = extract_required_kwarg(kwargs)
+        disabled, required, feature = extract_required_kwarg(kwargs, self.subproject)
         if disabled:
             for lang in sorted(args, key=compilers.sort_clink):
                 mlog.log('Compiler for language', mlog.bold(lang), 'skipped: feature', mlog.bold(feature), 'disabled')
@@ -2719,7 +2720,7 @@ external dependencies (including libraries) must go to "dependencies".''')
         if not args:
             raise InterpreterException('No program name specified.')
 
-        disabled, required, feature = extract_required_kwarg(kwargs)
+        disabled, required, feature = extract_required_kwarg(kwargs, self.subproject)
         if disabled:
             mlog.log('Program', mlog.bold(' '.join(args)), 'skipped: feature', mlog.bold(feature), 'disabled')
             return ExternalProgramHolder(dependencies.NonExistingExternalProgram())
@@ -2834,7 +2835,7 @@ external dependencies (including libraries) must go to "dependencies".''')
         name = args[0]
         display_name = name if name else '(anonymous)'
 
-        disabled, required, feature = extract_required_kwarg(kwargs)
+        disabled, required, feature = extract_required_kwarg(kwargs, self.subproject)
         if disabled:
             mlog.log('Dependency', mlog.bold(display_name), 'skipped: feature', mlog.bold(feature), 'disabled')
             return DependencyHolder(NotFoundDependency(self.environment), self.subproject)
-- 
2.18.0