diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2022-05-26 22:49:50 -0400 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2022-05-31 17:49:29 -0400 |
commit | 38c00feb9d2004c05491f52d6ec40f2ed8467b4e (patch) | |
tree | 2ec0065cf2b143f8328cbdada94ff7f29840e363 /mesonbuild | |
parent | dd2f1c4c57874a0efcd9f6d331985c408101c30d (diff) | |
download | meson-38c00feb9d2004c05491f52d6ec40f2ed8467b4e.zip meson-38c00feb9d2004c05491f52d6ec40f2ed8467b4e.tar.gz meson-38c00feb9d2004c05491f52d6ec40f2ed8467b4e.tar.bz2 |
relax target name restrictions to cater to internal use
We don't want to allow targets that conflict with:
- our aliased meson-* targets for phony commands
- any meson-*/ directories we create for internal purposes
We do want to allow targets such as:
- our own meson-*.X manpages
There are a couple routes we could take.
Using a better restriction, such as `meson-internal__*`, is trivially
done for our aliased targets, but changing directory names is...
awkward. We probably cannot do this, and doing the former but not the
latter is not very useful.
We could also carefully allow patterns we know we won't use, such as
file extensions, but which the manpages need, which works for our
directories and for many aliased targets, but run_target() is
user-specified and can be anything.
Use a hybrid approach to cover both use cases. We will now allow target
names that fulfill *all* the following criteria:
- it begins with "meson-"
- it doesn't continue with "internal__"
- it has a file extension
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 4 | ||||
-rw-r--r-- | mesonbuild/interpreter/interpreter.py | 7 |
2 files changed, 7 insertions, 4 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index c6f82e3..5c77dc2 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -442,10 +442,10 @@ class NinjaBackend(backends.Backend): 'benchmark', etc, and also for RunTargets. https://github.com/mesonbuild/meson/issues/1644 ''' - if dummy_outfile.startswith('meson-'): + if dummy_outfile.startswith('meson-internal__'): raise AssertionError(f'Invalid usage of create_phony_target with {dummy_outfile!r}') - to_name = f'meson-{dummy_outfile}' + to_name = f'meson-internal__{dummy_outfile}' elem = NinjaBuildElement(all_outputs, dummy_outfile, 'phony', to_name) self.add_build(elem) diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index af83c0e54..53e819b 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -2927,9 +2927,12 @@ Try setting b_lundef to false instead.'''.format(self.coredata.options[OptionKey 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 " + if name.startswith('meson-internal__'): + raise InvalidArguments("Target names starting with 'meson-internal__' are reserved " "for Meson's internal use. Please rename.") + if name.startswith('meson-') and '.' not in name: + raise InvalidArguments("Target names starting with 'meson-' and without a file extension " + "are reserved for Meson's internal use. Please rename.") if name in coredata.FORBIDDEN_TARGET_NAMES: raise InvalidArguments(f"Target name '{name}' is reserved for Meson's " "internal use. Please rename.") |