aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/optinterpreter.py9
-rwxr-xr-xrun_unittests.py19
-rw-r--r--test cases/unit/19 bad command line options/meson.build17
-rw-r--r--test cases/unit/19 bad command line options/meson_options.txt16
-rw-r--r--test cases/unit/19 bad command line options/subprojects/one/meson.build15
-rw-r--r--test cases/unit/19 bad command line options/subprojects/one/meson_options.txt15
6 files changed, 91 insertions, 0 deletions
diff --git a/mesonbuild/optinterpreter.py b/mesonbuild/optinterpreter.py
index f8ccbe6..df945ab 100644
--- a/mesonbuild/optinterpreter.py
+++ b/mesonbuild/optinterpreter.py
@@ -15,6 +15,7 @@
import os, re
import functools
+from . import mlog
from . import mparser
from . import coredata
from . import mesonlib
@@ -146,6 +147,14 @@ 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)))
def reduce_single(self, arg):
if isinstance(arg, str):
diff --git a/run_unittests.py b/run_unittests.py
index d7d5ed0..9706b45 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -1782,6 +1782,25 @@ class FailureTests(BasePlatformTests):
'''
self.assertMesonRaises(code, "Method.*configtool.*is invalid.*internal")
+ def test_bad_option(self):
+ tdir = os.path.join(self.unit_test_dir, '19 bad command line options')
+ os.environ['MESON_FORCE_BACKTRACE'] = '1'
+ self.init(tdir, extra_args=['-Dopt=bar', '-Dc_args=-Wall'], inprocess=True)
+ self.wipe()
+ out = self.init(tdir, extra_args=['-Dfoo=bar', '-Dbad=true'], inprocess=True)
+ self.assertRegex(
+ out, r'Unknown command line options: "bad, foo"')
+
+ def test_bad_option_subproject(self):
+ tdir = os.path.join(self.unit_test_dir, '19 bad command line options')
+ os.environ['MESON_FORCE_BACKTRACE'] = '1'
+ self.init(tdir, extra_args=['-Done:one=bar'], inprocess=True)
+ self.wipe()
+ out = self.init(tdir, extra_args=['-Done:two=bar'], inprocess=True)
+ self.assertRegex(
+ out,
+ r'In subproject one: Unknown command line options: "one:two"')
+
class WindowsTests(BasePlatformTests):
'''
diff --git a/test cases/unit/19 bad command line options/meson.build b/test cases/unit/19 bad command line options/meson.build
new file mode 100644
index 0000000..b1670c0
--- /dev/null
+++ b/test cases/unit/19 bad command line options/meson.build
@@ -0,0 +1,17 @@
+# Copyright © 2017 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+project('Bad command line options')
+
+one = subproject('one')
diff --git a/test cases/unit/19 bad command line options/meson_options.txt b/test cases/unit/19 bad command line options/meson_options.txt
new file mode 100644
index 0000000..fc09712
--- /dev/null
+++ b/test cases/unit/19 bad command line options/meson_options.txt
@@ -0,0 +1,16 @@
+# Copyright © 2017 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+option('opt', type : 'string', description : 'An argument')
+option('good', type : 'boolean', value : true, description : 'another argument')
diff --git a/test cases/unit/19 bad command line options/subprojects/one/meson.build b/test cases/unit/19 bad command line options/subprojects/one/meson.build
new file mode 100644
index 0000000..39ae07e
--- /dev/null
+++ b/test cases/unit/19 bad command line options/subprojects/one/meson.build
@@ -0,0 +1,15 @@
+# Copyright © 2017 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+project('one subproject')
diff --git a/test cases/unit/19 bad command line options/subprojects/one/meson_options.txt b/test cases/unit/19 bad command line options/subprojects/one/meson_options.txt
new file mode 100644
index 0000000..7d90fae
--- /dev/null
+++ b/test cases/unit/19 bad command line options/subprojects/one/meson_options.txt
@@ -0,0 +1,15 @@
+# Copyright © 2017 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+option('one', type : 'string', description : 'an option')