diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2022-04-27 19:15:04 -0400 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2022-05-05 20:07:44 -0400 |
commit | 09a26032852a4b4fbab9dcfa819c6958e426b9b1 (patch) | |
tree | a7207e39cd2f55627608c71146645ad91e3dfe98 /mesonbuild/minit.py | |
parent | 557680f7d6b2a2e7c3d0f04fb0d6529ac7a6d475 (diff) | |
download | meson-09a26032852a4b4fbab9dcfa819c6958e426b9b1.zip meson-09a26032852a4b4fbab9dcfa819c6958e426b9b1.tar.gz meson-09a26032852a4b4fbab9dcfa819c6958e426b9b1.tar.bz2 |
minit: refuse to allow creating broken projects
Some executable names are invalid, and while it's unlikely anyone will
specify such a thing using the --executable argument, it's not unlikely
that people experimenting will attempt to use meson init in a directory
named "test".
This then defaults to that for both the project name and the sample
target name, and the latter produces errors when you try to build it.
Fixes #10321
Diffstat (limited to 'mesonbuild/minit.py')
-rw-r--r-- | mesonbuild/minit.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/mesonbuild/minit.py b/mesonbuild/minit.py index 37b82b4..7081563 100644 --- a/mesonbuild/minit.py +++ b/mesonbuild/minit.py @@ -23,6 +23,7 @@ import os import re from glob import glob from mesonbuild import mesonlib +from mesonbuild.coredata import FORBIDDEN_TARGET_NAMES from mesonbuild.environment import detect_ninja from mesonbuild.templates.samplefactory import sameple_generator import typing as T @@ -81,6 +82,9 @@ def autodetect_options(options: 'argparse.Namespace', sample: bool = False) -> N if not options.executable: options.executable = options.name print(f'Using "{options.executable}" (project name) as name of executable to build.') + if options.executable in FORBIDDEN_TARGET_NAMES: + raise mesonlib.MesonException(f'Executable name {options.executable!r} is reserved for Meson internal use. ' + 'Refusing to init an invalid project.') if sample: # The rest of the autodetection is not applicable to generating sample projects. return |