From 0e9241a5d08ab1fb622df31efb863b522062e84f Mon Sep 17 00:00:00 2001 From: Sam James Date: Sun, 23 Nov 2025 20:02:33 +0000 Subject: [PATCH 1/5] templates: refactor tests to have a bit less nesting Use `itertools.product()` to reduce an indentation level or two, though we lose one again by changing to a function for fresh vs dirty. I plan on adding more to these tests and it makes it a bit more manageable. Best-viewed-with: --ignore-all-space --- unittests/allplatformstests.py | 128 +++++++++++++++++++-------------- 1 file changed, 74 insertions(+), 54 deletions(-) diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py index 34b2f98fede5..2c5123281b1f 100644 --- a/unittests/allplatformstests.py +++ b/unittests/allplatformstests.py @@ -2,6 +2,7 @@ # Copyright 2016-2021 The Meson development team # Copyright © 2023-2025 Intel Corporation +import itertools import subprocess import re import json @@ -2523,61 +2524,80 @@ def test_templates(self): if is_osx(): langs = [l for l in langs if l != 'd'] - for lang in langs: - for target_type in ('executable', 'library'): - with self.subTest(f'Language: {lang}; type: {target_type}; fresh: yes'): - 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 - # see "test cases/fortran/6 dynamic" - fc = detect_compiler_for(env, 'fortran', MachineChoice.HOST, True, '') - if fc.get_id() in {'intel-cl', 'pgi'}: - continue - # test empty directory - with tempfile.TemporaryDirectory() as tmpdir: - self._run(self.meson_command + ['init', '--language', lang, '--type', target_type], - workdir=tmpdir) - self._run(self.setup_command + ['--backend=ninja', 'builddir'], - workdir=tmpdir) + def _template_test_fresh(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 + # see "test cases/fortran/6 dynamic" + fc = detect_compiler_for(env, 'fortran', MachineChoice.HOST, True, '') + if fc.get_id() in {'intel-cl', 'pgi'}: + return + + # test empty directory + with tempfile.TemporaryDirectory() as tmpdir: + self._run(self.meson_command + ['init', '--language', lang, '--type', target_type], + workdir=tmpdir) + self._run(self.setup_command + ['--backend=ninja', 'builddir'], + workdir=tmpdir) + self._run(ninja, + workdir=os.path.join(tmpdir, 'builddir')) + + 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 + # see "test cases/fortran/6 dynamic" + fc = detect_compiler_for(env, 'fortran', MachineChoice.HOST, True, '') + if fc.get_id() in {'intel-cl', 'pgi'}: + return + + # test empty directory + with tempfile.TemporaryDirectory() as tmpdir: + self._run(self.meson_command + ['init', '--language', lang, '--type', target_type], + workdir=tmpdir) + self._run(self.setup_command + ['--backend=ninja', 'builddir'], + workdir=tmpdir) + self._run(ninja, + workdir=os.path.join(tmpdir, 'builddir')) + + # test directory with existing code file + if lang in {'c', 'cpp', 'd'}: + with tempfile.TemporaryDirectory() as tmpdir: + with open(os.path.join(tmpdir, 'foo.' + lang), 'w', encoding='utf-8') as f: + f.write('int main(void) {}') + self._run(self.meson_command + ['init', '-b'], workdir=tmpdir) + + # Check for whether we're doing source collection by repeating + # with a bogus file we should pick up (and then fail to compile). + with tempfile.TemporaryDirectory() as tmpdir: + with open(os.path.join(tmpdir, 'bar.' + lang), 'w', encoding='utf-8') as f: + f.write('#error bar') + self._run(self.meson_command + ['init'], workdir=tmpdir) + self._run(self.setup_command + ['--backend=ninja', 'builddir'], + workdir=tmpdir) + with self.assertRaises(subprocess.CalledProcessError): + self._run(ninja, + workdir=os.path.join(tmpdir, 'builddir')) + + elif lang in {'java'}: + with tempfile.TemporaryDirectory() as tmpdir: + with open(os.path.join(tmpdir, 'Foo.' + lang), 'w', encoding='utf-8') as f: + f.write('public class Foo { public static void main() {} }') + self._run(self.meson_command + ['init', '-b'], workdir=tmpdir) + + # Check for whether we're doing source collection by repeating + # with a bogus file we should pick up (and then fail to compile). + with tempfile.TemporaryDirectory() as tmpdir: + with open(os.path.join(tmpdir, 'Bar.' + lang), 'w', encoding='utf-8') as f: + f.write('public class Bar { public private static void main() {} }') + self._run(self.meson_command + ['init'], workdir=tmpdir) + self._run(self.setup_command + ['--backend=ninja', 'builddir'], + workdir=tmpdir) + with self.assertRaises(subprocess.CalledProcessError): self._run(ninja, - workdir=os.path.join(tmpdir, 'builddir')) - - with self.subTest(f'Language: {lang}; type: {target_type}; fresh: no'): - # test directory with existing code file - if lang in {'c', 'cpp', 'd'}: - with tempfile.TemporaryDirectory() as tmpdir: - with open(os.path.join(tmpdir, 'foo.' + lang), 'w', encoding='utf-8') as f: - f.write('int main(void) {}') - self._run(self.meson_command + ['init', '-b'], workdir=tmpdir) - - # Check for whether we're doing source collection by repeating - # with a bogus file we should pick up (and then fail to compile). - with tempfile.TemporaryDirectory() as tmpdir: - with open(os.path.join(tmpdir, 'bar.' + lang), 'w', encoding='utf-8') as f: - f.write('#error bar') - self._run(self.meson_command + ['init'], workdir=tmpdir) - self._run(self.setup_command + ['--backend=ninja', 'builddir'], - workdir=tmpdir) - with self.assertRaises(subprocess.CalledProcessError): - self._run(ninja, - workdir=os.path.join(tmpdir, 'builddir')) - - elif lang in {'java'}: - with tempfile.TemporaryDirectory() as tmpdir: - with open(os.path.join(tmpdir, 'Foo.' + lang), 'w', encoding='utf-8') as f: - f.write('public class Foo { public static void main() {} }') - self._run(self.meson_command + ['init', '-b'], workdir=tmpdir) - - # Check for whether we're doing source collection by repeating - # with a bogus file we should pick up (and then fail to compile). - with tempfile.TemporaryDirectory() as tmpdir: - with open(os.path.join(tmpdir, 'Bar.' + lang), 'w', encoding='utf-8') as f: - f.write('public class Bar { public private static void main() {} }') - self._run(self.meson_command + ['init'], workdir=tmpdir) - self._run(self.setup_command + ['--backend=ninja', 'builddir'], - workdir=tmpdir) - with self.assertRaises(subprocess.CalledProcessError): - self._run(ninja, - workdir=os.path.join(tmpdir, 'builddir')) + workdir=os.path.join(tmpdir, 'builddir')) + + for lang, target_type, fresh in itertools.product(langs, ('executable', 'library'), (True, False)): + with self.subTest(f'Language: {lang}; type: {target_type}; fresh: {fresh}'): + _template_test_fresh(lang, target_type) if fresh else _template_test_dirty(lang, target_type) def test_compiler_run_command(self): ''' From e25c12f6fdcc5d6a1de9776c1db09623b32720dd Mon Sep 17 00:00:00 2001 From: Sam James Date: Sun, 23 Nov 2025 20:14:42 +0000 Subject: [PATCH 2/5] 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 --- mesonbuild/templates/sampleimpl.py | 2 +- unittests/allplatformstests.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/mesonbuild/templates/sampleimpl.py b/mesonbuild/templates/sampleimpl.py index 00735c498995..46f9a70aa3df 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 2c5123281b1f..55421704365d 100644 --- a/unittests/allplatformstests.py +++ b/unittests/allplatformstests.py @@ -2541,6 +2541,20 @@ def _template_test_fresh(lang, target_type): 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 From 47ad66dd83ddd6c7d1d29b3a52043825a3f33fcf Mon Sep 17 00:00:00 2001 From: Sam James Date: Sun, 23 Nov 2025 20:37:33 +0000 Subject: [PATCH 3/5] templates: sort langs in test --- unittests/allplatformstests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py index 55421704365d..93fde1824bb3 100644 --- a/unittests/allplatformstests.py +++ b/unittests/allplatformstests.py @@ -2510,7 +2510,7 @@ def test_templates(self): langs = ['c'] env = get_fake_env() - for l in ['cpp', 'cs', 'd', 'java', 'cuda', 'fortran', 'objc', 'objcpp', 'rust', 'vala']: + for l in ['cpp', 'cs', 'cuda', 'd', 'fortran', 'java', 'objc', 'objcpp', 'rust', 'vala']: try: comp = detect_compiler_for(env, l, MachineChoice.HOST, True, '') with tempfile.TemporaryDirectory() as d: From 1d8b3e7a868633b0c2e0d4549e79f8f5925ef3e9 Mon Sep 17 00:00:00 2001 From: Sam James Date: Sun, 23 Nov 2025 20:52:21 +0000 Subject: [PATCH 4/5] templates: fix remaining languages for source file discovery too I missed this in 9104bb616766bd9a05f0b2f280359463d32e227d as we were only testing whitelisted languages for source file discovery. Tests now handle all of these by using the map we have in compilers, as we need to know the suffix to use for the invalid source files we inject. Note that for tests, we mix explicit --lang in some cases and not others, which we could probably do better with. For these 'must fail' tests, I've stuck with explicit `--lang` to make sure we're testing what we want, but the others are perhaps up for debate. Bug: https://github.com/mesonbuild/meson/issues/15286 --- mesonbuild/templates/cstemplates.py | 12 +++++-- mesonbuild/templates/cudatemplates.py | 12 +++++-- mesonbuild/templates/fortrantemplates.py | 12 +++++-- mesonbuild/templates/objcpptemplates.py | 12 +++++-- mesonbuild/templates/objctemplates.py | 12 +++++-- mesonbuild/templates/rusttemplates.py | 12 +++++-- mesonbuild/templates/valatemplates.py | 11 +++++-- unittests/allplatformstests.py | 42 ++++++++++-------------- 8 files changed, 86 insertions(+), 39 deletions(-) diff --git a/mesonbuild/templates/cstemplates.py b/mesonbuild/templates/cstemplates.py index 59c718953271..297d9b1d44ee 100644 --- a/mesonbuild/templates/cstemplates.py +++ b/mesonbuild/templates/cstemplates.py @@ -35,9 +35,13 @@ dependencies = [{dependencies} ] +sources = [{source_files} + +] + exe = executable( '{exe_name}', - '{source_name}', + [sources], install : true, dependencies : dependencies, ) @@ -83,9 +87,13 @@ dependencies = [{dependencies} ] +sources = [{source_files} + +] + stlib = shared_library( '{lib_name}', - '{source_file}', + [sources], dependencies : dependencies, install : true, ) diff --git a/mesonbuild/templates/cudatemplates.py b/mesonbuild/templates/cudatemplates.py index 252f44a276a9..45cd155f9077 100644 --- a/mesonbuild/templates/cudatemplates.py +++ b/mesonbuild/templates/cudatemplates.py @@ -36,9 +36,13 @@ dependencies = [{dependencies} ] +sources = [{source_files} + +] + exe = executable( '{exe_name}', - '{source_name}', + [sources], dependencies : dependencies, install : true, ) @@ -122,9 +126,13 @@ class {utoken}_PUBLIC {class_name} {{ dependencies = [{dependencies} ] +sources = [{source_files} + +] + lib = library( '{lib_name}', - '{source_file}', + [sources], install : true, cpp_shared_args : lib_args, gnu_symbol_visibility : 'hidden', diff --git a/mesonbuild/templates/fortrantemplates.py b/mesonbuild/templates/fortrantemplates.py index 7aaa9d39cf40..7d97c58f6a37 100644 --- a/mesonbuild/templates/fortrantemplates.py +++ b/mesonbuild/templates/fortrantemplates.py @@ -56,9 +56,13 @@ dependencies = [{dependencies} ] +sources = [{source_files} + +] + lib = library( '{lib_name}', - '{source_file}', + [sources], install : true, fortran_shared_args : lib_args, gnu_symbol_visibility : 'hidden', @@ -110,9 +114,13 @@ dependencies = [{dependencies} ] +sources = [{source_files} + +] + exe = executable( '{exe_name}', - '{source_name}', + [sources], dependencies : dependencies, install : true, ) diff --git a/mesonbuild/templates/objcpptemplates.py b/mesonbuild/templates/objcpptemplates.py index 1f4bef43183d..c6eddd646a2c 100644 --- a/mesonbuild/templates/objcpptemplates.py +++ b/mesonbuild/templates/objcpptemplates.py @@ -73,13 +73,17 @@ dependencies = [{dependencies} ] +sources = [{source_files} + +] + # These arguments are only used to build the shared library # not the executables that use the library. lib_args = ['-DBUILDING_{utoken}'] lib = library( '{lib_name}', - '{source_file}', + [sources], install : true, objcpp_shared_args : lib_args, dependencies : dependencies, @@ -139,9 +143,13 @@ dependencies = [{dependencies} ] +sources = [{source_files} + +] + exe = executable( '{exe_name}', - '{source_name}', + [sources], dependencies : dependencies, install : true, ) diff --git a/mesonbuild/templates/objctemplates.py b/mesonbuild/templates/objctemplates.py index 8708d78e3de3..8b73b365f8ce 100644 --- a/mesonbuild/templates/objctemplates.py +++ b/mesonbuild/templates/objctemplates.py @@ -73,13 +73,17 @@ dependencies = [{dependencies} ] +sources = [{source_files} + +] + # These arguments are only used to build the shared library # not the executables that use the library. lib_args = ['-DBUILDING_{utoken}'] lib = library( '{lib_name}', - '{source_file}', + [sources], install : true, objc_shared_args : lib_args, dependencies : dependencies, @@ -138,9 +142,13 @@ dependencies = [{dependencies} ] +sources = [{source_files} + +] + exe = executable( '{exe_name}', - '{source_name}', + [sources], dependencies : dependencies, install : true, ) diff --git a/mesonbuild/templates/rusttemplates.py b/mesonbuild/templates/rusttemplates.py index ee1f0081dcd6..4c10cdd993c3 100644 --- a/mesonbuild/templates/rusttemplates.py +++ b/mesonbuild/templates/rusttemplates.py @@ -50,9 +50,13 @@ dependencies = [{dependencies} ] +sources = [{source_files} + +] + lib = static_library( '{lib_name}', - '{source_file}', + [sources], dependencies : dependencies, install : true, ) @@ -86,9 +90,13 @@ dependencies = [{dependencies} ] +sources = [{source_files} + +] + exe = executable( '{exe_name}', - '{source_name}', + [sources], dependencies : dependencies, install : true, ) diff --git a/mesonbuild/templates/valatemplates.py b/mesonbuild/templates/valatemplates.py index b2aab3f31be0..4e867d49aca5 100644 --- a/mesonbuild/templates/valatemplates.py +++ b/mesonbuild/templates/valatemplates.py @@ -24,9 +24,12 @@ dependency('gobject-2.0'),{dependencies} ] +sources = [{source_files} +] + exe = executable( '{exe_name}', - '{source_name}', + [sources], dependencies : dependencies, install : true, ) @@ -67,11 +70,15 @@ dependency('gobject-2.0'),{dependencies} ] +sources = [{source_files} + +] + # These arguments are only used to build the shared library # not the executables that use the library. lib = shared_library( 'foo', - '{source_file}', + [sources], dependencies : dependencies, install : true, install_dir : [true, true, true], diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py index 93fde1824bb3..5e20b385eecc 100644 --- a/unittests/allplatformstests.py +++ b/unittests/allplatformstests.py @@ -47,7 +47,7 @@ from mesonbuild.compilers.cpp import VisualStudioCPPCompiler, ClangClCPPCompiler from mesonbuild.compilers import ( detect_static_linker, detect_c_compiler, compiler_from_language, - detect_compiler_for + detect_compiler_for, lang_suffixes ) from mesonbuild.linkers import linkers @@ -2572,6 +2572,22 @@ def _template_test_dirty(lang, target_type): self._run(ninja, workdir=os.path.join(tmpdir, 'builddir')) + # Check for whether we're doing source collection by repeating + # with a bogus file we should pick up (and then fail to compile). + with tempfile.TemporaryDirectory() as tmpdir: + suffix = lang_suffixes[lang][0] + # Assume that this is a good enough string to error out + # in all languages. + with open(os.path.join(tmpdir, 'bar.' + suffix), 'w', encoding='utf-8') as f: + f.write('error bar') + self._run(self.meson_command + ['init', '--language', lang, '--type', target_type], + workdir=tmpdir) + self._run(self.setup_command + ['--backend=ninja', 'builddir'], + workdir=tmpdir) + with self.assertRaises(subprocess.CalledProcessError): + self._run(ninja, + workdir=os.path.join(tmpdir, 'builddir')) + # test directory with existing code file if lang in {'c', 'cpp', 'd'}: with tempfile.TemporaryDirectory() as tmpdir: @@ -2579,36 +2595,12 @@ def _template_test_dirty(lang, target_type): f.write('int main(void) {}') self._run(self.meson_command + ['init', '-b'], workdir=tmpdir) - # Check for whether we're doing source collection by repeating - # with a bogus file we should pick up (and then fail to compile). - with tempfile.TemporaryDirectory() as tmpdir: - with open(os.path.join(tmpdir, 'bar.' + lang), 'w', encoding='utf-8') as f: - f.write('#error bar') - self._run(self.meson_command + ['init'], workdir=tmpdir) - self._run(self.setup_command + ['--backend=ninja', 'builddir'], - workdir=tmpdir) - with self.assertRaises(subprocess.CalledProcessError): - self._run(ninja, - workdir=os.path.join(tmpdir, 'builddir')) - elif lang in {'java'}: with tempfile.TemporaryDirectory() as tmpdir: with open(os.path.join(tmpdir, 'Foo.' + lang), 'w', encoding='utf-8') as f: f.write('public class Foo { public static void main() {} }') self._run(self.meson_command + ['init', '-b'], workdir=tmpdir) - # Check for whether we're doing source collection by repeating - # with a bogus file we should pick up (and then fail to compile). - with tempfile.TemporaryDirectory() as tmpdir: - with open(os.path.join(tmpdir, 'Bar.' + lang), 'w', encoding='utf-8') as f: - f.write('public class Bar { public private static void main() {} }') - self._run(self.meson_command + ['init'], workdir=tmpdir) - self._run(self.setup_command + ['--backend=ninja', 'builddir'], - workdir=tmpdir) - with self.assertRaises(subprocess.CalledProcessError): - self._run(ninja, - workdir=os.path.join(tmpdir, 'builddir')) - for lang, target_type, fresh in itertools.product(langs, ('executable', 'library'), (True, False)): with self.subTest(f'Language: {lang}; type: {target_type}; fresh: {fresh}'): _template_test_fresh(lang, target_type) if fresh else _template_test_dirty(lang, target_type) From 93635a820df56d3d40b7b79883af071675c98bfb Mon Sep 17 00:00:00 2001 From: Sam James Date: Mon, 24 Nov 2025 18:56:54 +0000 Subject: [PATCH 5/5] templates: simplify (whitespace, flatten array) --- mesonbuild/templates/cpptemplates.py | 5 ++--- mesonbuild/templates/cstemplates.py | 6 ++---- mesonbuild/templates/ctemplates.py | 4 ++-- mesonbuild/templates/cudatemplates.py | 6 ++---- mesonbuild/templates/dlangtemplates.py | 6 ++---- mesonbuild/templates/fortrantemplates.py | 6 ++---- mesonbuild/templates/javatemplates.py | 6 ++---- mesonbuild/templates/objcpptemplates.py | 6 ++---- mesonbuild/templates/objctemplates.py | 6 ++---- mesonbuild/templates/rusttemplates.py | 6 ++---- mesonbuild/templates/valatemplates.py | 5 ++--- 11 files changed, 22 insertions(+), 40 deletions(-) diff --git a/mesonbuild/templates/cpptemplates.py b/mesonbuild/templates/cpptemplates.py index 77e61e417c05..79f88a5de8b5 100644 --- a/mesonbuild/templates/cpptemplates.py +++ b/mesonbuild/templates/cpptemplates.py @@ -40,7 +40,7 @@ exe = executable( '{exe_name}', - [sources], + sources, install : true, dependencies : dependencies, ) @@ -131,12 +131,11 @@ class {utoken}_PUBLIC {class_name} {{ lib_args = ['-DBUILDING_{utoken}'] sources = [{source_files} - ] lib = library( '{lib_name}', - [sources], + sources, install : true, cpp_shared_args : lib_args, gnu_symbol_visibility : 'hidden', diff --git a/mesonbuild/templates/cstemplates.py b/mesonbuild/templates/cstemplates.py index 297d9b1d44ee..e44cf6f646b6 100644 --- a/mesonbuild/templates/cstemplates.py +++ b/mesonbuild/templates/cstemplates.py @@ -36,12 +36,11 @@ ] sources = [{source_files} - ] exe = executable( '{exe_name}', - [sources], + sources, install : true, dependencies : dependencies, ) @@ -88,12 +87,11 @@ ] sources = [{source_files} - ] stlib = shared_library( '{lib_name}', - [sources], + sources, dependencies : dependencies, install : true, ) diff --git a/mesonbuild/templates/ctemplates.py b/mesonbuild/templates/ctemplates.py index 134e43b3f24c..3db6477aabe1 100644 --- a/mesonbuild/templates/ctemplates.py +++ b/mesonbuild/templates/ctemplates.py @@ -82,7 +82,7 @@ lib = library( '{lib_name}', - [sources], + sources, install : true, c_shared_args : lib_args, gnu_symbol_visibility : 'hidden', @@ -147,7 +147,7 @@ exe = executable( '{exe_name}', - [sources], + sources, dependencies : dependencies, install : true, ) diff --git a/mesonbuild/templates/cudatemplates.py b/mesonbuild/templates/cudatemplates.py index 45cd155f9077..d10fb76190bd 100644 --- a/mesonbuild/templates/cudatemplates.py +++ b/mesonbuild/templates/cudatemplates.py @@ -37,12 +37,11 @@ ] sources = [{source_files} - ] exe = executable( '{exe_name}', - [sources], + sources, dependencies : dependencies, install : true, ) @@ -127,12 +126,11 @@ class {utoken}_PUBLIC {class_name} {{ ] sources = [{source_files} - ] lib = library( '{lib_name}', - [sources], + sources, install : true, cpp_shared_args : lib_args, gnu_symbol_visibility : 'hidden', diff --git a/mesonbuild/templates/dlangtemplates.py b/mesonbuild/templates/dlangtemplates.py index 4ca91a69b67a..727ee209c724 100644 --- a/mesonbuild/templates/dlangtemplates.py +++ b/mesonbuild/templates/dlangtemplates.py @@ -36,12 +36,11 @@ ] sources = [{source_files} - ] exe = executable( '{exe_name}', - [sources], + sources, dependencies : dependencies, install : true, ) @@ -89,12 +88,11 @@ ] sources = [{source_files} - ] stlib = static_library( '{lib_name}', - [sources], + sources, install : true, gnu_symbol_visibility : 'hidden', dependencies : dependencies, diff --git a/mesonbuild/templates/fortrantemplates.py b/mesonbuild/templates/fortrantemplates.py index 7d97c58f6a37..03f0ff922e6a 100644 --- a/mesonbuild/templates/fortrantemplates.py +++ b/mesonbuild/templates/fortrantemplates.py @@ -57,12 +57,11 @@ ] sources = [{source_files} - ] lib = library( '{lib_name}', - [sources], + sources, install : true, fortran_shared_args : lib_args, gnu_symbol_visibility : 'hidden', @@ -115,12 +114,11 @@ ] sources = [{source_files} - ] exe = executable( '{exe_name}', - [sources], + sources, dependencies : dependencies, install : true, ) diff --git a/mesonbuild/templates/javatemplates.py b/mesonbuild/templates/javatemplates.py index 458142e6b487..ed32194fee88 100644 --- a/mesonbuild/templates/javatemplates.py +++ b/mesonbuild/templates/javatemplates.py @@ -36,12 +36,11 @@ ] sources = [{source_files} - ] exe = jar( '{exe_name}', - [sources], + sources, main_class : '{exe_name}', dependencies : dependencies, install : true, @@ -91,12 +90,11 @@ ] sources = [{source_files} - ] jarlib = jar( '{class_name}', - [sources], + sources, dependencies : dependencies, main_class : '{class_name}', install : true, diff --git a/mesonbuild/templates/objcpptemplates.py b/mesonbuild/templates/objcpptemplates.py index c6eddd646a2c..d80c37485282 100644 --- a/mesonbuild/templates/objcpptemplates.py +++ b/mesonbuild/templates/objcpptemplates.py @@ -74,7 +74,6 @@ ] sources = [{source_files} - ] # These arguments are only used to build the shared library @@ -83,7 +82,7 @@ lib = library( '{lib_name}', - [sources], + sources, install : true, objcpp_shared_args : lib_args, dependencies : dependencies, @@ -144,12 +143,11 @@ ] sources = [{source_files} - ] exe = executable( '{exe_name}', - [sources], + sources, dependencies : dependencies, install : true, ) diff --git a/mesonbuild/templates/objctemplates.py b/mesonbuild/templates/objctemplates.py index 8b73b365f8ce..7dc3d4f989a3 100644 --- a/mesonbuild/templates/objctemplates.py +++ b/mesonbuild/templates/objctemplates.py @@ -74,7 +74,6 @@ ] sources = [{source_files} - ] # These arguments are only used to build the shared library @@ -83,7 +82,7 @@ lib = library( '{lib_name}', - [sources], + sources, install : true, objc_shared_args : lib_args, dependencies : dependencies, @@ -143,12 +142,11 @@ ] sources = [{source_files} - ] exe = executable( '{exe_name}', - [sources], + sources, dependencies : dependencies, install : true, ) diff --git a/mesonbuild/templates/rusttemplates.py b/mesonbuild/templates/rusttemplates.py index 4c10cdd993c3..b415be7c6b5f 100644 --- a/mesonbuild/templates/rusttemplates.py +++ b/mesonbuild/templates/rusttemplates.py @@ -51,12 +51,11 @@ ] sources = [{source_files} - ] lib = static_library( '{lib_name}', - [sources], + sources, dependencies : dependencies, install : true, ) @@ -91,12 +90,11 @@ ] sources = [{source_files} - ] exe = executable( '{exe_name}', - [sources], + sources, dependencies : dependencies, install : true, ) diff --git a/mesonbuild/templates/valatemplates.py b/mesonbuild/templates/valatemplates.py index 4e867d49aca5..de31877674b5 100644 --- a/mesonbuild/templates/valatemplates.py +++ b/mesonbuild/templates/valatemplates.py @@ -29,7 +29,7 @@ exe = executable( '{exe_name}', - [sources], + sources, dependencies : dependencies, install : true, ) @@ -71,14 +71,13 @@ ] sources = [{source_files} - ] # These arguments are only used to build the shared library # not the executables that use the library. lib = shared_library( 'foo', - [sources], + sources, dependencies : dependencies, install : true, install_dir : [true, true, true],