From 218ed2de89c3729e9d8d6a5d8e80e0a9461714ca Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Sun, 13 May 2018 10:36:58 -0400 Subject: [PATCH] optinterpreter: Remove duplicated list of languages It is important to keep the list of languages up to date in optinterpreter, otherwise we could have conflicting options when adding new languages. --- mesonbuild/compilers/__init__.py | 2 ++ mesonbuild/compilers/compilers.py | 1 + mesonbuild/optinterpreter.py | 15 ++------------- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/mesonbuild/compilers/__init__.py b/mesonbuild/compilers/__init__.py index 6b31ccac1..849e229f3 100644 --- a/mesonbuild/compilers/__init__.py +++ b/mesonbuild/compilers/__init__.py @@ -25,6 +25,7 @@ __all__ = [ 'ICC_STANDARD', 'ICC_WIN', + 'all_languages', 'base_options', 'clike_langs', 'c_suffixes', @@ -99,6 +100,7 @@ from .compilers import ( ICC_OSX, ICC_WIN, ICC_STANDARD, + all_languages, base_options, clike_langs, c_suffixes, diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index b61398fbe..a9ab29e81 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -45,6 +45,7 @@ lang_suffixes = { 'swift': ('swift',), 'java': ('java',), } +all_languages = lang_suffixes.keys() cpp_suffixes = lang_suffixes['cpp'] + ('h',) c_suffixes = lang_suffixes['c'] + ('h',) # List of languages that can be linked with C code directly by the linker diff --git a/mesonbuild/optinterpreter.py b/mesonbuild/optinterpreter.py index 3da5dadac..7455c484e 100644 --- a/mesonbuild/optinterpreter.py +++ b/mesonbuild/optinterpreter.py @@ -20,21 +20,10 @@ from . import mparser from . import coredata from . import mesonlib from .interpreterbase import FeatureNew +from . import compilers forbidden_option_names = coredata.get_builtin_options() -forbidden_prefixes = {'c_', - 'cpp_', - 'd_', - 'rust_', - 'fortran_', - 'objc_', - 'objcpp_', - 'vala_', - 'csharp_', - 'swift_', - 'b_', - 'backend_', - } +forbidden_prefixes = [lang + '_' for lang in compilers.all_languages] + ['b_', 'backend_'] def is_invalid_name(name): if name in forbidden_option_names: