summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/templates/cstemplates.py12
-rw-r--r--mesonbuild/templates/cudatemplates.py12
-rw-r--r--mesonbuild/templates/fortrantemplates.py12
-rw-r--r--mesonbuild/templates/objcpptemplates.py12
-rw-r--r--mesonbuild/templates/objctemplates.py12
-rw-r--r--mesonbuild/templates/rusttemplates.py12
-rw-r--r--mesonbuild/templates/valatemplates.py11
-rw-r--r--unittests/allplatformstests.py61
8 files changed, 93 insertions, 51 deletions
diff --git a/mesonbuild/templates/cstemplates.py b/mesonbuild/templates/cstemplates.py
index 59c718953..297d9b1d4 100644
--- a/mesonbuild/templates/cstemplates.py
+++ b/mesonbuild/templates/cstemplates.py
@@ -35,9 +35,13 @@ hello_cs_meson_template = '''project(
dependencies = [{dependencies}
]
+sources = [{source_files}
+
+]
+
exe = executable(
'{exe_name}',
- '{source_name}',
+ [sources],
install : true,
dependencies : dependencies,
)
@@ -83,9 +87,13 @@ lib_cs_meson_template = '''project(
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 252f44a27..45cd155f9 100644
--- a/mesonbuild/templates/cudatemplates.py
+++ b/mesonbuild/templates/cudatemplates.py
@@ -36,9 +36,13 @@ hello_cuda_meson_template = '''project(
dependencies = [{dependencies}
]
+sources = [{source_files}
+
+]
+
exe = executable(
'{exe_name}',
- '{source_name}',
+ [sources],
dependencies : dependencies,
install : true,
)
@@ -122,9 +126,13 @@ lib_args = ['-DBUILDING_{utoken}']
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 7aaa9d39c..7d97c58f6 100644
--- a/mesonbuild/templates/fortrantemplates.py
+++ b/mesonbuild/templates/fortrantemplates.py
@@ -56,9 +56,13 @@ lib_args = ['-DBUILDING_{utoken}']
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 @@ hello_fortran_meson_template = '''project(
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 1f4bef431..c6eddd646 100644
--- a/mesonbuild/templates/objcpptemplates.py
+++ b/mesonbuild/templates/objcpptemplates.py
@@ -73,13 +73,17 @@ lib_objcpp_meson_template = '''project(
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 @@ hello_objcpp_meson_template = '''project(
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 8708d78e3..8b73b365f 100644
--- a/mesonbuild/templates/objctemplates.py
+++ b/mesonbuild/templates/objctemplates.py
@@ -73,13 +73,17 @@ lib_objc_meson_template = '''project(
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 @@ hello_objc_meson_template = '''project(
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 ee1f0081d..4c10cdd99 100644
--- a/mesonbuild/templates/rusttemplates.py
+++ b/mesonbuild/templates/rusttemplates.py
@@ -50,9 +50,13 @@ rust = import('rust')
dependencies = [{dependencies}
]
+sources = [{source_files}
+
+]
+
lib = static_library(
'{lib_name}',
- '{source_file}',
+ [sources],
dependencies : dependencies,
install : true,
)
@@ -86,9 +90,13 @@ hello_rust_meson_template = '''project(
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 b2aab3f31..4e867d49a 100644
--- a/mesonbuild/templates/valatemplates.py
+++ b/mesonbuild/templates/valatemplates.py
@@ -24,9 +24,12 @@ dependencies = [
dependency('gobject-2.0'),{dependencies}
]
+sources = [{source_files}
+]
+
exe = executable(
'{exe_name}',
- '{source_name}',
+ [sources],
dependencies : dependencies,
install : true,
)
@@ -67,11 +70,15 @@ dependencies = [
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 93fde1824..1304658da 100644
--- a/unittests/allplatformstests.py
+++ b/unittests/allplatformstests.py
@@ -47,7 +47,7 @@ from mesonbuild.compilers.c import VisualStudioCCompiler, ClangClCCompiler
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
@@ -2536,20 +2536,17 @@ class AllPlatformTests(BasePlatformTests):
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'))
+ self._run(self.setup_command + ['--backend=ninja', 'builddir'], workdir=tmpdir)
+ 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'))
+ '--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)
@@ -2566,10 +2563,24 @@ class AllPlatformTests(BasePlatformTests):
# test empty directory
with tempfile.TemporaryDirectory() as tmpdir:
self._run(self.meson_command + ['init', '--language', lang, '--type', target_type],
- workdir=tmpdir)
+ workdir=tmpdir)
+ self._run(self.setup_command + ['--backend=ninja', 'builddir'], workdir=tmpdir)
+ 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)
- self._run(ninja,
+ workdir=tmpdir)
+ with self.assertRaises(subprocess.CalledProcessError):
+ self._run(ninja,
workdir=os.path.join(tmpdir, 'builddir'))
# test directory with existing code file
@@ -2579,36 +2590,12 @@ class AllPlatformTests(BasePlatformTests):
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)