aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/modules
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2021-04-09 15:15:07 -0400
committerXavier Claessens <xclaesse@gmail.com>2021-05-28 15:17:10 -0400
commit2e02ef6592fa6634eadbe388c2a5ee957ce20e59 (patch)
tree2083b14523bc246507a5d91dee7113e9ac66d5ee /mesonbuild/modules
parenta734bcfc83a67788f71b5b84a46a4d9727b5ec09 (diff)
downloadmeson-2e02ef6592fa6634eadbe388c2a5ee957ce20e59.zip
meson-2e02ef6592fa6634eadbe388c2a5ee957ce20e59.tar.gz
meson-2e02ef6592fa6634eadbe388c2a5ee957ce20e59.tar.bz2
modules: Add methods dict everywhere
This fix calling random internal methods from meson.build as long as they were not prefixed by underscore.
Diffstat (limited to 'mesonbuild/modules')
-rw-r--r--mesonbuild/modules/__init__.py4
-rw-r--r--mesonbuild/modules/cmake.py6
-rw-r--r--mesonbuild/modules/dlang.py3
-rw-r--r--mesonbuild/modules/fs.py17
-rw-r--r--mesonbuild/modules/gnome.py14
-rw-r--r--mesonbuild/modules/hotdoc.py4
-rw-r--r--mesonbuild/modules/i18n.py6
-rw-r--r--mesonbuild/modules/keyval.py3
-rw-r--r--mesonbuild/modules/modtest.py5
-rw-r--r--mesonbuild/modules/pkgconfig.py5
-rw-r--r--mesonbuild/modules/python.py3
-rw-r--r--mesonbuild/modules/python3.py6
-rw-r--r--mesonbuild/modules/qt.py5
-rw-r--r--mesonbuild/modules/rpm.py26
-rw-r--r--mesonbuild/modules/sourceset.py3
-rw-r--r--mesonbuild/modules/unstable_icestorm.py3
-rw-r--r--mesonbuild/modules/unstable_rust.py4
-rw-r--r--mesonbuild/modules/unstable_simd.py3
-rw-r--r--mesonbuild/modules/windows.py5
19 files changed, 112 insertions, 13 deletions
diff --git a/mesonbuild/modules/__init__.py b/mesonbuild/modules/__init__.py
index 7a83122..5bae3a0 100644
--- a/mesonbuild/modules/__init__.py
+++ b/mesonbuild/modules/__init__.py
@@ -87,7 +87,7 @@ class ModuleObject:
"""Base class for all objects returned by modules
"""
def __init__(self) -> None:
- self.methods = {} # type: T.Dict[str, T.Callable[[T.List[TYPE_nvar], TYPE_nkwargs], TYPE_var]]
+ self.methods = {} # type: T.Dict[str, T.Callable[[ModuleState, T.List[TYPE_nvar], TYPE_nkwargs], T.Union[ModuleReturnValue, TYPE_var]]]
class MutableModuleObject(ModuleObject):
pass
@@ -112,7 +112,7 @@ def is_module_library(fname):
class ModuleReturnValue:
- def __init__(self, return_value: 'TYPE_var', new_objects: T.List['TYPE_var']) -> None:
+ def __init__(self, return_value: T.Optional['TYPE_var'], new_objects: T.List['TYPE_var']) -> None:
self.return_value = return_value
assert(isinstance(new_objects, list))
self.new_objects = new_objects
diff --git a/mesonbuild/modules/cmake.py b/mesonbuild/modules/cmake.py
index b488843..fac3b24 100644
--- a/mesonbuild/modules/cmake.py
+++ b/mesonbuild/modules/cmake.py
@@ -212,6 +212,12 @@ class CmakeModule(ExtensionModule):
def __init__(self, interpreter):
super().__init__(interpreter)
+ self.methods.update({
+ 'write_basic_package_version_file': self.write_basic_package_version_file,
+ 'configure_package_config_file': self.configure_package_config_file,
+ 'subproject': self.subproject,
+ 'subproject_options': self.subproject_options,
+ })
def detect_voidp_size(self, env):
compilers = env.coredata.compilers.host
diff --git a/mesonbuild/modules/dlang.py b/mesonbuild/modules/dlang.py
index 1dcf5e2..f08803d 100644
--- a/mesonbuild/modules/dlang.py
+++ b/mesonbuild/modules/dlang.py
@@ -36,6 +36,9 @@ class DlangModule(ExtensionModule):
def __init__(self, interpreter):
super().__init__(interpreter)
+ self.methods.update({
+ 'generate_dub_file': self.generate_dub_file,
+ })
def _init_dub(self):
if DlangModule.class_dubbin is None:
diff --git a/mesonbuild/modules/fs.py b/mesonbuild/modules/fs.py
index 58cf7e1..caa21f7 100644
--- a/mesonbuild/modules/fs.py
+++ b/mesonbuild/modules/fs.py
@@ -36,6 +36,23 @@ class FSModule(ExtensionModule):
def __init__(self, interpreter: 'Interpreter') -> None:
super().__init__(interpreter)
+ self.methods.update({
+ 'expanduser': self.expanduser,
+ 'is_absolute': self.is_absolute,
+ 'as_posix': self.as_posix,
+ 'exists': self.exists,
+ 'is_symlink': self.is_symlink,
+ 'is_file': self.is_file,
+ 'is_dir': self.is_dir,
+ 'hash': self.hash,
+ 'size': self.size,
+ 'is_samepath': self.is_samepath,
+ 'replace_suffix': self.replace_suffix,
+ 'parent': self.parent,
+ 'name': self.name,
+ 'stem': self.stem,
+ 'read': self.read,
+ })
def _absolute_dir(self, state: 'ModuleState', arg: 'FileOrString') -> Path:
"""
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
index 5a744fe..d2b64dd 100644
--- a/mesonbuild/modules/gnome.py
+++ b/mesonbuild/modules/gnome.py
@@ -57,6 +57,20 @@ class GnomeModule(ExtensionModule):
self.install_gio_querymodules = []
self.install_gtk_update_icon_cache = False
self.devenv = None
+ self.methods.update({
+ 'post_install': self.post_install,
+ 'compile_resources': self.compile_resources,
+ 'generate_gir': self.generate_gir,
+ 'compile_schemas': self.compile_schemas,
+ 'yelp': self.yelp,
+ 'gtkdoc': self.gtkdoc,
+ 'gtkdoc_html_dir': self.gtkdoc_html_dir,
+ 'gdbus_codegen': self.gdbus_codegen,
+ 'mkenums': self.mkenums,
+ 'mkenums_simple': self.mkenums_simple,
+ 'genmarshal': self.genmarshal,
+ 'generate_vapi': self.generate_vapi,
+ })
@staticmethod
def _get_native_glib_version(state):
diff --git a/mesonbuild/modules/hotdoc.py b/mesonbuild/modules/hotdoc.py
index ae8a2c6..90635e6 100644
--- a/mesonbuild/modules/hotdoc.py
+++ b/mesonbuild/modules/hotdoc.py
@@ -405,6 +405,10 @@ class HotDocModule(ExtensionModule):
except Exception as e:
raise MesonException('hotdoc {} required but not found. ({})'.format(
MIN_HOTDOC_VERSION, e))
+ self.methods.update({
+ 'has_extensions': self.has_extensions,
+ 'generate_doc': self.generate_doc,
+ })
@noKwargs
def has_extensions(self, state, args, kwargs):
diff --git a/mesonbuild/modules/i18n.py b/mesonbuild/modules/i18n.py
index b915745..98a8b0d 100644
--- a/mesonbuild/modules/i18n.py
+++ b/mesonbuild/modules/i18n.py
@@ -57,6 +57,12 @@ PRESET_ARGS = {
class I18nModule(ExtensionModule):
+ def __init__(self, interpreter):
+ super().__init__(interpreter)
+ self.methods.update({
+ 'merge_file': self.merge_file,
+ 'gettext': self.gettext,
+ })
@staticmethod
def nogettext_warning():
diff --git a/mesonbuild/modules/keyval.py b/mesonbuild/modules/keyval.py
index 8e43491..d637ac0 100644
--- a/mesonbuild/modules/keyval.py
+++ b/mesonbuild/modules/keyval.py
@@ -25,6 +25,9 @@ class KeyvalModule(ExtensionModule):
@FeatureNew('Keyval Module', '0.55.0')
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
+ self.methods.update({
+ 'load': self.load,
+ })
def _load_file(self, path_to_config):
result = dict()
diff --git a/mesonbuild/modules/modtest.py b/mesonbuild/modules/modtest.py
index 7a4c19d..dd2e2ff 100644
--- a/mesonbuild/modules/modtest.py
+++ b/mesonbuild/modules/modtest.py
@@ -16,6 +16,11 @@ from . import ExtensionModule
from ..interpreterbase import noKwargs
class TestModule(ExtensionModule):
+ def __init__(self, interpreter):
+ super().__init__(interpreter)
+ self.methods.update({
+ 'print_hello': self.print_hello,
+ })
@noKwargs
def print_hello(self, state, args, kwargs):
diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py
index c9d5361..c2f713c 100644
--- a/mesonbuild/modules/pkgconfig.py
+++ b/mesonbuild/modules/pkgconfig.py
@@ -280,6 +280,11 @@ class DependenciesHelper:
self.cflags = _fn(self.cflags)
class PkgConfigModule(ExtensionModule):
+ def __init__(self, interpreter):
+ super().__init__(interpreter)
+ self.methods.update({
+ 'generate': self.generate,
+ })
def _get_lname(self, l, msg, pcfile, is_custom_target):
if is_custom_target:
diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py
index 1efebf8..b7070df 100644
--- a/mesonbuild/modules/python.py
+++ b/mesonbuild/modules/python.py
@@ -473,6 +473,9 @@ class PythonModule(ExtensionModule):
@FeatureNew('Python Module', '0.46.0')
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
+ self.methods.update({
+ 'find_installation': self.find_installation,
+ })
# https://www.python.org/dev/peps/pep-0397/
def _get_win_pythonpath(self, name_or_path):
diff --git a/mesonbuild/modules/python3.py b/mesonbuild/modules/python3.py
index ac71049..dc1f7c7 100644
--- a/mesonbuild/modules/python3.py
+++ b/mesonbuild/modules/python3.py
@@ -25,6 +25,12 @@ class Python3Module(ExtensionModule):
@FeatureDeprecated('python3 module', '0.48.0')
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
+ self.methods.update({
+ 'extension_module': self.extension_module,
+ 'find_python': self.find_python,
+ 'language_version': self.language_version,
+ 'sysconfig_path': self.sysconfig_path,
+ })
@permittedKwargs(known_shmod_kwargs)
def extension_module(self, state, args, kwargs):
diff --git a/mesonbuild/modules/qt.py b/mesonbuild/modules/qt.py
index 7455e8e..b03e750 100644
--- a/mesonbuild/modules/qt.py
+++ b/mesonbuild/modules/qt.py
@@ -46,6 +46,11 @@ class QtBaseModule(ExtensionModule):
self.uic: 'ExternalProgram' = NonExistingExternalProgram('uic')
self.rcc: 'ExternalProgram' = NonExistingExternalProgram('rcc')
self.lrelease: 'ExternalProgram' = NonExistingExternalProgram('lrelease')
+ self.methods.update({
+ 'has_tools': self.has_tools,
+ 'preprocess': self.preprocess,
+ 'compile_translations': self.compile_translations,
+ })
def compilers_detect(self, qt_dep: 'QtBaseDependency') -> None:
"""Detect Qt (4 or 5) moc, uic, rcc in the specified bindir or in PATH"""
diff --git a/mesonbuild/modules/rpm.py b/mesonbuild/modules/rpm.py
index 7638a45..704e82b 100644
--- a/mesonbuild/modules/rpm.py
+++ b/mesonbuild/modules/rpm.py
@@ -26,18 +26,22 @@ from ..interpreterbase import noKwargs
import os
class RPMModule(ExtensionModule):
+ def __init__(self, interpreter):
+ super().__init__(interpreter)
+ self.methods.update({
+ 'generate_spec_template': self.generate_spec_template,
+ })
@noKwargs
- def generate_spec_template(self, coredata, args, kwargs):
- self.coredata = coredata
- required_compilers = self.__get_required_compilers()
- proj = coredata.project_name.replace(' ', '_').replace('\t', '_')
+ def generate_spec_template(self, state, args, kwargs):
+ required_compilers = self.__get_required_compilers(state)
+ proj = state.project_name.replace(' ', '_').replace('\t', '_')
so_installed = False
devel_subpkg = False
files = set()
files_devel = set()
to_delete = set()
- for target in coredata.targets.values():
+ for target in state.targets.values():
if isinstance(target, build.Executable) and target.need_install:
files.add('%%{_bindir}/%s' % target.get_filename())
elif isinstance(target, build.SharedLibrary) and target.need_install:
@@ -56,13 +60,13 @@ class RPMModule(ExtensionModule):
files_devel.add('%%{_datadir}/gir-1.0/%s' % target.get_filename()[0])
elif isinstance(target, TypelibTarget) and target.should_install():
files.add('%%{_libdir}/girepository-1.0/%s' % target.get_filename()[0])
- for header in coredata.headers:
+ for header in state.headers:
if header.get_install_subdir():
files_devel.add('%%{_includedir}/%s/' % header.get_install_subdir())
else:
for hdr_src in header.get_sources():
files_devel.add('%%{_includedir}/%s' % hdr_src)
- for man in coredata.man:
+ for man in state.man:
for man_file in man.get_sources():
if man.locale:
files.add('%%{_mandir}/%s/man%u/%s.*' % (man.locale, int(man_file.split('.')[-1]), man_file))
@@ -71,7 +75,7 @@ class RPMModule(ExtensionModule):
if files_devel:
devel_subpkg = True
- filename = os.path.join(coredata.environment.get_build_dir(),
+ filename = os.path.join(state.environment.get_build_dir(),
'%s.spec' % proj)
with open(filename, 'w+') as fn:
fn.write('Name: %s\n' % proj)
@@ -85,7 +89,7 @@ class RPMModule(ExtensionModule):
fn.write('BuildRequires: meson\n')
for compiler in required_compilers:
fn.write('BuildRequires: %s\n' % compiler)
- for dep in coredata.environment.coredata.deps.host:
+ for dep in state.environment.coredata.deps.host:
fn.write('BuildRequires: pkgconfig(%s)\n' % dep[0])
# ext_libs and ext_progs have been removed from coredata so the following code
# no longer works. It is kept as a reminder of the idea should anyone wish
@@ -150,9 +154,9 @@ class RPMModule(ExtensionModule):
fn.write('\n')
mlog.log('RPM spec template written to %s.spec.\n' % proj)
- def __get_required_compilers(self):
+ def __get_required_compilers(self, state):
required_compilers = set()
- for compiler in self.coredata.environment.coredata.compilers.host.values():
+ for compiler in state.environment.coredata.compilers.host.values():
# Elbrus has one 'lcc' package for every compiler
if isinstance(compiler, compilers.GnuCCompiler):
required_compilers.add('gcc')
diff --git a/mesonbuild/modules/sourceset.py b/mesonbuild/modules/sourceset.py
index 1340959..e413e32 100644
--- a/mesonbuild/modules/sourceset.py
+++ b/mesonbuild/modules/sourceset.py
@@ -189,6 +189,9 @@ class SourceSetModule(ExtensionModule):
@FeatureNew('SourceSet module', '0.51.0')
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
+ self.methods.update({
+ 'source_set': self.source_set,
+ })
@noKwargs
@noPosargs
diff --git a/mesonbuild/modules/unstable_icestorm.py b/mesonbuild/modules/unstable_icestorm.py
index 8746870..be83885 100644
--- a/mesonbuild/modules/unstable_icestorm.py
+++ b/mesonbuild/modules/unstable_icestorm.py
@@ -24,6 +24,9 @@ class IceStormModule(ExtensionModule):
def __init__(self, interpreter):
super().__init__(interpreter)
self.yosys_bin = None
+ self.methods.update({
+ 'project': self.project,
+ })
def detect_binaries(self, interpreter):
self.yosys_bin = interpreter.find_program_impl(['yosys'])
diff --git a/mesonbuild/modules/unstable_rust.py b/mesonbuild/modules/unstable_rust.py
index 0f64df8..30dea9f 100644
--- a/mesonbuild/modules/unstable_rust.py
+++ b/mesonbuild/modules/unstable_rust.py
@@ -38,6 +38,10 @@ class RustModule(ExtensionModule):
def __init__(self, interpreter: 'Interpreter') -> None:
super().__init__(interpreter)
self._bindgen_bin: T.Optional['ExternalProgram'] = None
+ self.methods.update({
+ 'test': self.test,
+ 'bindgen': self.bindgen,
+ })
@permittedKwargs(permitted_test_kwargs | {'dependencies'} ^ {'protocol'})
@typed_pos_args('rust.test', str, BuildTargetHolder)
diff --git a/mesonbuild/modules/unstable_simd.py b/mesonbuild/modules/unstable_simd.py
index 5f8edfd..df5faa1 100644
--- a/mesonbuild/modules/unstable_simd.py
+++ b/mesonbuild/modules/unstable_simd.py
@@ -35,6 +35,9 @@ class SimdModule(ExtensionModule):
'avx2',
'neon',
)
+ self.methods.update({
+ 'check': self.check,
+ })
def check(self, state, args, kwargs):
result = []
diff --git a/mesonbuild/modules/windows.py b/mesonbuild/modules/windows.py
index c4fdc19..441fb9f 100644
--- a/mesonbuild/modules/windows.py
+++ b/mesonbuild/modules/windows.py
@@ -30,6 +30,11 @@ class ResourceCompilerType(enum.Enum):
rc = 2
class WindowsModule(ExtensionModule):
+ def __init__(self, interpreter):
+ super().__init__(interpreter)
+ self.methods.update({
+ 'compile_resources': self.compile_resources,
+ })
def detect_compiler(self, compilers):
for l in ('c', 'cpp'):