templates: move initializer to base class

Every class implements the exact same initializer, simplify this by
putting it in the base class initializer
pull/12044/head
Dylan Baker 1 year ago committed by Eli Schwartz
parent 3fdc877e8a
commit d0729bde02
  1. 7
      mesonbuild/templates/cpptemplates.py
  2. 7
      mesonbuild/templates/cstemplates.py
  3. 7
      mesonbuild/templates/ctemplates.py
  4. 7
      mesonbuild/templates/cudatemplates.py
  5. 7
      mesonbuild/templates/dlangtemplates.py
  6. 7
      mesonbuild/templates/fortrantemplates.py
  7. 7
      mesonbuild/templates/javatemplates.py
  8. 7
      mesonbuild/templates/objcpptemplates.py
  9. 7
      mesonbuild/templates/objctemplates.py
  10. 7
      mesonbuild/templates/rusttemplates.py
  11. 10
      mesonbuild/templates/sampleimpl.py
  12. 7
      mesonbuild/templates/valatemplates.py

@ -13,9 +13,10 @@
# limitations under the License.
from __future__ import annotations
from mesonbuild.templates.sampleimpl import SampleImpl
import re
from mesonbuild.templates.sampleimpl import SampleImpl
hello_cpp_template = '''#include <iostream>
@ -143,10 +144,6 @@ pkg_mod.generate(
class CppProject(SampleImpl):
def __init__(self, options):
super().__init__()
self.name = options.name
self.version = options.version
def create_executable(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())

@ -13,9 +13,10 @@
# limitations under the License.
from __future__ import annotations
from mesonbuild.templates.sampleimpl import SampleImpl
import re
from mesonbuild.templates.sampleimpl import SampleImpl
hello_cs_template = '''using System;
@ -92,10 +93,6 @@ test('{test_name}', test_exe)
class CSharpProject(SampleImpl):
def __init__(self, options):
super().__init__()
self.name = options.name
self.version = options.version
def create_executable(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())

@ -13,9 +13,10 @@
# limitations under the License.
from __future__ import annotations
from mesonbuild.templates.sampleimpl import SampleImpl
import re
from mesonbuild.templates.sampleimpl import SampleImpl
lib_h_template = '''#pragma once
#if defined _WIN32 || defined __CYGWIN__
@ -126,10 +127,6 @@ test('basic', exe)
class CProject(SampleImpl):
def __init__(self, options):
super().__init__()
self.name = options.name
self.version = options.version
def create_executable(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())

@ -13,9 +13,10 @@
# limitations under the License.
from __future__ import annotations
from mesonbuild.templates.sampleimpl import SampleImpl
import re
from mesonbuild.templates.sampleimpl import SampleImpl
hello_cuda_template = '''#include <iostream>
@ -143,10 +144,6 @@ pkg_mod.generate(
class CudaProject(SampleImpl):
def __init__(self, options):
super().__init__()
self.name = options.name
self.version = options.version
def create_executable(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())

@ -13,9 +13,10 @@
# limitations under the License.
from __future__ import annotations
from mesonbuild.templates.sampleimpl import SampleImpl
import re
from mesonbuild.templates.sampleimpl import SampleImpl
hello_d_template = '''module main;
import std.stdio;
@ -104,10 +105,6 @@ endif
class DlangProject(SampleImpl):
def __init__(self, options):
super().__init__()
self.name = options.name
self.version = options.version
def create_executable(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())

@ -13,9 +13,10 @@
# limitations under the License.
from __future__ import annotations
from mesonbuild.templates.sampleimpl import SampleImpl
import re
from mesonbuild.templates.sampleimpl import SampleImpl
lib_fortran_template = '''
! This procedure will not be exported and is not
! directly callable by users of this library.
@ -103,10 +104,6 @@ test('basic', exe)
class FortranProject(SampleImpl):
def __init__(self, options):
super().__init__()
self.name = options.name
self.version = options.version
def create_executable(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())

@ -13,9 +13,10 @@
# limitations under the License.
from __future__ import annotations
from mesonbuild.templates.sampleimpl import SampleImpl
import re
from mesonbuild.templates.sampleimpl import SampleImpl
hello_java_template = '''
@ -96,10 +97,6 @@ test('{test_name}', test_jar)
class JavaProject(SampleImpl):
def __init__(self, options):
super().__init__()
self.name = options.name
self.version = options.version
def create_executable(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())

@ -13,9 +13,10 @@
# limitations under the License.
from __future__ import annotations
from mesonbuild.templates.sampleimpl import SampleImpl
import re
from mesonbuild.templates.sampleimpl import SampleImpl
lib_h_template = '''#pragma once
#if defined _WIN32 || defined __CYGWIN__
@ -126,10 +127,6 @@ test('basic', exe)
class ObjCppProject(SampleImpl):
def __init__(self, options):
super().__init__()
self.name = options.name
self.version = options.version
def create_executable(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())

@ -13,9 +13,10 @@
# limitations under the License.
from __future__ import annotations
from mesonbuild.templates.sampleimpl import SampleImpl
import re
from mesonbuild.templates.sampleimpl import SampleImpl
lib_h_template = '''#pragma once
#if defined _WIN32 || defined __CYGWIN__
@ -126,10 +127,6 @@ test('basic', exe)
class ObjCProject(SampleImpl):
def __init__(self, options):
super().__init__()
self.name = options.name
self.version = options.version
def create_executable(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())

@ -13,9 +13,10 @@
# limitations under the License.
from __future__ import annotations
from mesonbuild.templates.sampleimpl import SampleImpl
import re
from mesonbuild.templates.sampleimpl import SampleImpl
lib_rust_template = '''#![crate_name = "{crate_file}"]
@ -74,10 +75,6 @@ test('basic', exe)
class RustProject(SampleImpl):
def __init__(self, options):
super().__init__()
self.name = options.name
self.version = options.version
def create_executable(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())

@ -13,8 +13,18 @@
# limitations under the License.
from __future__ import annotations
import typing as T
if T.TYPE_CHECKING:
from ..minit import Arguments
class SampleImpl:
def __init__(self, args: Arguments):
self.name = args.name
self.version = args.version
def create_executable(self) -> None:
raise NotImplementedError('Sample implementation for "executable" not implemented!')

@ -13,9 +13,10 @@
# limitations under the License.
from __future__ import annotations
from mesonbuild.templates.sampleimpl import SampleImpl
import re
from mesonbuild.templates.sampleimpl import SampleImpl
hello_vala_template = '''void main (string[] args) {{
stdout.printf ("Hello {project_name}!\\n");
@ -84,10 +85,6 @@ test('{test_name}', test_exe)
class ValaProject(SampleImpl):
def __init__(self, options):
super().__init__()
self.name = options.name
self.version = options.version
def create_executable(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())

Loading…
Cancel
Save