summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2021-10-10 01:30:43 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2021-10-10 01:30:43 +0300
commit95f006fc0111a8bd3aeacdf9ecdebace646bc334 (patch)
tree5a89e4a0ee09871890003f2ab8e734f83fd0a22b
parent329d111709ab5c5140f75f29c7176c9546de5770 (diff)
downloadmeson-stricternames.tar.gz
Be more strict about target names with slashes.stricternames
-rw-r--r--mesonbuild/interpreter/interpreter.py8
-rw-r--r--test cases/failing/52 slashname/test.json2
2 files changed, 9 insertions, 1 deletions
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py
index 4c5dfbb99..8a2a8f46e 100644
--- a/mesonbuild/interpreter/interpreter.py
+++ b/mesonbuild/interpreter/interpreter.py
@@ -2566,6 +2566,14 @@ Try setting b_lundef to false instead.'''.format(self.coredata.options[OptionKey
raise InterpreterException('Target name must not be empty.')
if name.strip() == '':
raise InterpreterException('Target name must not consist only of whitespace.')
+ if has_path_sep(name):
+ pathseg, _ = os.path.split(name)
+ if os.path.exists(os.path.join(self.source_root, pathseg)):
+ raise InvalidArguments(textwrap.dedent(f'''\
+ Target "{name}" has a path segment pointing to directory "{pathseg}". This is an error.
+ To define a target that builds in that directory you must define it
+ in the meson.build file in that directory.
+ '''))
if name.startswith('meson-'):
raise InvalidArguments("Target names starting with 'meson-' are reserved "
"for Meson's internal use. Please rename.")
diff --git a/test cases/failing/52 slashname/test.json b/test cases/failing/52 slashname/test.json
index 180400ae7..eb50e1b83 100644
--- a/test cases/failing/52 slashname/test.json
+++ b/test cases/failing/52 slashname/test.json
@@ -1,7 +1,7 @@
{
"stdout": [
{
- "line": "test cases/failing/52 slashname/meson.build:11:0: ERROR: Problem encountered: Re-enable me once slash in name is finally prohibited."
+ "line": "test cases/failing/52 slashname/meson.build:9:0: ERROR: Target \"sub/prog\" has a path segment pointing to directory \"sub\". This is an error."
}
]
}