Be more strict about target names with slashes.

pull/9354/head
Jussi Pakkanen 3 years ago
parent 6b7d43ebe0
commit 95d8b8787a
  1. 8
      mesonbuild/interpreter/interpreter.py
  2. 2
      test cases/failing/52 slashname/test.json

@ -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.")

@ -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."
}
]
}

Loading…
Cancel
Save