diff options
| author | Sam James <sam@gentoo.org> | 2025-11-23 20:14:42 +0000 |
|---|---|---|
| committer | Jussi Pakkanen <jussi.pakkanen@mailbox.org> | 2025-12-01 16:55:18 +0200 |
| commit | 6419b22f6183d87c92d42bd3a99aa2787cb13e08 (patch) | |
| tree | 4905fdfce792e21752761e065b0cbff6f62eff99 | |
| parent | b3a0f9ce6147b5b2f6fbfdb257138e1f3a796086 (diff) | |
| download | meson-6419b22f6183d87c92d42bd3a99aa2787cb13e08.tar.gz | |
templates: fix --executable
* In 1.7.1, the behaviour of --executable was to just ignore it.
* After my recent 9104bb616766bd9a05f0b2f280359463d32e227d, the behaviour
was that we'd require, for --executable xyz, xyz.c to exist or we'd
fail to generate.
Neither are good! Instead, create the sample source file w/ the project
name, but call the executable whatever the user passed with `--executable`.
Bug: https://github.com/mesonbuild/meson/issues/15286
| -rw-r--r-- | mesonbuild/templates/sampleimpl.py | 2 | ||||
| -rw-r--r-- | unittests/allplatformstests.py | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/mesonbuild/templates/sampleimpl.py b/mesonbuild/templates/sampleimpl.py index 00735c498..46f9a70aa 100644 --- a/mesonbuild/templates/sampleimpl.py +++ b/mesonbuild/templates/sampleimpl.py @@ -133,7 +133,7 @@ class FileImpl(SampleImpl): def __init__(self, args: Arguments): super().__init__(args) - self.sources = args.srcfiles if args.srcfiles else [Path(f'{self.executable_name}.{self.source_ext}')] + self.sources = args.srcfiles if args.srcfiles else [Path(f'{self.name}.{self.source_ext}')] def create_executable(self) -> None: source_name = f'{self.lowercase_token}.{self.source_ext}' diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py index 2c5123281..554217043 100644 --- a/unittests/allplatformstests.py +++ b/unittests/allplatformstests.py @@ -2541,6 +2541,20 @@ class AllPlatformTests(BasePlatformTests): self._run(ninja, workdir=os.path.join(tmpdir, 'builddir')) + # custom executable name + if target_type == 'executable': + with tempfile.TemporaryDirectory() as tmpdir: + self._run(self.meson_command + ['init', '--language', lang, '--type', target_type, + '--executable', 'foobar'], workdir=tmpdir) + self._run(self.setup_command + ['--backend=ninja', 'builddir'], + workdir=tmpdir) + self._run(ninja, + workdir=os.path.join(tmpdir, 'builddir')) + + if lang not in {'cs', 'java'}: + exe = os.path.join(tmpdir, 'builddir', 'foobar' + exe_suffix) + self.assertTrue(os.path.exists(exe)) + def _template_test_dirty(lang, target_type): if is_windows() and lang == 'fortran' and target_type == 'library': # non-Gfortran Windows Fortran compilers do not do shared libraries in a Fortran standard way |
