Skip to content

Commit 81fe701

Browse files
committed
templates: fix --executable
* In 1.7.1, the behaviour of --executable was to just ignore it. * After my recent 9104bb6, 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: #15286
1 parent 69711f3 commit 81fe701

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

mesonbuild/templates/sampleimpl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class FileImpl(SampleImpl):
133133

134134
def __init__(self, args: Arguments):
135135
super().__init__(args)
136-
self.sources = args.srcfiles if args.srcfiles else [Path(f'{self.executable_name}.{self.source_ext}')]
136+
self.sources = args.srcfiles if args.srcfiles else [Path(f'{self.name}.{self.source_ext}')]
137137

138138
def create_executable(self) -> None:
139139
source_name = f'{self.lowercase_token}.{self.source_ext}'

unittests/allplatformstests.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2541,6 +2541,17 @@ def _template_test_fresh(lang, target_type):
25412541
self._run(ninja,
25422542
workdir=os.path.join(tmpdir, 'builddir'))
25432543

2544+
# custom executable name
2545+
if target_type == 'executable':
2546+
with tempfile.TemporaryDirectory() as tmpdir:
2547+
self._run(self.meson_command + ['init', '--language', lang, '--type', target_type,
2548+
'--executable', 'foobar'], workdir=tmpdir)
2549+
self._run(self.setup_command + ['--backend=ninja', 'builddir'],
2550+
workdir=tmpdir)
2551+
self._run(ninja,
2552+
workdir=os.path.join(tmpdir, 'builddir'))
2553+
2554+
25442555
def _template_test_dirty(lang, target_type):
25452556
if is_windows() and lang == 'fortran' and target_type == 'library':
25462557
# non-Gfortran Windows Fortran compilers do not do shared libraries in a Fortran standard way

0 commit comments

Comments
 (0)