diff options
| author | Dylan Baker <dylan@pnwbakers.com> | 2025-01-06 11:58:50 -0800 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2025-01-08 09:54:46 -0800 |
| commit | 5c209e196683289319535ada713759b6f4244ef6 (patch) | |
| tree | ddbdbd1936b6369bf5b1dab543760479ffa3dd47 | |
| parent | fbe5655707a945d5b0ebf3c5d29d91fffd91a7d6 (diff) | |
| download | meson-5c209e196683289319535ada713759b6f4244ef6.tar.gz | |
templates: Add a Meson version
Without a version certain kinds of warnings will be suppressed, which is
bad.
I've picked 1.0 because it's pretty old, except for Rust where I've
maintained the 1.3.0 requirement
| -rw-r--r-- | mesonbuild/templates/cpptemplates.py | 2 | ||||
| -rw-r--r-- | mesonbuild/templates/cstemplates.py | 2 | ||||
| -rw-r--r-- | mesonbuild/templates/ctemplates.py | 2 | ||||
| -rw-r--r-- | mesonbuild/templates/cudatemplates.py | 2 | ||||
| -rw-r--r-- | mesonbuild/templates/dlangtemplates.py | 2 | ||||
| -rw-r--r-- | mesonbuild/templates/fortrantemplates.py | 2 | ||||
| -rw-r--r-- | mesonbuild/templates/javatemplates.py | 2 | ||||
| -rw-r--r-- | mesonbuild/templates/mesontemplates.py | 4 | ||||
| -rw-r--r-- | mesonbuild/templates/objcpptemplates.py | 2 | ||||
| -rw-r--r-- | mesonbuild/templates/objctemplates.py | 2 | ||||
| -rw-r--r-- | mesonbuild/templates/rusttemplates.py | 13 | ||||
| -rw-r--r-- | mesonbuild/templates/sampleimpl.py | 9 | ||||
| -rw-r--r-- | mesonbuild/templates/valatemplates.py | 2 |
13 files changed, 42 insertions, 4 deletions
diff --git a/mesonbuild/templates/cpptemplates.py b/mesonbuild/templates/cpptemplates.py index 1975a76f0..f21729982 100644 --- a/mesonbuild/templates/cpptemplates.py +++ b/mesonbuild/templates/cpptemplates.py @@ -23,6 +23,7 @@ int main(int argc, char **argv) {{ hello_cpp_meson_template = '''project('{project_name}', 'cpp', version : '{version}', + meson_version : '>= {meson_version}', default_options : ['warning_level=3', 'cpp_std=c++14']) @@ -95,6 +96,7 @@ int main(int argc, char **argv) {{ lib_cpp_meson_template = '''project('{project_name}', 'cpp', version : '{version}', + meson_version : '>= {meson_version}', default_options : ['warning_level=3', 'cpp_std=c++14']) # These arguments are only used to build the shared library diff --git a/mesonbuild/templates/cstemplates.py b/mesonbuild/templates/cstemplates.py index 8522d54ee..4dbb39863 100644 --- a/mesonbuild/templates/cstemplates.py +++ b/mesonbuild/templates/cstemplates.py @@ -26,6 +26,7 @@ public class {class_name} {{ hello_cs_meson_template = '''project('{project_name}', 'cs', version : '{version}', + meson_version : '>= {meson_version}', default_options : ['warning_level=3']) exe = executable('{exe_name}', '{source_name}', @@ -63,6 +64,7 @@ public class {class_test} {{ lib_cs_meson_template = '''project('{project_name}', 'cs', version : '{version}', + meson_version : '>= {meson_version}', default_options : ['warning_level=3']) stlib = shared_library('{lib_name}', '{source_file}', diff --git a/mesonbuild/templates/ctemplates.py b/mesonbuild/templates/ctemplates.py index d150fe52d..a879b9ac5 100644 --- a/mesonbuild/templates/ctemplates.py +++ b/mesonbuild/templates/ctemplates.py @@ -54,6 +54,7 @@ int main(int argc, char **argv) {{ lib_c_meson_template = '''project('{project_name}', 'c', version : '{version}', + meson_version : '>= {meson_version}', default_options : ['warning_level=3']) # These arguments are only used to build the shared library @@ -105,6 +106,7 @@ int main(int argc, char **argv) {{ ''' hello_c_meson_template = '''project('{project_name}', 'c', + meson_version : '>= {meson_version}', version : '{version}', default_options : ['warning_level=3']) diff --git a/mesonbuild/templates/cudatemplates.py b/mesonbuild/templates/cudatemplates.py index 7c42d342f..c79150e81 100644 --- a/mesonbuild/templates/cudatemplates.py +++ b/mesonbuild/templates/cudatemplates.py @@ -23,6 +23,7 @@ int main(int argc, char **argv) {{ hello_cuda_meson_template = '''project('{project_name}', ['cuda', 'cpp'], version : '{version}', + meson_version : '>= {meson_version}', default_options : ['warning_level=3', 'cpp_std=c++14']) @@ -95,6 +96,7 @@ int main(int argc, char **argv) {{ lib_cuda_meson_template = '''project('{project_name}', ['cuda', 'cpp'], version : '{version}', + meson_version : '>= {meson_version}', default_options : ['warning_level=3']) # These arguments are only used to build the shared library diff --git a/mesonbuild/templates/dlangtemplates.py b/mesonbuild/templates/dlangtemplates.py index fdae841b2..eb102aede 100644 --- a/mesonbuild/templates/dlangtemplates.py +++ b/mesonbuild/templates/dlangtemplates.py @@ -26,6 +26,7 @@ int main(string[] args) {{ hello_d_meson_template = '''project('{project_name}', 'd', version : '{version}', + meson_version : '>= {meson_version}', default_options: ['warning_level=3']) exe = executable('{exe_name}', '{source_name}', @@ -64,6 +65,7 @@ int main(string[] args) {{ lib_d_meson_template = '''project('{project_name}', 'd', version : '{version}', + meson_version : '>= {meson_version}', default_options : ['warning_level=3']) stlib = static_library('{lib_name}', '{source_file}', diff --git a/mesonbuild/templates/fortrantemplates.py b/mesonbuild/templates/fortrantemplates.py index 2ea54628f..6e3383653 100644 --- a/mesonbuild/templates/fortrantemplates.py +++ b/mesonbuild/templates/fortrantemplates.py @@ -39,6 +39,7 @@ end program lib_fortran_meson_template = '''project('{project_name}', 'fortran', version : '{version}', + meson_version : '>= {meson_version}', default_options : ['warning_level=3']) # These arguments are only used to build the shared library @@ -83,6 +84,7 @@ end program hello_fortran_meson_template = '''project('{project_name}', 'fortran', version : '{version}', + meson_version : '>= {meson_version}', default_options : ['warning_level=3']) exe = executable('{exe_name}', '{source_name}', diff --git a/mesonbuild/templates/javatemplates.py b/mesonbuild/templates/javatemplates.py index e55c5fa3a..caaa98920 100644 --- a/mesonbuild/templates/javatemplates.py +++ b/mesonbuild/templates/javatemplates.py @@ -26,6 +26,7 @@ public class {class_name} {{ hello_java_meson_template = '''project('{project_name}', 'java', version : '{version}', + meson_version : '>= {meson_version}', default_options : ['warning_level=3']) exe = jar('{exe_name}', '{source_name}', @@ -66,6 +67,7 @@ public class {class_test} {{ lib_java_meson_template = '''project('{project_name}', 'java', version : '{version}', + meson_version : '>= {meson_version}', default_options : ['warning_level=3']) jarlib = jar('{class_name}', '{source_file}', diff --git a/mesonbuild/templates/mesontemplates.py b/mesonbuild/templates/mesontemplates.py index caea28bd6..e0f6ca3fb 100644 --- a/mesonbuild/templates/mesontemplates.py +++ b/mesonbuild/templates/mesontemplates.py @@ -11,6 +11,7 @@ if T.TYPE_CHECKING: meson_executable_template = '''project('{project_name}', {language}, version : '{version}', + meson_version : '>= {meson_version}', default_options : [{default_options}]) executable('{executable}', @@ -21,6 +22,7 @@ executable('{executable}', meson_jar_template = '''project('{project_name}', '{language}', version : '{version}', + meson_version : '>= {meson_version}', default_options : [{default_options}]) jar('{executable}', @@ -54,6 +56,7 @@ def create_meson_build(options: Arguments) -> None: content = meson_executable_template.format(project_name=options.name, language=language, version=options.version, + meson_version='1.0.0', executable=options.executable, sourcespec=sourcespec, depspec=depspec, @@ -62,6 +65,7 @@ def create_meson_build(options: Arguments) -> None: content = meson_jar_template.format(project_name=options.name, language=options.language, version=options.version, + meson_version='1.0.0' if options.language != 'rust' else '1.3.0', executable=options.executable, main_class=options.name, sourcespec=sourcespec, diff --git a/mesonbuild/templates/objcpptemplates.py b/mesonbuild/templates/objcpptemplates.py index 85794a5c4..91ce177c3 100644 --- a/mesonbuild/templates/objcpptemplates.py +++ b/mesonbuild/templates/objcpptemplates.py @@ -54,6 +54,7 @@ int main(int argc, char **argv) {{ lib_objcpp_meson_template = '''project('{project_name}', 'objcpp', version : '{version}', + meson_version : '>= {meson_version}', default_options : ['warning_level=3']) # These arguments are only used to build the shared library @@ -106,6 +107,7 @@ int main(int argc, char **argv) {{ hello_objcpp_meson_template = '''project('{project_name}', 'objcpp', version : '{version}', + meson_version : '>= {meson_version}', default_options : ['warning_level=3']) exe = executable('{exe_name}', '{source_name}', diff --git a/mesonbuild/templates/objctemplates.py b/mesonbuild/templates/objctemplates.py index b96949968..59a6cd88b 100644 --- a/mesonbuild/templates/objctemplates.py +++ b/mesonbuild/templates/objctemplates.py @@ -54,6 +54,7 @@ int main(int argc, char **argv) {{ lib_objc_meson_template = '''project('{project_name}', 'objc', version : '{version}', + meson_version : '>= {meson_version}', default_options : ['warning_level=3']) # These arguments are only used to build the shared library @@ -106,6 +107,7 @@ int main(int argc, char **argv) {{ hello_objc_meson_template = '''project('{project_name}', 'objc', version : '{version}', + meson_version : '>= {meson_version}', default_options : ['warning_level=3']) exe = executable('{exe_name}', '{source_name}', diff --git a/mesonbuild/templates/rusttemplates.py b/mesonbuild/templates/rusttemplates.py index 8e9d5b88d..83d8d4f95 100644 --- a/mesonbuild/templates/rusttemplates.py +++ b/mesonbuild/templates/rusttemplates.py @@ -8,6 +8,9 @@ import typing as T from mesonbuild.templates.sampleimpl import FileImpl +if T.TYPE_CHECKING: + from ..minit import Arguments + lib_rust_template = '''#![crate_name = "{crate_file}"] @@ -35,7 +38,8 @@ mod tests {{ lib_rust_meson_template = '''project('{project_name}', 'rust', - version : '{version}', meson_version: '>=1.3.0', + version : '{version}', + meson_version : '>= {meson_version}', default_options : ['rust_std=2021', 'warning_level=3']) rust = import('rust') @@ -58,7 +62,8 @@ fn main() {{ ''' hello_rust_meson_template = '''project('{project_name}', 'rust', - version : '{version}', meson_version: '>=1.3.0', + version : '{version}', + meson_version : '>= {meson_version}', default_options : ['rust_std=2021', 'warning_level=3']) exe = executable('{exe_name}', '{source_name}', @@ -77,6 +82,10 @@ class RustProject(FileImpl): lib_test_template = None lib_meson_template = lib_rust_meson_template + def __init__(self, args: Arguments): + super().__init__(args) + self.meson_version = '1.3.0' + def lib_kwargs(self) -> T.Dict[str, str]: kwargs = super().lib_kwargs() kwargs['crate_file'] = self.lowercase_token diff --git a/mesonbuild/templates/sampleimpl.py b/mesonbuild/templates/sampleimpl.py index 14b0460d7..b6c389565 100644 --- a/mesonbuild/templates/sampleimpl.py +++ b/mesonbuild/templates/sampleimpl.py @@ -20,6 +20,7 @@ class SampleImpl(metaclass=abc.ABCMeta): self.lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower()) self.uppercase_token = self.lowercase_token.upper() self.capitalized_token = self.lowercase_token.capitalize() + self.meson_version = '1.0.0' @abc.abstractmethod def create_executable(self) -> None: @@ -67,7 +68,8 @@ class ClassImpl(SampleImpl): f.write(self.exe_meson_template.format(project_name=self.name, exe_name=self.name, source_name=source_name, - version=self.version)) + version=self.version, + meson_version=self.meson_version)) def create_library(self) -> None: lib_name = f'{self.capitalized_token}.{self.source_ext}' @@ -83,6 +85,7 @@ class ClassImpl(SampleImpl): 'lib_name': self.lowercase_token, 'test_name': self.lowercase_token, 'version': self.version, + 'meson_version': self.meson_version, } with open(lib_name, 'w', encoding='utf-8') as f: f.write(self.lib_template.format(**kwargs)) @@ -105,7 +108,8 @@ class FileImpl(SampleImpl): f.write(self.exe_meson_template.format(project_name=self.name, exe_name=self.name, source_name=source_name, - version=self.version)) + version=self.version, + meson_version=self.meson_version)) def lib_kwargs(self) -> T.Dict[str, str]: """Get Language specific keyword arguments @@ -126,6 +130,7 @@ class FileImpl(SampleImpl): 'lib_name': self.lowercase_token, 'test_name': self.lowercase_token, 'version': self.version, + 'meson_version': self.meson_version, } def create_library(self) -> None: diff --git a/mesonbuild/templates/valatemplates.py b/mesonbuild/templates/valatemplates.py index f577880d4..fd93ffaf4 100644 --- a/mesonbuild/templates/valatemplates.py +++ b/mesonbuild/templates/valatemplates.py @@ -13,6 +13,7 @@ hello_vala_template = '''void main (string[] args) {{ ''' hello_vala_meson_template = '''project('{project_name}', ['c', 'vala'], + meson_version : '>= {meson_version}', version : '{version}') dependencies = [ @@ -48,6 +49,7 @@ public void main() {{ ''' lib_vala_meson_template = '''project('{project_name}', ['c', 'vala'], + meson_version : '>= {meson_version}', version : '{version}') dependencies = [ |
