diff options
Diffstat (limited to 'mesonbuild/modules/gnome.py')
-rw-r--r-- | mesonbuild/modules/gnome.py | 637 |
1 files changed, 382 insertions, 255 deletions
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index 326f56b..8e8349b 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -16,6 +16,7 @@ functionality such as gobject-introspection, gresources and gtk-doc''' import copy +import itertools import functools import os import subprocess @@ -29,16 +30,17 @@ from .. import build from .. import interpreter from .. import mesonlib from .. import mlog -from ..build import CustomTarget, CustomTargetIndex, GeneratedList, InvalidArguments +from ..build import BuildTarget, CustomTarget, CustomTargetIndex, Executable, GeneratedList, InvalidArguments from ..dependencies import Dependency, PkgConfigDependency, InternalDependency from ..interpreter.type_checking import DEPENDS_KW, DEPEND_FILES_KW, INSTALL_KW, NoneType, in_set_validator -from ..interpreterbase import noPosargs, noKwargs, permittedKwargs, FeatureNew, FeatureDeprecated +from ..interpreterbase import noPosargs, noKwargs, FeatureNew, FeatureDeprecated from ..interpreterbase import typed_kwargs, KwargInfo, ContainerTypeInfo from ..interpreterbase.decorators import typed_pos_args from ..mesonlib import ( MachineChoice, MesonException, OrderedSet, Popen_safe, join_args, ) from ..programs import ExternalProgram, OverrideProgram, EmptyExternalProgram +from ..scripts.gettext import read_linguas if T.TYPE_CHECKING: from typing_extensions import Literal, TypedDict @@ -118,9 +120,9 @@ if T.TYPE_CHECKING: install_dir: T.List[str] check: bool install: bool - gobject_typesfile: T.List[str] - html_assets: T.List[str] - expand_content_files: T.List[str] + gobject_typesfile: T.List[FileOrString] + html_assets: T.List[FileOrString] + expand_content_files: T.List[FileOrString] c_args: T.List[str] include_directories: T.List[T.Union[str, build.IncludeDirs]] dependencies: T.List[T.Union[Dependency, build.SharedLibrary, build.StaticLibrary]] @@ -133,7 +135,7 @@ if T.TYPE_CHECKING: namespace: T.Optional[str] object_manager: bool build_by_default: bool - annotations: T.List[str] + annotations: T.List[T.List[str]] install_header: bool install_dir: T.Optional[str] docbook: T.Optional[str] @@ -152,7 +154,7 @@ if T.TYPE_CHECKING: nostdinc: bool prefix: T.Optional[str] skip_source: bool - sources: T.List[str] + sources: T.List[FileOrString] stdinc: bool valist_marshallers: bool @@ -166,6 +168,36 @@ if T.TYPE_CHECKING: gir_dirs: T.List[str] packages: T.List[T.Union[str, InternalDependency]] + class _MkEnumsCommon(TypedDict): + + sources: T.List[T.Union[FileOrString, build.GeneratedTypes]] + install_header: bool + install_dir: T.Optional[str] + identifier_prefix: T.Optional[str] + symbol_prefix: T.Optional[str] + + class MkEnumsSimple(_MkEnumsCommon): + + header_prefix: str + decorator: str + function_prefix: str + body_prefix: str + + class MkEnums(_MkEnumsCommon): + + c_template: T.Optional[FileOrString] + h_template: T.Optional[FileOrString] + comments: T.Optional[str] + eprod: T.Optional[str] + fhead: T.Optional[str] + fprod: T.Optional[str] + ftail: T.Optional[str] + vhead: T.Optional[str] + vprod: T.Optional[str] + vtail: T.Optional[str] + depends: T.List[T.Union[BuildTarget, CustomTarget, CustomTargetIndex]] + + # Differs from the CustomTarget version in that it straight defaults to True _BUILD_BY_DEFAULT: KwargInfo[bool] = KwargInfo( 'build_by_default', bool, default=True, @@ -178,6 +210,40 @@ _EXTRA_ARGS_KW: KwargInfo[T.List[str]] = KwargInfo( listify=True, ) +_MK_ENUMS_COMMON_KWS: T.List[KwargInfo] = [ + INSTALL_KW.evolve(name='install_header'), + KwargInfo( + 'sources', + ContainerTypeInfo(list, (str, mesonlib.File, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList)), + listify=True, + required=True, + ), + KwargInfo('install_dir', (str, NoneType)), + KwargInfo('identifier_prefix', (str, NoneType)), + KwargInfo('symbol_prefix', (str, NoneType)), +] + +def annotations_validator(annotations: T.List[T.Union[str, T.List[str]]]) -> T.Optional[str]: + + """Validate gdbus-codegen annotations argument""" + + badlist = 'must be made up of 3 strings for ELEMENT, KEY, and VALUE' + + if all(isinstance(annot, str) for annot in annotations): + if len(annotations) == 3: + return None + else: + return badlist + elif not all(isinstance(annot, list) for annot in annotations): + for c, annot in enumerate(annotations): + if not isinstance(annot, list): + return f'element {c+1} must be a list' + else: + for c, annot in enumerate(annotations): + if len(annot) != 3 or not all(isinstance(i, str) for i in annot): + return f'element {c+1} {badlist}' + return None + # gresource compilation is broken due to the way # the resource compiler and Ninja clash about it # @@ -190,12 +256,14 @@ native_glib_version = None class GnomeModule(ExtensionModule): def __init__(self, interpreter: 'Interpreter') -> None: super().__init__(interpreter) - self.gir_dep = None + self.gir_dep: T.Optional[Dependency] = None + self.giscanner: T.Optional[T.Union[ExternalProgram, build.Executable, OverrideProgram]] = None + self.gicompiler: T.Optional[T.Union[ExternalProgram, build.Executable, OverrideProgram]] = None self.install_glib_compile_schemas = False - self.install_gio_querymodules = [] + self.install_gio_querymodules: T.List[str] = [] self.install_gtk_update_icon_cache = False self.install_update_desktop_database = False - self.devenv = None + self.devenv: T.Optional[build.EnvironmentVariables] = None self.methods.update({ 'post_install': self.post_install, 'compile_resources': self.compile_resources, @@ -243,7 +311,10 @@ class GnomeModule(ExtensionModule): def _get_dep(self, state: 'ModuleState', depname: str, native: bool = False, required: bool = True) -> Dependency: kwargs = {'native': native, 'required': required} - return self.interpreter.func_dependency(state.current_node, [depname], kwargs) + # FIXME: Even if we fix the function, mypy still can't figure out what's + # going on here. And we really dont want to call interpreter + # implementations of meson functions anyway. + return self.interpreter.func_dependency(state.current_node, [depname], kwargs) # type: ignore def _get_native_binary(self, state: 'ModuleState', name: str, depname: str, varname: str, required: bool = True) -> T.Union[ExternalProgram, OverrideProgram, 'build.Executable']: @@ -260,7 +331,7 @@ class GnomeModule(ExtensionModule): # Check if pkgconfig has a variable dep = self._get_dep(state, depname, native=True, required=False) if dep.found() and dep.type_name == 'pkgconfig': - value = dep.get_pkgconfig_variable(varname, {}) + value = dep.get_pkgconfig_variable(varname, [], None) if value: return ExternalProgram(name, [value]) @@ -450,8 +521,9 @@ class GnomeModule(ExtensionModule): rv = [target_c, target_h] return ModuleReturnValue(rv, rv) + @staticmethod def _get_gresource_dependencies( - self, state: 'ModuleState', input_file: str, source_dirs: T.List[str], + state: 'ModuleState', input_file: str, source_dirs: T.List[str], dependencies: T.Sequence[T.Union[mesonlib.File, build.CustomTarget, build.CustomTargetIndex]] ) -> T.Tuple[T.List[mesonlib.FileOrString], T.List[T.Union[build.CustomTarget, build.CustomTargetIndex]], T.List[str]]: @@ -525,17 +597,19 @@ class GnomeModule(ExtensionModule): def _get_link_args(self, state: 'ModuleState', lib: T.Union[build.SharedLibrary, build.StaticLibrary], - depends: T.List[build.BuildTarget], + depends: T.Sequence[T.Union[build.BuildTarget, 'build.GeneratedTypes', 'FileOrString']], include_rpath: bool = False, - use_gir_args: bool = False) -> T.List[str]: + use_gir_args: bool = False + ) -> T.Tuple[T.List[str], T.List[T.Union[build.BuildTarget, 'build.GeneratedTypes', 'FileOrString']]]: link_command: T.List[str] = [] + new_depends = list(depends) # Construct link args if isinstance(lib, build.SharedLibrary): libdir = os.path.join(state.environment.get_build_dir(), state.backend.get_target_dir(lib)) link_command.append('-L' + libdir) if include_rpath: link_command.append('-Wl,-rpath,' + libdir) - depends.append(lib) + new_depends.append(lib) # Needed for the following binutils bug: # https://github.com/mesonbuild/meson/issues/1911 # However, g-ir-scanner does not understand -Wl,-rpath @@ -549,13 +623,17 @@ class GnomeModule(ExtensionModule): link_command.append('--extra-library=' + lib.name) else: link_command.append('-l' + lib.name) - return link_command + return link_command, new_depends def _get_dependencies_flags( - self, deps: T.Sequence[T.Union['Dependency', build.SharedLibrary, build.StaticLibrary]], - state: 'ModuleState', depends: T.List[build.BuildTarget], include_rpath: bool = False, - use_gir_args: bool = False, separate_nodedup: bool = False - ) -> T.Tuple[OrderedSet[str], OrderedSet[str], OrderedSet[str], T.Optional[T.List[str]], OrderedSet[str]]: + self, deps: T.Sequence[T.Union['Dependency', build.BuildTarget, build.CustomTarget, build.CustomTargetIndex]], + state: 'ModuleState', + depends: T.Sequence[T.Union[build.BuildTarget, 'build.GeneratedTypes', 'FileOrString']], + include_rpath: bool = False, + use_gir_args: bool = False, + separate_nodedup: bool = False + ) -> T.Tuple[OrderedSet[str], OrderedSet[str], OrderedSet[str], T.Optional[T.List[str]], OrderedSet[str], + T.List[T.Union[build.BuildTarget, 'build.GeneratedTypes', 'FileOrString']]]: cflags: OrderedSet[str] = OrderedSet() internal_ldflags: OrderedSet[str] = OrderedSet() external_ldflags: OrderedSet[str] = OrderedSet() @@ -564,6 +642,7 @@ class GnomeModule(ExtensionModule): external_ldflags_nodedup: T.List[str] = [] gi_includes: OrderedSet[str] = OrderedSet() deps = mesonlib.listify(deps) + depends = list(depends) for dep in deps: if isinstance(dep, Dependency): @@ -576,7 +655,8 @@ class GnomeModule(ExtensionModule): cflags.update(state.get_include_args(dep.include_directories)) for lib in dep.libraries: if isinstance(lib, build.SharedLibrary): - internal_ldflags.update(self._get_link_args(state, lib, depends, include_rpath)) + _ld, depends = self._get_link_args(state, lib, depends, include_rpath) + internal_ldflags.update(_ld) libdepflags = self._get_dependencies_flags(lib.get_external_deps(), state, depends, include_rpath, use_gir_args, True) cflags.update(libdepflags[0]) @@ -640,9 +720,9 @@ class GnomeModule(ExtensionModule): external_ldflags = fix_ldflags(external_ldflags) if not separate_nodedup: external_ldflags.update(external_ldflags_nodedup) - return cflags, internal_ldflags, external_ldflags, None, gi_includes + return cflags, internal_ldflags, external_ldflags, None, gi_includes, depends else: - return cflags, internal_ldflags, external_ldflags, external_ldflags_nodedup, gi_includes + return cflags, internal_ldflags, external_ldflags, external_ldflags_nodedup, gi_includes, depends def _unwrap_gir_target(self, girtarget: T.Union[build.Executable, build.StaticLibrary, build.SharedLibrary], state: 'ModuleState' ) -> T.Union[build.Executable, build.StaticLibrary, build.SharedLibrary]: @@ -684,7 +764,8 @@ class GnomeModule(ExtensionModule): return p.returncode == 0 and option in o # May mutate depends and gir_inc_dirs - def _scan_include(self, state: 'ModuleState', includes: T.List[T.Union[str, GirTarget]] + @staticmethod + def _scan_include(state: 'ModuleState', includes: T.List[T.Union[str, GirTarget]] ) -> T.Tuple[T.List[str], T.List[str], T.List[GirTarget]]: ret: T.List[str] = [] gir_inc_dirs: T.List[str] = [] @@ -700,7 +781,8 @@ class GnomeModule(ExtensionModule): return ret, gir_inc_dirs, depends - def _scan_langs(self, state: 'ModuleState', langs: T.Iterable[str]) -> T.List[str]: + @staticmethod + def _scan_langs(state: 'ModuleState', langs: T.Iterable[str]) -> T.List[str]: ret: T.List[str] = [] for lang in langs: @@ -711,7 +793,8 @@ class GnomeModule(ExtensionModule): return ret - def _scan_gir_targets(self, state: 'ModuleState', girtargets: T.List[build.BuildTarget]) -> T.List[T.Union[str, build.Executable]]: + @staticmethod + def _scan_gir_targets(state: 'ModuleState', girtargets: T.Sequence[build.BuildTarget]) -> T.List[T.Union[str, build.Executable]]: ret: T.List[T.Union[str, build.Executable]] = [] for girtarget in girtargets: @@ -744,7 +827,8 @@ class GnomeModule(ExtensionModule): return ret - def _get_girtargets_langs_compilers(self, girtargets: T.Sequence[build.BuildTarget]) -> T.List[T.Tuple[str, 'Compiler']]: + @staticmethod + def _get_girtargets_langs_compilers(girtargets: T.Sequence[build.BuildTarget]) -> T.List[T.Tuple[str, 'Compiler']]: ret: T.List[T.Tuple[str, 'Compiler']] = [] for girtarget in girtargets: for lang, compiler in girtarget.compilers.items(): @@ -755,21 +839,24 @@ class GnomeModule(ExtensionModule): return ret - def _get_gir_targets_deps(self, girtargets: T.Sequence[build.BuildTarget] - ) -> T.List[T.Union[build.Target, Dependency]]: - ret: T.List[T.Union[build.Target, Dependency]] = [] + @staticmethod + def _get_gir_targets_deps(girtargets: T.Sequence[build.BuildTarget] + ) -> T.List[T.Union[build.BuildTarget, build.CustomTarget, build.CustomTargetIndex, Dependency]]: + ret: T.List[T.Union[build.BuildTarget, build.CustomTarget, build.CustomTargetIndex, Dependency]] = [] for girtarget in girtargets: ret += girtarget.get_all_link_deps() ret += girtarget.get_external_deps() return ret - def _get_gir_targets_inc_dirs(self, girtargets: T.List[build.BuildTarget]) -> T.List[build.IncludeDirs]: + @staticmethod + def _get_gir_targets_inc_dirs(girtargets: T.Sequence[build.BuildTarget]) -> T.List[build.IncludeDirs]: ret: T.List[build.IncludeDirs] = [] for girtarget in girtargets: ret += girtarget.get_include_dirs() return ret - def _get_langs_compilers_flags(self, state: 'ModuleState', langs_compilers: T.List[T.Tuple[str, 'Compiler']] + @staticmethod + def _get_langs_compilers_flags(state: 'ModuleState', langs_compilers: T.List[T.Tuple[str, 'Compiler']] ) -> T.Tuple[T.List[str], T.List[str], T.List[str]]: cflags: T.List[str] = [] internal_ldflags: T.List[str] = [] @@ -797,8 +884,9 @@ class GnomeModule(ExtensionModule): return cflags, internal_ldflags, external_ldflags - def _make_gir_filelist(self, state: 'ModuleState', srcdir: str, ns: str, - nsversion: str, girtargets: T.List[build.BuildTarget], + @staticmethod + def _make_gir_filelist(state: 'ModuleState', srcdir: str, ns: str, + nsversion: str, girtargets: T.Sequence[build.BuildTarget], libsources: T.Sequence[T.Union[ str, mesonlib.File, build.GeneratedList, build.CustomTarget, build.CustomTargetIndex]] @@ -825,9 +913,14 @@ class GnomeModule(ExtensionModule): return gir_filelist_filename - def _make_gir_target(self, state: 'ModuleState', girfile: str, scan_command: T.List[str], - generated_files: T.Sequence[T.Union[str, mesonlib.File, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList]], - depends: T.List[build.Target], kwargs: T.Dict[str, T.Any]) -> GirTarget: + @staticmethod + def _make_gir_target( + state: 'ModuleState', + girfile: str, + scan_command: T.Sequence[T.Union['FileOrString', Executable, ExternalProgram, OverrideProgram]], + generated_files: T.Sequence[T.Union[str, mesonlib.File, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList]], + depends: T.Sequence[T.Union['FileOrString', build.BuildTarget, 'build.GeneratedTypes']], + kwargs: T.Dict[str, T.Any]) -> GirTarget: install = kwargs['install_gir'] if install is None: install = kwargs['install'] @@ -851,7 +944,9 @@ class GnomeModule(ExtensionModule): return GirTarget(girfile, state.subdir, state.subproject, scankwargs) - def _make_typelib_target(self, state: 'ModuleState', typelib_output: str, typelib_cmd: T.List[str], + @staticmethod + def _make_typelib_target(state: 'ModuleState', typelib_output: str, + typelib_cmd: T.Sequence[T.Union[str, build.Executable, ExternalProgram, build.CustomTarget]], generated_files: T.Sequence[T.Union[str, mesonlib.File, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList]], kwargs: T.Dict[str, T.Any]) -> TypelibTarget: install = kwargs['install_typelib'] @@ -867,7 +962,7 @@ class GnomeModule(ExtensionModule): typelib_kwargs = { 'input': generated_files, 'output': [typelib_output], - 'command': typelib_cmd, + 'command': list(typelib_cmd), 'install': install, 'install_dir': install_dir, 'install_tag': 'typelib', @@ -876,19 +971,24 @@ class GnomeModule(ExtensionModule): return TypelibTarget(typelib_output, state.subdir, state.subproject, typelib_kwargs) - # May mutate depends - def _gather_typelib_includes_and_update_depends(self, state: 'ModuleState', deps: T.List[Dependency], depends: T.List[build.Target]) -> T.List[str]: + @staticmethod + def _gather_typelib_includes_and_update_depends( + state: 'ModuleState', + deps: T.Sequence[T.Union[Dependency, build.BuildTarget, build.CustomTarget, build.CustomTargetIndex]], + depends: T.Sequence[T.Union[build.BuildTarget, 'build.GeneratedTypes', 'FileOrString']] + ) -> T.Tuple[T.List[str], T.List[T.Union[build.BuildTarget, 'build.GeneratedTypes', 'FileOrString']]]: # Need to recursively add deps on GirTarget sources from our # dependencies and also find the include directories needed for the # typelib generation custom target below. typelib_includes: T.List[str] = [] + new_depends = list(depends) for dep in deps: # Add a dependency on each GirTarget listed in dependencies and add # the directory where it will be generated to the typelib includes if isinstance(dep, InternalDependency): for source in dep.sources: if isinstance(source, GirTarget) and source not in depends: - depends.append(source) + new_depends.append(source) subdir = os.path.join(state.environment.get_build_dir(), source.get_subdir()) if subdir not in typelib_includes: @@ -899,10 +999,10 @@ class GnomeModule(ExtensionModule): # FIXME: Store this in the original form from declare_dependency() # so it can be used here directly. elif isinstance(dep, build.SharedLibrary): - for source in dep.generated: - if isinstance(source, GirTarget): + for g_source in dep.generated: + if isinstance(g_source, GirTarget): subdir = os.path.join(state.environment.get_build_dir(), - source.get_subdir()) + g_source.get_subdir()) if subdir not in typelib_includes: typelib_includes.append(subdir) if isinstance(dep, Dependency): @@ -910,9 +1010,10 @@ class GnomeModule(ExtensionModule): assert isinstance(girdir, str), 'for mypy' if girdir and girdir not in typelib_includes: typelib_includes.append(girdir) - return typelib_includes + return typelib_includes, new_depends - def _get_external_args_for_langs(self, state: 'ModuleState', langs: T.Sequence[str]) -> T.List[str]: + @staticmethod + def _get_external_args_for_langs(state: 'ModuleState', langs: T.Sequence[str]) -> T.List[str]: ret: T.List[str] = [] for lang in langs: ret += mesonlib.listify(state.environment.coredata.get_external_args(MachineChoice.HOST, lang)) @@ -977,7 +1078,7 @@ class GnomeModule(ExtensionModule): srcdir = os.path.join(state.environment.get_source_dir(), state.subdir) builddir = os.path.join(state.environment.get_build_dir(), state.subdir) - depends: T.List[T.Union['FileOrString', build.GeneratedTypes, build.Executable, build.SharedLibrary, build.StaticLibrary]] = [] + depends: T.List[T.Union['FileOrString', 'build.GeneratedTypes', build.BuildTarget]] = [] depends.extend(gir_dep.sources) depends.extend(girtargets) @@ -986,11 +1087,11 @@ class GnomeModule(ExtensionModule): deps = self._get_gir_targets_deps(girtargets) deps += kwargs['dependencies'] deps += [gir_dep] - typelib_includes = self._gather_typelib_includes_and_update_depends(state, deps, depends) + typelib_includes, depends = self._gather_typelib_includes_and_update_depends(state, deps, depends) # ldflags will be misinterpreted by gir scanner (showing # spurious dependencies) but building GStreamer fails if they # are not used here. - dep_cflags, dep_internal_ldflags, dep_external_ldflags, _, gi_includes = \ + dep_cflags, dep_internal_ldflags, dep_external_ldflags, _, gi_includes, depends = \ self._get_dependencies_flags(deps, state, depends, use_gir_args=True) scan_cflags = [] scan_cflags += list(self._get_scanner_cflags(cflags)) @@ -1032,7 +1133,7 @@ class GnomeModule(ExtensionModule): scan_command += scan_cflags scan_command += ['--cflags-end'] scan_command += state.get_include_args(inc_dirs) - scan_command += state.get_include_args(list(gi_includes) + gir_inc_dirs + inc_dirs, prefix='--add-include-path=') + scan_command += state.get_include_args(itertools.chain(gi_includes, gir_inc_dirs, inc_dirs), prefix='--add-include-path=') scan_command += list(scan_internal_ldflags) scan_command += self._scan_gir_targets(state, girtargets) scan_command += self._scan_langs(state, [lc[0] for lc in langs_compilers]) @@ -1050,7 +1151,10 @@ class GnomeModule(ExtensionModule): generated_files = [f for f in libsources if isinstance(f, (GeneratedList, CustomTarget, CustomTargetIndex))] - scan_target = self._make_gir_target(state, girfile, scan_command, generated_files, depends, kwargs) + scan_target = self._make_gir_target( + state, girfile, scan_command, generated_files, depends, + # We have to cast here because mypy can't figure this out + T.cast(T.Dict[str, T.Any], kwargs)) typelib_output = f'{ns}-{nsversion}.typelib' typelib_cmd = [gicompiler, scan_target, '--output', '@OUTPUT@'] @@ -1059,7 +1163,7 @@ class GnomeModule(ExtensionModule): for incdir in typelib_includes: typelib_cmd += ["--includedir=" + incdir] - typelib_target = self._make_typelib_target(state, typelib_output, typelib_cmd, generated_files, kwargs) + typelib_target = self._make_typelib_target(state, typelib_output, typelib_cmd, generated_files, T.cast(T.Dict[str, T.Any], kwargs)) self._devenv_prepend('GI_TYPELIB_PATH', os.path.join(state.environment.get_build_dir(), state.subdir)) @@ -1111,47 +1215,102 @@ class GnomeModule(ExtensionModule): raise MesonException('Yelp requires a list of sources') elif args[1]: mlog.warning('"gnome.yelp" ignores positional sources arguments when the "sources" keyword argument is set') - source_str = '@@'.join(sources) + sources_files = [mesonlib.File.from_source_file(state.environment.source_dir, + os.path.join(state.subdir, 'C'), + s) for s in sources] langs = kwargs['languages'] + if not langs: + langs = read_linguas(os.path.join(state.environment.source_dir, state.subdir)) + + media = kwargs['media'] + symlinks = kwargs['symlink_media'] + targets: T.List[T.Union['build.Target', build.Data, build.SymlinkData]] = [] + potargets: T.List[build.RunTarget] = [] + + itstool = state.find_program('itstool') + msgmerge = state.find_program('msgmerge') + msgfmt = state.find_program('msgfmt') + + install_dir = os.path.join(state.environment.get_datadir(), 'help') + c_install_dir = os.path.join(install_dir, 'C', project_id) + c_data = build.Data(sources_files, c_install_dir, c_install_dir, + mesonlib.FileMode(), state.subproject) + targets.append(c_data) + + media_files: T.List[mesonlib.File] = [] + for m in media: + f = mesonlib.File.from_source_file(state.environment.source_dir, + os.path.join(state.subdir, 'C'), m) + media_files.append(f) + m_install_dir = os.path.join(c_install_dir, os.path.dirname(m)) + m_data = build.Data([f], m_install_dir, m_install_dir, + mesonlib.FileMode(), state.subproject) + targets.append(m_data) + + pot_file = os.path.join('@SOURCE_ROOT@', state.subdir, 'C', project_id + '.pot') + pot_sources = [os.path.join('@SOURCE_ROOT@', state.subdir, 'C', s) for s in sources] + pot_args: T.List[T.Union['ExternalProgram', str]] = [itstool, '-o', pot_file] + pot_args.extend(pot_sources) + pottarget = build.RunTarget(f'help-{project_id}-pot', pot_args, [], + os.path.join(state.subdir, 'C'), state.subproject) + targets.append(pottarget) + + for l in langs: + l_subdir = os.path.join(state.subdir, l) + l_install_dir = os.path.join(install_dir, l, project_id) + + for i, m in enumerate(media): + m_dir = os.path.dirname(m) + m_install_dir = os.path.join(l_install_dir, m_dir) + l_data: T.Union[build.Data, build.SymlinkData] + if symlinks: + link_target = os.path.join(os.path.relpath(c_install_dir, start=m_install_dir), m) + l_data = build.SymlinkData(link_target, os.path.basename(m), + m_install_dir, state.subproject) + else: + try: + m_file = mesonlib.File.from_source_file(state.environment.source_dir, l_subdir, m) + except MesonException: + m_file = media_files[i] + l_data = build.Data([m_file], m_install_dir, m_install_dir, + mesonlib.FileMode(), state.subproject) + targets.append(l_data) + + po_file = l + '.po' + po_args: T.List[T.Union['ExternalProgram', str]] = [ + msgmerge, '-q', '-o', + os.path.join('@SOURCE_ROOT@', l_subdir, po_file), + os.path.join('@SOURCE_ROOT@', l_subdir, po_file), pot_file] + potarget = build.RunTarget(f'help-{project_id}-{l}-update-po', + po_args, [pottarget], l_subdir, state.subproject) + targets.append(potarget) + potargets.append(potarget) + + gmo_file = project_id + '-' + l + '.gmo' + gmo_kwargs = {'command': [msgfmt, '@INPUT@', '-o', '@OUTPUT@'], + 'input': po_file, + 'output': gmo_file, + } + gmotarget = build.CustomTarget(f'help-{project_id}-{l}-gmo', l_subdir, state.subproject, gmo_kwargs) + targets.append(gmotarget) + + merge_kwargs = {'command': [itstool, '-m', os.path.join(l_subdir, gmo_file), + '-o', '@OUTDIR@', '@INPUT@'], + 'input': sources_files, + 'output': sources, + 'depends': gmotarget, + 'install': True, + 'install_dir': l_install_dir, + } + mergetarget = build.CustomTarget(f'help-{project_id}-{l}', l_subdir, state.subproject, merge_kwargs) + targets.append(mergetarget) - script = state.environment.get_build_command() - inscript_args = ['--internal', - 'yelphelper', - 'install', - '--subdir=' + state.subdir, - '--id=' + project_id, - '--installdir=' + os.path.join(state.environment.get_datadir(), 'help'), - '--sources=' + source_str] - if kwargs['symlink_media']: - inscript_args.append('--symlinks=true') - if kwargs['media']: - inscript_args.append('--media=' + '@@'.join(kwargs['media'])) - if langs: - inscript_args.append('--langs=' + '@@'.join(langs)) - inscript = state.backend.get_executable_serialisation(script + inscript_args) - - potargs = state.environment.get_build_command() + [ - '--internal', 'yelphelper', 'pot', - '--subdir=' + state.subdir, - '--id=' + project_id, - '--sources=' + source_str, - ] - pottarget = build.RunTarget('help-' + project_id + '-pot', potargs, - [], state.subdir, state.subproject) - - poargs = state.environment.get_build_command() + [ - '--internal', 'yelphelper', 'update-po', - '--subdir=' + state.subdir, - '--id=' + project_id, - '--sources=' + source_str, - '--langs=' + '@@'.join(langs), - ] - potarget = build.RunTarget('help-' + project_id + '-update-po', poargs, - [], state.subdir, state.subproject) - - rv: T.List[T.Union[build.ExecutableSerialisation, build.RunTarget]] = [inscript, pottarget, potarget] - return ModuleReturnValue(None, rv) + allpotarget = build.AliasTarget(f'help-{project_id}-update-po', potargets, + state.subdir, state.subproject) + targets.append(allpotarget) + + return ModuleReturnValue(None, targets) @typed_pos_args('gnome.gtkdoc', str) @typed_kwargs( @@ -1163,11 +1322,11 @@ class GnomeModule(ExtensionModule): 'dependencies', ContainerTypeInfo(list, (Dependency, build.SharedLibrary, build.StaticLibrary)), listify=True, default=[]), - KwargInfo('expand_content_files', ContainerTypeInfo(list, str), default=[], listify=True), + KwargInfo('expand_content_files', ContainerTypeInfo(list, (str, mesonlib.File)), default=[], listify=True), KwargInfo('fixxref_args', ContainerTypeInfo(list, str), default=[], listify=True), - KwargInfo('gobject_typesfile', ContainerTypeInfo(list, str), default=[], listify=True), + KwargInfo('gobject_typesfile', ContainerTypeInfo(list, (str, mesonlib.File)), default=[], listify=True), KwargInfo('html_args', ContainerTypeInfo(list, str), default=[], listify=True), - KwargInfo('html_assets', ContainerTypeInfo(list, str), default=[], listify=True), + KwargInfo('html_assets', ContainerTypeInfo(list, (str, mesonlib.File)), default=[], listify=True), KwargInfo('ignore_headers', ContainerTypeInfo(list, str), default=[], listify=True), KwargInfo( 'include_directories', @@ -1193,7 +1352,7 @@ class GnomeModule(ExtensionModule): main_xml = kwargs['main_xml'] if main_xml is not None: if main_file is not None: - raise InvalidArguments('gnome.gtkdoc: main_xml and main_xgml are exclusive arguments') + raise InvalidArguments('gnome.gtkdoc: main_xml and main_sgml are exclusive arguments') main_file = main_xml moduleversion = kwargs['module_version'] targetname = modulename + ('-' + moduleversion if moduleversion else '') + '-doc' @@ -1293,7 +1452,8 @@ class GnomeModule(ExtensionModule): def _get_build_args(self, c_args: T.List[str], inc_dirs: T.List[T.Union[str, build.IncludeDirs]], deps: T.List[T.Union[Dependency, build.SharedLibrary, build.StaticLibrary]], - state: 'ModuleState', depends: T.List[build.BuildTarget]) -> T.List[str]: + state: 'ModuleState', + depends: T.Sequence[T.Union[build.BuildTarget, 'build.GeneratedTypes']]) -> T.List[str]: args: T.List[str] = [] cflags = c_args.copy() deps_cflags, internal_ldflags, external_ldflags, *_ = \ @@ -1328,7 +1488,7 @@ class GnomeModule(ExtensionModule): def gtkdoc_html_dir(self, state: 'ModuleState', args: T.Tuple[str], kwargs: 'TYPE_kwargs') -> str: return os.path.join('share/gtk-doc/html', args[0]) - @typed_pos_args('gnome.gdbus_codegen', str, optargs=[str]) + @typed_pos_args('gnome.gdbus_codegen', str, optargs=[(str, mesonlib.File)]) @typed_kwargs( 'gnome.gdbus_codegen', _BUILD_BY_DEFAULT.evolve(since='0.40.0'), @@ -1338,10 +1498,10 @@ class GnomeModule(ExtensionModule): KwargInfo('namespace', (str, NoneType)), KwargInfo('object_manager', bool, default=False), KwargInfo( - 'annotations', ContainerTypeInfo(list, str), - listify=True, + 'annotations', ContainerTypeInfo(list, (list, str)), default=[], - validator=lambda x: 'must be made up of 3 strings for ELEMENT, KEY, and VALUE' if len(x) != 3 else None + validator=annotations_validator, + convertor=lambda x: [x] if x and isinstance(x[0], str) else x, ), KwargInfo('install_header', bool, default=False, since='0.46.0'), KwargInfo('install_dir', (str, NoneType), since='0.46.0'), @@ -1350,7 +1510,7 @@ class GnomeModule(ExtensionModule): 'autocleanup', str, default='default', since='0.47.0', validator=in_set_validator({'all', 'none', 'objects'})), ) - def gdbus_codegen(self, state: 'ModuleState', args: T.Tuple[str, T.Optional[str]], + def gdbus_codegen(self, state: 'ModuleState', args: T.Tuple[str, T.Optional['FileOrString']], kwargs: 'GdbusCodegen') -> ModuleReturnValue: namebase = args[0] xml_files: T.List['FileOrString'] = [args[1]] if args[1] else [] @@ -1381,9 +1541,9 @@ class GnomeModule(ExtensionModule): build_by_default = kwargs['build_by_default'] # Annotations are a bit ugly in that they are a list of lists of strings... - if kwargs['annotations']: + for annot in kwargs['annotations']: cmd.append('--annotate') - cmd.extend(kwargs['annotations']) + cmd.extend(annot) targets = [] install_header = kwargs['install_header'] @@ -1475,80 +1635,54 @@ class GnomeModule(ExtensionModule): return ModuleReturnValue(targets, targets) - @permittedKwargs({'sources', 'c_template', 'h_template', 'install_header', 'install_dir', - 'comments', 'identifier_prefix', 'symbol_prefix', 'eprod', 'vprod', - 'fhead', 'fprod', 'ftail', 'vhead', 'vtail', 'depends'}) @typed_pos_args('gnome.mkenums', str) - def mkenums(self, state: 'ModuleState', args: T.Tuple[str], kwargs) -> ModuleReturnValue: + @typed_kwargs( + 'gnome.mkenums', + *_MK_ENUMS_COMMON_KWS, + DEPENDS_KW, + KwargInfo('c_template', (str, mesonlib.File, NoneType)), + KwargInfo('h_template', (str, mesonlib.File, NoneType)), + KwargInfo('comments', (str, NoneType)), + KwargInfo('eprod', (str, NoneType)), + KwargInfo('fhead', (str, NoneType)), + KwargInfo('fprod', (str, NoneType)), + KwargInfo('ftail', (str, NoneType)), + KwargInfo('vhead', (str, NoneType)), + KwargInfo('vprod', (str, NoneType)), + KwargInfo('vtail', (str, NoneType)), + ) + def mkenums(self, state: 'ModuleState', args: T.Tuple[str], kwargs: 'MkEnums') -> ModuleReturnValue: basename = args[0] - if 'sources' not in kwargs: - raise MesonException('Missing keyword argument "sources".') - sources = kwargs.pop('sources') - if isinstance(sources, str): - sources = [sources] - elif not isinstance(sources, list): - raise MesonException( - 'Sources keyword argument must be a string or array.') + c_template = kwargs['c_template'] + if isinstance(c_template, mesonlib.File): + c_template = c_template.absolute_path(state.environment.source_dir, state.environment.build_dir) + h_template = kwargs['h_template'] + if isinstance(h_template, mesonlib.File): + h_template = h_template.absolute_path(state.environment.source_dir, state.environment.build_dir) - cmd = [] + cmd: T.List[str] = [] known_kwargs = ['comments', 'eprod', 'fhead', 'fprod', 'ftail', - 'identifier_prefix', 'symbol_prefix', 'template', + 'identifier_prefix', 'symbol_prefix', 'vhead', 'vprod', 'vtail'] - known_custom_target_kwargs = ['install_dir', 'build_always', - 'depends', 'depend_files'] - c_template = h_template = None - install_header = False - for arg, value in kwargs.items(): - if arg == 'sources': - raise AssertionError("sources should've already been handled") - elif arg == 'c_template': - c_template = value - if isinstance(c_template, mesonlib.File): - c_template = c_template.absolute_path(state.environment.source_dir, state.environment.build_dir) - if 'template' in kwargs: - raise MesonException('Mkenums does not accept both ' - 'c_template and template keyword ' - 'arguments at the same time.') - elif arg == 'h_template': - h_template = value - if isinstance(h_template, mesonlib.File): - h_template = h_template.absolute_path(state.environment.source_dir, state.environment.build_dir) - if 'template' in kwargs: - raise MesonException('Mkenums does not accept both ' - 'h_template and template keyword ' - 'arguments at the same time.') - elif arg == 'install_header': - install_header = value - elif arg in known_kwargs: - cmd += ['--' + arg.replace('_', '-'), value] - elif arg not in known_custom_target_kwargs: - raise MesonException( - f'Mkenums does not take a {arg} keyword argument.') - cmd = [state.find_program(['glib-mkenums', 'mkenums'])] + cmd - custom_kwargs = {} - for arg in known_custom_target_kwargs: - if arg in kwargs: - custom_kwargs[arg] = kwargs[arg] + for arg in known_kwargs: + # mypy can't figure this out + if kwargs[arg]: # type: ignore + cmd += ['--' + arg.replace('_', '-'), kwargs[arg]] # type: ignore - targets = [] + targets: T.List[CustomTarget] = [] + h_target: T.Optional[CustomTarget] = None if h_template is not None: h_output = os.path.basename(os.path.splitext(h_template)[0]) # We always set template as the first element in the source array # so --template consumes it. h_cmd = cmd + ['--template', '@INPUT@'] - h_sources = [h_template] + sources - - # Copy so we don't mutate the arguments for the c_template - h_kwargs = custom_kwargs.copy() - h_kwargs['install'] = install_header - if 'install_dir' not in h_kwargs: - h_kwargs['install_dir'] = \ - state.environment.coredata.get_option(mesonlib.OptionKey('includedir')) - h_target = self._make_mkenum_custom_target(state, h_sources, - h_output, h_cmd, - h_kwargs) + h_sources: T.List[T.Union[FileOrString, 'build.GeneratedTypes']] = [h_template] + h_sources.extend(kwargs['sources']) + h_target = self._make_mkenum_impl( + state, h_sources, h_output, h_cmd, install=kwargs['install_header'], + install_dir=kwargs['install_dir']) targets.append(h_target) if c_template is not None: @@ -1556,110 +1690,86 @@ class GnomeModule(ExtensionModule): # We always set template as the first element in the source array # so --template consumes it. c_cmd = cmd + ['--template', '@INPUT@'] - c_sources = [c_template] + sources - - c_kwargs = custom_kwargs.copy() - # Never install the C file. Complain on bug tracker if you need it. - c_kwargs['install'] = False - c_kwargs['install_dir'] = [] - if h_template is not None: - if 'depends' in custom_kwargs: - c_kwargs['depends'] += [h_target] - else: - c_kwargs['depends'] = h_target - c_target = self._make_mkenum_custom_target(state, c_sources, - c_output, c_cmd, - c_kwargs) + c_sources: T.List[T.Union[FileOrString, 'build.GeneratedTypes']] = [c_template] + c_sources.extend(kwargs['sources']) + + depends = kwargs['depends'].copy() + if h_target is not None: + depends.append(h_target) + c_target = self._make_mkenum_impl( + state, c_sources, c_output, c_cmd, depends=depends) targets.insert(0, c_target) if c_template is None and h_template is None: generic_cmd = cmd + ['@INPUT@'] - custom_kwargs['install'] = install_header - if 'install_dir' not in custom_kwargs: - custom_kwargs['install_dir'] = \ - state.environment.coredata.get_option(mesonlib.OptionKey('includedir')) - target = self._make_mkenum_custom_target(state, sources, basename, - generic_cmd, custom_kwargs) + target = self._make_mkenum_impl( + state, kwargs['sources'], basename, generic_cmd, + install=kwargs['install_header'], + install_dir=kwargs['install_dir']) return ModuleReturnValue(target, [target]) - elif len(targets) == 1: - return ModuleReturnValue(targets[0], [targets[0]]) else: return ModuleReturnValue(targets, targets) @FeatureNew('gnome.mkenums_simple', '0.42.0') @typed_pos_args('gnome.mkenums_simple', str) - def mkenums_simple(self, state: 'ModuleState', args: T.Tuple[str], kwargs) -> ModuleReturnValue: + @typed_kwargs( + 'gnome.mkenums_simple', + *_MK_ENUMS_COMMON_KWS, + KwargInfo('header_prefix', str, default=''), + KwargInfo('function_prefix', str, default=''), + KwargInfo('body_prefix', str, default=''), + KwargInfo('decorator', str, default=''), + ) + def mkenums_simple(self, state: 'ModuleState', args: T.Tuple[str], kwargs: 'MkEnumsSimple') -> ModuleReturnValue: hdr_filename = f'{args[0]}.h' body_filename = f'{args[0]}.c' - # not really needed, just for sanity checking - forbidden_kwargs = ['c_template', 'h_template', 'eprod', 'fhead', - 'fprod', 'ftail', 'vhead', 'vtail', 'comments'] - for arg in forbidden_kwargs: - if arg in kwargs: - raise MesonException(f'mkenums_simple() does not take a {arg} keyword argument') - - # kwargs to pass as-is from mkenums_simple() to mkenums() - shared_kwargs = ['sources', 'install_header', 'install_dir', - 'identifier_prefix', 'symbol_prefix'] - mkenums_kwargs = {} - for arg in shared_kwargs: - if arg in kwargs: - mkenums_kwargs[arg] = kwargs[arg] - - # .c file generation - c_file_kwargs = copy.deepcopy(mkenums_kwargs) - if 'sources' not in kwargs: - raise MesonException('Missing keyword argument "sources".') - sources = kwargs['sources'] - if isinstance(sources, str): - sources = [sources] - elif not isinstance(sources, list): - raise MesonException( - 'Sources keyword argument must be a string or array.') - - # The `install_header` argument will be used by mkenums() when - # not using template files, so we need to forcibly unset it - # when generating the C source file, otherwise we will end up - # installing it - c_file_kwargs['install_header'] = False - - header_prefix = kwargs.get('header_prefix', '') - decl_decorator = kwargs.get('decorator', '') - func_prefix = kwargs.get('function_prefix', '') - body_prefix = kwargs.get('body_prefix', '') + header_prefix = kwargs['header_prefix'] + decl_decorator = kwargs['decorator'] + func_prefix = kwargs['function_prefix'] + body_prefix = kwargs['body_prefix'] + cmd: T.List[str] = [] + if kwargs['identifier_prefix']: + cmd.extend(['--identifier-prefix', kwargs['identifier_prefix']]) + if kwargs['symbol_prefix']: + cmd.extend(['--symbol-prefix', kwargs['symbol_prefix']]) + + c_cmd = cmd.copy() # Maybe we should write our own template files into the build dir # instead, but that seems like much more work, nice as it would be. fhead = '' if body_prefix != '': fhead += '%s\n' % body_prefix fhead += '#include "%s"\n' % hdr_filename - for hdr in sources: + for hdr in kwargs['sources']: fhead += '#include "{}"\n'.format(os.path.basename(str(hdr))) fhead += textwrap.dedent( ''' #define C_ENUM(v) ((gint) v) #define C_FLAGS(v) ((guint) v) ''') - c_file_kwargs['fhead'] = fhead + c_cmd.extend(['--fhead', fhead]) - c_file_kwargs['fprod'] = textwrap.dedent( + c_cmd.append('--fprod') + c_cmd.append(textwrap.dedent( ''' /* enumerations from "@basename@" */ - ''') + ''')) - c_file_kwargs['vhead'] = textwrap.dedent( + c_cmd.append('--vhead') + c_cmd.append(textwrap.dedent( f''' GType {func_prefix}@enum_name@_get_type (void) {{ static gsize gtype_id = 0; - static const G@Type@Value values[] = {{''') + static const G@Type@Value values[] = {{''')) - c_file_kwargs['vprod'] = ' { C_@TYPE@(@VALUENAME@), "@VALUENAME@", "@valuenick@" },' + c_cmd.extend(['--vprod', ' { C_@TYPE@(@VALUENAME@), "@VALUENAME@", "@valuenick@" },']) - c_file_kwargs['vtail'] = textwrap.dedent( + c_cmd.append('--vtail') + c_cmd.append(textwrap.dedent( ''' { 0, NULL, NULL } }; if (g_once_init_enter (>ype_id)) { @@ -1667,55 +1777,72 @@ class GnomeModule(ExtensionModule): g_once_init_leave (>ype_id, new_type); } return (GType) gtype_id; - }''') + }''')) + c_cmd.append('@INPUT@') - rv = self.mkenums(state, [body_filename], c_file_kwargs) - c_file = rv.return_value + c_file = self._make_mkenum_impl(state, kwargs['sources'], body_filename, c_cmd) # .h file generation - h_file_kwargs = copy.deepcopy(mkenums_kwargs) + h_cmd = cmd.copy() - h_file_kwargs['fhead'] = textwrap.dedent( + h_cmd.append('--fhead') + h_cmd.append(textwrap.dedent( f'''#pragma once #include <glib-object.h> {header_prefix} G_BEGIN_DECLS - ''') + ''')) - h_file_kwargs['fprod'] = textwrap.dedent( + h_cmd.append('--fprod') + h_cmd.append(textwrap.dedent( ''' /* enumerations from "@basename@" */ - ''') + ''')) - h_file_kwargs['vhead'] = textwrap.dedent( + h_cmd.append('--vhead') + h_cmd.append(textwrap.dedent( f''' {decl_decorator} GType {func_prefix}@enum_name@_get_type (void); - #define @ENUMPREFIX@_TYPE_@ENUMSHORT@ ({func_prefix}@enum_name@_get_type())''') + #define @ENUMPREFIX@_TYPE_@ENUMSHORT@ ({func_prefix}@enum_name@_get_type())''')) - h_file_kwargs['ftail'] = textwrap.dedent( + h_cmd.append('--ftail') + h_cmd.append(textwrap.dedent( ''' - G_END_DECLS''') + G_END_DECLS''')) + h_cmd.append('@INPUT@') - rv = self.mkenums(state, [hdr_filename], h_file_kwargs) - h_file = rv.return_value + h_file = self._make_mkenum_impl( + state, kwargs['sources'], hdr_filename, h_cmd, + install=kwargs['install_header'], + install_dir=kwargs['install_dir']) return ModuleReturnValue([c_file, h_file], [c_file, h_file]) @staticmethod - def _make_mkenum_custom_target( + def _make_mkenum_impl( state: 'ModuleState', sources: T.Sequence[T.Union[str, mesonlib.File, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList]], - output: str, cmd: T.List[str], kwargs: T.Dict[str, T.Any]) -> build.CustomTarget: + output: str, + cmd: T.List[str], + *, + install: bool = False, + install_dir: T.Optional[T.Sequence[T.Union[str, bool]]] = None, + depends: T.Optional[T.Sequence[T.Union[CustomTarget, CustomTargetIndex, BuildTarget]]] = None + ) -> build.CustomTarget: + real_cmd: T.List[T.Union[str, ExternalProgram]] = [state.find_program(['glib-mkenums', 'mkenums'])] + real_cmd.extend(cmd) custom_kwargs = { 'input': sources, 'output': [output], 'capture': True, - 'command': cmd + 'command': real_cmd, + 'install': install, + 'install_dir': install_dir or state.environment.coredata.get_option(mesonlib.OptionKey('includedir')), + 'depends': list(depends or []), } - custom_kwargs.update(kwargs) return build.CustomTarget(output, state.subdir, state.subproject, custom_kwargs, # https://github.com/mesonbuild/meson/issues/973 absolute_paths=True) @@ -1732,7 +1859,7 @@ class GnomeModule(ExtensionModule): KwargInfo('nostdinc', bool, default=False), KwargInfo('prefix', (str, NoneType)), KwargInfo('skip_source', bool, default=False), - KwargInfo('sources', ContainerTypeInfo(list, str, allow_empty=False), listify=True, required=True), + KwargInfo('sources', ContainerTypeInfo(list, (str, mesonlib.File), allow_empty=False), listify=True, required=True), KwargInfo('stdinc', bool, default=False), KwargInfo('valist_marshallers', bool, default=False), ) @@ -1793,7 +1920,7 @@ class GnomeModule(ExtensionModule): return ModuleReturnValue(rv, rv) def _extract_vapi_packages(self, state: 'ModuleState', packages: T.List[T.Union[InternalDependency, str]], - ) -> T.Tuple[T.List[str], T.List[build.Target], T.List[str], T.List[str], T.List[str]]: + ) -> T.Tuple[T.List[str], T.List[VapiTarget], T.List[str], T.List[str], T.List[str]]: ''' Packages are special because we need to: - Get a list of packages for the .deps file @@ -1803,7 +1930,7 @@ class GnomeModule(ExtensionModule): ''' if not packages: return [], [], [], [], [] - vapi_depends: T.List[build.Target] = [] + vapi_depends: T.List[VapiTarget] = [] vapi_packages: T.List[str] = [] vapi_includes: T.List[str] = [] vapi_args: T.List[str] = [] @@ -1866,7 +1993,7 @@ class GnomeModule(ExtensionModule): KwargInfo('packages', ContainerTypeInfo(list, (str, InternalDependency)), listify=True, default=[]), ) def generate_vapi(self, state: 'ModuleState', args: T.Tuple[str], kwargs: 'GenerateVapi') -> ModuleReturnValue: - created_values: T.List[Dependency] = [] + created_values: T.List[T.Union[Dependency, build.Data]] = [] library = args[0] build_dir = os.path.join(state.environment.get_build_dir(), state.subdir) source_dir = os.path.join(state.environment.get_source_dir(), state.subdir) @@ -1874,7 +2001,7 @@ class GnomeModule(ExtensionModule): cmd: T.List[T.Union[str, 'ExternalProgram']] cmd = [state.find_program('vapigen'), '--quiet', f'--library={library}', f'--directory={build_dir}'] cmd.extend([f'--vapidir={d}' for d in kwargs['vapi_dirs']]) - cmd.extend([f'--metadatdir={d}' for d in kwargs['metadata_dirs']]) + cmd.extend([f'--metadatadir={d}' for d in kwargs['metadata_dirs']]) cmd.extend([f'--girdir={d}' for d in kwargs['gir_dirs']]) cmd += pkg_cmd cmd += ['--metadatadir=' + source_dir] |