Converted some modules.

pull/2001/head
Jussi Pakkanen 8 years ago
parent 7f482824bb
commit 80d665e8de
  1. 13
      mesonbuild/modules/__init__.py
  2. 22
      mesonbuild/modules/gnome.py
  3. 4
      mesonbuild/modules/i18n.py
  4. 1
      mesonbuild/modules/modtest.py
  5. 4
      mesonbuild/modules/pkgconfig.py
  6. 13
      mesonbuild/modules/python3.py

@ -5,6 +5,19 @@ from .. import dependencies
from ..mesonlib import MesonException from ..mesonlib import MesonException
from ..interpreterbase import permittedKwargs, noKwargs from ..interpreterbase import permittedKwargs, noKwargs
class permittedSnippetKwargs:
def __init__(self, permitted):
self.permitted = permitted
def __call__(self, f):
def wrapped(s, interpreter, state, args, kwargs):
for k in kwargs:
if k not in self.permitted:
raise InvalidArguments('Invalid keyword argument %s.' % k)
return f(s, interpreter, state, args, kwargs)
return wrapped
_found_programs = {} _found_programs = {}

@ -30,6 +30,7 @@ from .. import interpreter
from . import GResourceTarget, GResourceHeaderTarget, GirTarget, TypelibTarget, VapiTarget from . import GResourceTarget, GResourceHeaderTarget, GirTarget, TypelibTarget, VapiTarget
from . import find_program, get_include_args from . import find_program, get_include_args
from . import ExtensionModule from . import ExtensionModule
from . import noKwargs, permittedKwargs
# gresource compilation is broken due to the way # gresource compilation is broken due to the way
@ -90,6 +91,8 @@ class GnomeModule(ExtensionModule):
mlog.bold('https://github.com/mesonbuild/meson/issues/1387')) mlog.bold('https://github.com/mesonbuild/meson/issues/1387'))
gdbuswarning_printed = True gdbuswarning_printed = True
@permittedKwargs(set(['source_dir', 'c_name', 'dependencies', 'export', 'gresource_bundle', 'install_header',
'install', 'install_dir', 'extra_args']))
def compile_resources(self, state, args, kwargs): def compile_resources(self, state, args, kwargs):
self.__print_gresources_warning(state) self.__print_gresources_warning(state)
glib_version = self._get_native_glib_version(state) glib_version = self._get_native_glib_version(state)
@ -377,6 +380,10 @@ class GnomeModule(ExtensionModule):
return cflags, ldflags, gi_includes return cflags, ldflags, gi_includes
@permittedKwargs(set(['sources', 'nsversion', 'namespace', 'symbol_prefix', 'identifier_prefix',
'export_packagse', 'includes', 'dependencies', 'link_with', 'include_directories',
'install', 'install_dir_gir', 'install_dir_typelib', 'extra_args',
'packages']))
def generate_gir(self, state, args, kwargs): def generate_gir(self, state, args, kwargs):
if len(args) != 1: if len(args) != 1:
raise MesonException('Gir takes one argument') raise MesonException('Gir takes one argument')
@ -595,6 +602,7 @@ class GnomeModule(ExtensionModule):
rv = [scan_target, typelib_target] rv = [scan_target, typelib_target]
return ModuleReturnValue(rv, rv) return ModuleReturnValue(rv, rv)
@noKwargs
def compile_schemas(self, state, args, kwargs): def compile_schemas(self, state, args, kwargs):
if args: if args:
raise MesonException('Compile_schemas does not take positional arguments.') raise MesonException('Compile_schemas does not take positional arguments.')
@ -613,6 +621,7 @@ class GnomeModule(ExtensionModule):
target_g = build.CustomTarget(targetname, state.subdir, kwargs) target_g = build.CustomTarget(targetname, state.subdir, kwargs)
return ModuleReturnValue(target_g, [target_g]) return ModuleReturnValue(target_g, [target_g])
@permittedKwargs(set(['sources', 'media', 'symlink_media', 'languages']))
def yelp(self, state, args, kwargs): def yelp(self, state, args, kwargs):
if len(args) < 1: if len(args) < 1:
raise MesonException('Yelp requires a project id') raise MesonException('Yelp requires a project id')
@ -670,6 +679,10 @@ class GnomeModule(ExtensionModule):
rv = [inscript, pottarget, potarget] rv = [inscript, pottarget, potarget]
return ModuleReturnValue(None, rv) return ModuleReturnValue(None, rv)
@permittedKwargs(set(['main_xml', 'main_sgml', 'src_dir', 'dependencies', 'install',
'install_dir', 'scan_args', 'scanobjs_args', 'gobject_typesfile',
'fixxref_args', 'html_args', 'html_assets', 'content_files',
'mkdb_args']))
def gtkdoc(self, state, args, kwargs): def gtkdoc(self, state, args, kwargs):
if len(args) != 1: if len(args) != 1:
raise MesonException('Gtkdoc must have one positional argument.') raise MesonException('Gtkdoc must have one positional argument.')
@ -763,6 +776,7 @@ class GnomeModule(ExtensionModule):
return args return args
@noKwargs
def gtkdoc_html_dir(self, state, args, kwargs): def gtkdoc_html_dir(self, state, args, kwargs):
if len(args) != 1: if len(args) != 1:
raise MesonException('Must have exactly one argument.') raise MesonException('Must have exactly one argument.')
@ -792,6 +806,7 @@ class GnomeModule(ExtensionModule):
return [] return []
@permittedKwargs(set(['interface_prefix', 'namespace', 'object_manager']))
def gdbus_codegen(self, state, args, kwargs): def gdbus_codegen(self, state, args, kwargs):
if len(args) != 2: if len(args) != 2:
raise MesonException('Gdbus_codegen takes two arguments, name and xml file.') raise MesonException('Gdbus_codegen takes two arguments, name and xml file.')
@ -820,6 +835,9 @@ class GnomeModule(ExtensionModule):
ct = build.CustomTarget(target_name, state.subdir, custom_kwargs) ct = build.CustomTarget(target_name, state.subdir, custom_kwargs)
return ModuleReturnValue(ct, [ct]) return ModuleReturnValue(ct, [ct])
@permittedKwargs(set(['sources', 'c_template', 'h_template', 'install_header', 'install_dir',
'comments', 'identifier_prefix', 'symbol_prefix', 'eprod', 'vprod',
'fhead', 'fprod', 'ftail', 'vhead', 'vtail', 'depends']))
def mkenums(self, state, args, kwargs): def mkenums(self, state, args, kwargs):
if len(args) != 1: if len(args) != 1:
raise MesonException('Mkenums requires one positional argument.') raise MesonException('Mkenums requires one positional argument.')
@ -932,6 +950,8 @@ class GnomeModule(ExtensionModule):
# https://github.com/mesonbuild/meson/issues/973 # https://github.com/mesonbuild/meson/issues/973
absolute_paths=True) absolute_paths=True)
@permittedKwargs(set(['sources', 'prefix', 'install_header', 'install_dir', 'stdinc',
'nostdinc', 'internal', 'skip_source', 'valist_marshallers']))
def genmarshal(self, state, args, kwargs): def genmarshal(self, state, args, kwargs):
if len(args) != 1: if len(args) != 1:
raise MesonException( raise MesonException(
@ -1070,6 +1090,8 @@ class GnomeModule(ExtensionModule):
link_with += self._get_vapi_link_with(dep) link_with += self._get_vapi_link_with(dep)
return link_with return link_with
@permittedKwargs(set(['sources', 'packages', 'metadata_dirs', 'gir_dirs',
'vapi_dirs', 'install', 'install_dir']))
def generate_vapi(self, state, args, kwargs): def generate_vapi(self, state, args, kwargs):
if len(args) != 1: if len(args) != 1:
raise MesonException('The library name is required') raise MesonException('The library name is required')

@ -20,6 +20,7 @@ from .. import coredata, mesonlib, build
from ..mesonlib import MesonException from ..mesonlib import MesonException
from . import ModuleReturnValue from . import ModuleReturnValue
from . import ExtensionModule from . import ExtensionModule
from . import permittedKwargs
PRESET_ARGS = { PRESET_ARGS = {
'glib': [ 'glib': [
@ -55,6 +56,8 @@ class I18nModule(ExtensionModule):
src_dir = path.join(state.environment.get_source_dir(), state.subdir) src_dir = path.join(state.environment.get_source_dir(), state.subdir)
return [path.join(src_dir, d) for d in dirs] return [path.join(src_dir, d) for d in dirs]
@permittedKwargs(set(['languages', 'data_dirs', 'preset', 'args', 'po_dir', 'type',
'input', 'output', 'install', 'install_dir']))
def merge_file(self, state, args, kwargs): def merge_file(self, state, args, kwargs):
podir = kwargs.pop('po_dir', None) podir = kwargs.pop('po_dir', None)
if not podir: if not podir:
@ -78,6 +81,7 @@ class I18nModule(ExtensionModule):
ct = build.CustomTarget(kwargs['output'] + '_merge', state.subdir, kwargs) ct = build.CustomTarget(kwargs['output'] + '_merge', state.subdir, kwargs)
return ModuleReturnValue(ct, [ct]) return ModuleReturnValue(ct, [ct])
@permittedKwargs(set(['po_dir', 'data_dirs', 'type', 'languages']))
def gettext(self, state, args, kwargs): def gettext(self, state, args, kwargs):
if len(args) != 1: if len(args) != 1:
raise coredata.MesonException('Gettext requires one positional argument (package name).') raise coredata.MesonException('Gettext requires one positional argument (package name).')

@ -18,7 +18,6 @@ from . import noKwargs
class TestModule(ExtensionModule): class TestModule(ExtensionModule):
@noKwargs
def print_hello(self, state, args, kwargs): def print_hello(self, state, args, kwargs):
print('Hello from a Meson module') print('Hello from a Meson module')
rv = ModuleReturnValue(None, []) rv = ModuleReturnValue(None, [])

@ -19,6 +19,7 @@ from .. import mesonlib
from .. import mlog from .. import mlog
from . import ModuleReturnValue from . import ModuleReturnValue
from . import ExtensionModule from . import ExtensionModule
from . import permittedKwargs
class PkgConfigModule(ExtensionModule): class PkgConfigModule(ExtensionModule):
@ -114,6 +115,9 @@ class PkgConfigModule(ExtensionModule):
processed_libs.append(l) processed_libs.append(l)
return processed_libs return processed_libs
@permittedKwargs(set(['libraries', 'version', 'name', 'description', 'filebase',
'subdirs', 'requires', 'requires_private', 'libraries_private',
'install_dir', 'variables']))
def generate(self, state, args, kwargs): def generate(self, state, args, kwargs):
if len(args) > 0: if len(args) > 0:
raise mesonlib.MesonException('Pkgconfig_gen takes no positional arguments.') raise mesonlib.MesonException('Pkgconfig_gen takes no positional arguments.')

@ -18,6 +18,11 @@ from .. import mesonlib, dependencies
from . import ExtensionModule from . import ExtensionModule
from mesonbuild.modules import ModuleReturnValue from mesonbuild.modules import ModuleReturnValue
from . import noKwargs, permittedSnippetKwargs
from ..interpreter import shlib_kwargs
mod_kwargs = set()
mod_kwargs.update(shlib_kwargs)
class Python3Module(ExtensionModule): class Python3Module(ExtensionModule):
@ -25,6 +30,7 @@ class Python3Module(ExtensionModule):
super().__init__() super().__init__()
self.snippets.add('extension_module') self.snippets.add('extension_module')
@permittedSnippetKwargs(mod_kwargs)
def extension_module(self, interpreter, state, args, kwargs): def extension_module(self, interpreter, state, args, kwargs):
if 'name_prefix' in kwargs: if 'name_prefix' in kwargs:
raise mesonlib.MesonException('Name_prefix is set automatically, specifying it is forbidden.') raise mesonlib.MesonException('Name_prefix is set automatically, specifying it is forbidden.')
@ -43,20 +49,19 @@ class Python3Module(ExtensionModule):
kwargs['name_suffix'] = suffix kwargs['name_suffix'] = suffix
return interpreter.func_shared_module(None, args, kwargs) return interpreter.func_shared_module(None, args, kwargs)
@noKwargs
def find_python(self, state, args, kwargs): def find_python(self, state, args, kwargs):
py3 = dependencies.ExternalProgram('python3', sys.executable, silent=True) py3 = dependencies.ExternalProgram('python3', sys.executable, silent=True)
return ModuleReturnValue(py3, [py3]) return ModuleReturnValue(py3, [py3])
@noKwargs
def language_version(self, state, args, kwargs): def language_version(self, state, args, kwargs):
if args or kwargs:
raise mesonlib.MesonException('language_version() takes no arguments.')
return ModuleReturnValue(sysconfig.get_python_version(), []) return ModuleReturnValue(sysconfig.get_python_version(), [])
@noKwargs
def sysconfig_path(self, state, args, kwargs): def sysconfig_path(self, state, args, kwargs):
if len(args) != 1: if len(args) != 1:
raise mesonlib.MesonException('sysconfig_path() requires passing the name of path to get.') raise mesonlib.MesonException('sysconfig_path() requires passing the name of path to get.')
if kwargs:
raise mesonlib.MesonException('sysconfig_path() does not accept keywords.')
path_name = args[0] path_name = args[0]
valid_names = sysconfig.get_path_names() valid_names = sysconfig.get_path_names()
if path_name not in valid_names: if path_name not in valid_names:

Loading…
Cancel
Save