aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/optinterpreter.py
diff options
context:
space:
mode:
authorHemmo Nieminen <hemmo.nieminen@iki.fi>2018-02-12 20:57:23 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2018-02-16 00:09:47 +0200
commitff1146bc8c3b489fafce5746ce9d3c5f1d80fd96 (patch)
tree83ffcc446fe3ed335d5820df1cf0efee13a81019 /mesonbuild/optinterpreter.py
parentb06a4901cb7f062e57dcd5b8193271031ca36c62 (diff)
downloadmeson-ff1146bc8c3b489fafce5746ce9d3c5f1d80fd96.zip
meson-ff1146bc8c3b489fafce5746ce9d3c5f1d80fd96.tar.gz
meson-ff1146bc8c3b489fafce5746ce9d3c5f1d80fd96.tar.bz2
Fix subproject prefix handling when checking subproject option validity.
Diffstat (limited to 'mesonbuild/optinterpreter.py')
-rw-r--r--mesonbuild/optinterpreter.py33
1 files changed, 25 insertions, 8 deletions
diff --git a/mesonbuild/optinterpreter.py b/mesonbuild/optinterpreter.py
index d4ea06a..16eaf78 100644
--- a/mesonbuild/optinterpreter.py
+++ b/mesonbuild/optinterpreter.py
@@ -154,6 +154,30 @@ class OptionInterpreter:
continue
self.cmd_line_options[key] = value
+ def get_bad_options(self):
+ subproj_len = len(self.subproject)
+ if subproj_len > 0:
+ subproj_len += 1
+ retval = []
+ # The options need to be sorted (e.g. here) to get consistent
+ # error messages (on all platforms) which is required by some test
+ # cases that check (also) the order of these options.
+ for option in sorted(self.cmd_line_options):
+ if option in list(self.options) + forbidden_option_names:
+ continue
+ if any(option[subproj_len:].startswith(p) for p in forbidden_prefixes):
+ continue
+ retval += [option]
+ return retval
+
+ def check_for_bad_options(self):
+ bad = self.get_bad_options()
+ if bad:
+ sub = 'In subproject {}: '.format(self.subproject) if self.subproject else ''
+ mlog.warning(
+ '{}Unknown command line options: "{}"\n'
+ 'This will become a hard error in a future Meson release.'.format(sub, ', '.join(bad)))
+
def process(self, option_file):
try:
with open(option_file, 'r', encoding='utf8') as f:
@@ -173,14 +197,7 @@ class OptionInterpreter:
e.colno = cur.colno
e.file = os.path.join('meson_options.txt')
raise e
- bad = [o for o in sorted(self.cmd_line_options) if not
- (o in list(self.options) + forbidden_option_names or
- any(o.startswith(p) for p in forbidden_prefixes))]
- if bad:
- sub = 'In subproject {}: '.format(self.subproject) if self.subproject else ''
- mlog.warning(
- '{}Unknown command line options: "{}"\n'
- 'This will become a hard error in a future Meson release.'.format(sub, ', '.join(bad)))
+ self.check_for_bad_options()
def reduce_single(self, arg):
if isinstance(arg, str):