aboutsummaryrefslogtreecommitdiff
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 15:01:53 +0300
commit95d8b8787a2dd01e0abb40f7088e706e204a859f (patch)
tree03d59ea3fe3016f45168ed7b7ccac50bb46be339
parent6b7d43ebe0d77ac85fa2c01e0e358efc64418126 (diff)
downloadmeson-95d8b8787a2dd01e0abb40f7088e706e204a859f.zip
meson-95d8b8787a2dd01e0abb40f7088e706e204a859f.tar.gz
meson-95d8b8787a2dd01e0abb40f7088e706e204a859f.tar.bz2
Be more strict about target names with slashes.
-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 4c5dfbb..7e2a934 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.join(self.subdir, os.path.split(name)[0])
+ 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 180400a..eb50e1b 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."
}
]
}