aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/modules
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild/modules')
-rw-r--r--mesonbuild/modules/__init__.py9
-rw-r--r--mesonbuild/modules/cmake.py16
-rw-r--r--mesonbuild/modules/dlang.py13
-rw-r--r--mesonbuild/modules/fs.py1
-rw-r--r--mesonbuild/modules/gnome.py637
-rw-r--r--mesonbuild/modules/pkgconfig.py3
-rw-r--r--mesonbuild/modules/python.py29
-rw-r--r--mesonbuild/modules/python3.py3
-rw-r--r--mesonbuild/modules/qt6.py2
-rw-r--r--mesonbuild/modules/rpm.py186
-rw-r--r--mesonbuild/modules/sourceset.py8
-rw-r--r--mesonbuild/modules/unstable_simd.py6
12 files changed, 440 insertions, 473 deletions
diff --git a/mesonbuild/modules/__init__.py b/mesonbuild/modules/__init__.py
index 7eab2cb..8fe61c6 100644
--- a/mesonbuild/modules/__init__.py
+++ b/mesonbuild/modules/__init__.py
@@ -80,8 +80,8 @@ class ModuleState:
def find_program(self, prog: T.Union[str, T.List[str]], required: bool = True,
version_func: T.Optional[T.Callable[['ExternalProgram'], str]] = None,
- wanted: T.Optional[str] = None) -> 'ExternalProgram':
- return self._interpreter.find_program_impl(prog, required=required, version_func=version_func, wanted=wanted)
+ wanted: T.Optional[str] = None, silent: bool = False) -> 'ExternalProgram':
+ return self._interpreter.find_program_impl(prog, required=required, version_func=version_func, wanted=wanted, silent=silent)
def test(self, args: T.Tuple[str, T.Union[build.Executable, build.Jar, 'ExternalProgram', mesonlib.File]],
workdir: T.Optional[str] = None,
@@ -91,8 +91,11 @@ class ModuleState:
'env': env,
'depends': depends,
}
+ # typed_* takes a list, and gives a tuple to func_test. Violating that constraint
+ # makes the universe (or at least use of this function) implode
+ real_args = list(args)
# TODO: Use interpreter internal API, but we need to go through @typed_kwargs
- self._interpreter.func_test(self.current_node, args, kwargs)
+ self._interpreter.func_test(self.current_node, real_args, kwargs)
def get_option(self, name: str, subproject: str = '',
machine: MachineChoice = MachineChoice.HOST,
diff --git a/mesonbuild/modules/cmake.py b/mesonbuild/modules/cmake.py
index 67fdd0c..0f325f5 100644
--- a/mesonbuild/modules/cmake.py
+++ b/mesonbuild/modules/cmake.py
@@ -20,7 +20,7 @@ from . import ExtensionModule, ModuleReturnValue, ModuleObject
from .. import build, mesonlib, mlog, dependencies
from ..cmake import SingleTargetOptions, TargetOptions, cmake_defines_to_args
-from ..interpreter import ConfigurationDataObject, SubprojectHolder
+from ..interpreter import SubprojectHolder
from ..interpreterbase import (
FeatureNew,
FeatureNewKwargs,
@@ -34,7 +34,6 @@ from ..interpreterbase import (
InvalidArguments,
InterpreterException,
)
-from ..programs import ExternalProgram
COMPATIBILITIES = ['AnyNewerVersion', 'SameMajorVersion', 'SameMinorVersion', 'ExactVersion']
@@ -213,6 +212,7 @@ class CmakeModule(ExtensionModule):
cmake_detected = False
cmake_root = None
+ @FeatureNew('CMake Module', '0.50.0')
def __init__(self, interpreter):
super().__init__(interpreter)
self.methods.update({
@@ -233,11 +233,11 @@ class CmakeModule(ExtensionModule):
return compiler.sizeof('void *', '', env)
- def detect_cmake(self):
+ def detect_cmake(self, state):
if self.cmake_detected:
return True
- cmakebin = ExternalProgram('cmake', silent=False)
+ cmakebin = state.find_program('cmake', silent=False)
if not cmakebin.found():
return False
@@ -272,7 +272,7 @@ class CmakeModule(ExtensionModule):
if compatibility not in COMPATIBILITIES:
raise mesonlib.MesonException('compatibility must be either AnyNewerVersion, SameMajorVersion or ExactVersion.')
- if not self.detect_cmake():
+ if not self.detect_cmake(state):
raise mesonlib.MesonException('Unable to find cmake')
pkgroot = pkgroot_name = kwargs.get('install_dir', None)
@@ -358,7 +358,7 @@ class CmakeModule(ExtensionModule):
if 'configuration' not in kwargs:
raise mesonlib.MesonException('"configuration" not specified.')
conf = kwargs['configuration']
- if not isinstance(conf, ConfigurationDataObject):
+ if not isinstance(conf, build.ConfigurationData):
raise mesonlib.MesonException('Argument "configuration" is not of type configuration_data')
prefix = state.environment.coredata.get_option(mesonlib.OptionKey('prefix'))
@@ -372,8 +372,8 @@ class CmakeModule(ExtensionModule):
extra = PACKAGE_INIT_EXT.replace('@absInstallDir@', abs_install_dir)
extra = extra.replace('@installPrefix@', prefix)
- self.create_package_file(ifile_abs, ofile_abs, PACKAGE_RELATIVE_PATH, extra, conf.conf_data)
- conf.mark_used()
+ self.create_package_file(ifile_abs, ofile_abs, PACKAGE_RELATIVE_PATH, extra, conf)
+ conf.used = True
conffile = os.path.normpath(inputfile.relative_name())
if conffile not in self.interpreter.build_def_files:
diff --git a/mesonbuild/modules/dlang.py b/mesonbuild/modules/dlang.py
index 60d2885..558ca81 100644
--- a/mesonbuild/modules/dlang.py
+++ b/mesonbuild/modules/dlang.py
@@ -21,20 +21,21 @@ import os
from . import ExtensionModule
from .. import dependencies
from .. import mlog
+from ..interpreterbase import FeatureNew
from ..mesonlib import Popen_safe, MesonException
-from ..programs import ExternalProgram
class DlangModule(ExtensionModule):
class_dubbin = None
init_dub = False
+ @FeatureNew('Dlang Module', '0.48.0')
def __init__(self, interpreter):
super().__init__(interpreter)
self.methods.update({
'generate_dub_file': self.generate_dub_file,
})
- def _init_dub(self):
+ def _init_dub(self, state):
if DlangModule.class_dubbin is None:
self.dubbin = dependencies.DubDependency.class_dubbin
DlangModule.class_dubbin = self.dubbin
@@ -42,7 +43,7 @@ class DlangModule(ExtensionModule):
self.dubbin = DlangModule.class_dubbin
if DlangModule.class_dubbin is None:
- self.dubbin = self.check_dub()
+ self.dubbin = self.check_dub(state)
DlangModule.class_dubbin = self.dubbin
else:
self.dubbin = DlangModule.class_dubbin
@@ -53,7 +54,7 @@ class DlangModule(ExtensionModule):
def generate_dub_file(self, state, args, kwargs):
if not DlangModule.init_dub:
- self._init_dub()
+ self._init_dub(state)
if len(args) < 2:
raise MesonException('Missing arguments')
@@ -109,8 +110,8 @@ class DlangModule(ExtensionModule):
p, out = Popen_safe(self.dubbin.get_command() + args, env=env)[0:2]
return p.returncode, out.strip()
- def check_dub(self):
- dubbin = ExternalProgram('dub', silent=True)
+ def check_dub(self, state):
+ dubbin = state.find_program('dub', silent=True)
if dubbin.found():
try:
p, out = Popen_safe(dubbin.get_command() + ['--version'])[0:2]
diff --git a/mesonbuild/modules/fs.py b/mesonbuild/modules/fs.py
index ab3aae2..5faee83 100644
--- a/mesonbuild/modules/fs.py
+++ b/mesonbuild/modules/fs.py
@@ -41,6 +41,7 @@ if T.TYPE_CHECKING:
class FSModule(ExtensionModule):
+ @FeatureNew('Fs Module', '0.53.0')
def __init__(self, interpreter: 'Interpreter') -> None:
super().__init__(interpreter)
self.methods.update({
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 (&gtype_id)) {
@@ -1667,55 +1777,72 @@ class GnomeModule(ExtensionModule):
g_once_init_leave (&gtype_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]
diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py
index 4a0b39e..6c5d347 100644
--- a/mesonbuild/modules/pkgconfig.py
+++ b/mesonbuild/modules/pkgconfig.py
@@ -183,7 +183,8 @@ class DependenciesHelper:
# lists in case a library is link_with and link_whole at the same time.
# See remove_dups() below.
self.link_whole_targets.append(t)
- self._add_lib_dependencies(t.link_targets, t.link_whole_targets, t.external_deps, public)
+ if isinstance(t, build.BuildTarget):
+ self._add_lib_dependencies(t.link_targets, t.link_whole_targets, t.external_deps, public)
def add_version_reqs(self, name, version_reqs):
if version_reqs:
diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py
index 90335a1..2b62ea3 100644
--- a/mesonbuild/modules/python.py
+++ b/mesonbuild/modules/python.py
@@ -79,10 +79,19 @@ class _PythonDependencyBase(_Base):
class PythonPkgConfigDependency(PkgConfigDependency, _PythonDependencyBase):
def __init__(self, name: str, environment: 'Environment',
- kwargs: T.Dict[str, T.Any], installation: 'PythonInstallation'):
+ kwargs: T.Dict[str, T.Any], installation: 'PythonInstallation',
+ libpc: bool = False):
+ if libpc:
+ mlog.debug(f'Searching for {name!r} via pkgconfig lookup in LIBPC')
+ else:
+ mlog.debug(f'Searching for {name!r} via fallback pkgconfig lookup in default paths')
+
PkgConfigDependency.__init__(self, name, environment, kwargs)
_PythonDependencyBase.__init__(self, installation, kwargs.get('embed', False))
+ if libpc and not self.is_found:
+ mlog.debug(f'"python-{self.version}" could not be found in LIBPC, this is likely due to a relocated python installation')
+
class PythonFrameworkDependency(ExtraFrameworkDependency, _PythonDependencyBase):
@@ -240,12 +249,15 @@ def python_factory(env: 'Environment', for_machine: 'MachineChoice',
# If python-X.Y.pc exists in LIBPC, we will try to use it
def wrap_in_pythons_pc_dir(name: str, env: 'Environment', kwargs: T.Dict[str, T.Any],
installation: 'PythonInstallation') -> 'ExternalDependency':
+ if not pkg_libdir:
+ # there is no LIBPC, so we can't search in it
+ return NotFoundDependency('python', env)
+
old_pkg_libdir = os.environ.pop('PKG_CONFIG_LIBDIR', None)
old_pkg_path = os.environ.pop('PKG_CONFIG_PATH', None)
- if pkg_libdir:
- os.environ['PKG_CONFIG_LIBDIR'] = pkg_libdir
+ os.environ['PKG_CONFIG_LIBDIR'] = pkg_libdir
try:
- return PythonPkgConfigDependency(name, env, kwargs, installation)
+ return PythonPkgConfigDependency(name, env, kwargs, installation, True)
finally:
def set_env(name, value):
if value is not None:
@@ -255,10 +267,11 @@ def python_factory(env: 'Environment', for_machine: 'MachineChoice',
set_env('PKG_CONFIG_LIBDIR', old_pkg_libdir)
set_env('PKG_CONFIG_PATH', old_pkg_path)
- candidates.extend([
- functools.partial(wrap_in_pythons_pc_dir, pkg_name, env, kwargs, installation),
- functools.partial(PythonPkgConfigDependency, pkg_name, env, kwargs, installation)
- ])
+ candidates.append(functools.partial(wrap_in_pythons_pc_dir, pkg_name, env, kwargs, installation))
+ # We only need to check both, if a python install has a LIBPC. It might point to the wrong location,
+ # e.g. relocated / cross compilation, but the presence of LIBPC indicates we should definitely look for something.
+ if pkg_libdir is not None:
+ candidates.append(functools.partial(PythonPkgConfigDependency, pkg_name, env, kwargs, installation))
if DependencyMethods.SYSTEM in methods:
candidates.append(functools.partial(PythonSystemDependency, 'python', env, kwargs, installation))
diff --git a/mesonbuild/modules/python3.py b/mesonbuild/modules/python3.py
index dc1f7c7..f7600e2 100644
--- a/mesonbuild/modules/python3.py
+++ b/mesonbuild/modules/python3.py
@@ -16,12 +16,13 @@ import sysconfig
from .. import mesonlib
from . import ExtensionModule
-from ..interpreterbase import noKwargs, permittedKwargs, FeatureDeprecated
+from ..interpreterbase import noKwargs, permittedKwargs, FeatureDeprecated, FeatureNew
from ..build import known_shmod_kwargs
from ..programs import ExternalProgram
class Python3Module(ExtensionModule):
+ @FeatureNew('python3 module', '0.38.0')
@FeatureDeprecated('python3 module', '0.48.0')
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
diff --git a/mesonbuild/modules/qt6.py b/mesonbuild/modules/qt6.py
index d9cd651..3cfe243 100644
--- a/mesonbuild/modules/qt6.py
+++ b/mesonbuild/modules/qt6.py
@@ -13,10 +13,12 @@
# limitations under the License.
from .qt import QtBaseModule
+from ..interpreterbase import FeatureNew
class Qt6Module(QtBaseModule):
+ @FeatureNew('Qt6 Module', '0.57.0')
def __init__(self, interpreter):
QtBaseModule.__init__(self, interpreter, qt_version=6)
diff --git a/mesonbuild/modules/rpm.py b/mesonbuild/modules/rpm.py
deleted file mode 100644
index 1fae144..0000000
--- a/mesonbuild/modules/rpm.py
+++ /dev/null
@@ -1,186 +0,0 @@
-# Copyright 2015 The Meson development team
-
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-
-# http://www.apache.org/licenses/LICENSE-2.0
-
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-'''This module provides helper functions for RPM related
-functionality such as generating template RPM spec file.'''
-
-from .. import build
-from .. import compilers
-import datetime
-from .. import mlog
-from . import GirTarget, TypelibTarget
-from . import ExtensionModule
-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, 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 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:
- files.add('%%{_libdir}/%s' % target.get_filename())
- for alias in target.get_aliases():
- if alias.endswith('.so'):
- files_devel.add('%%{_libdir}/%s' % alias)
- else:
- files.add('%%{_libdir}/%s' % alias)
- so_installed = True
- elif isinstance(target, build.StaticLibrary) and target.need_install:
- to_delete.add('%%{buildroot}%%{_libdir}/%s' % target.get_filename())
- mlog.warning('removing', mlog.bold(target.get_filename()),
- 'from package because packaging static libs not recommended')
- elif isinstance(target, GirTarget) and target.should_install():
- 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 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 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))
- else:
- files.add('%%{_mandir}/man%u/%s.*' % (int(man_file.split('.')[-1]), man_file))
- if files_devel:
- devel_subpkg = True
-
- filename = os.path.join(state.environment.get_build_dir(),
- '%s.spec' % proj)
- with open(filename, 'w+', encoding='utf-8') as fn:
- fn.write('Name: %s\n' % proj)
- fn.write('Version: # FIXME\n')
- fn.write('Release: 1%{?dist}\n')
- fn.write('Summary: # FIXME\n')
- fn.write('License: # FIXME\n')
- fn.write('\n')
- fn.write('Source0: %{name}-%{version}.tar.xz # FIXME\n')
- fn.write('\n')
- fn.write('BuildRequires: meson\n')
- for compiler in required_compilers:
- fn.write('BuildRequires: %s\n' % compiler)
- 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
-# to re-implement it.
-#
-# for lib in state.environment.coredata.ext_libs.values():
-# name = lib.get_name()
-# fn.write('BuildRequires: {} # FIXME\n'.format(name))
-# mlog.warning('replace', mlog.bold(name), 'with the real package.',
-# 'You can use following command to find package which '
-# 'contains this lib:',
-# mlog.bold("dnf provides '*/lib{}.so'".format(name)))
-# for prog in state.environment.coredata.ext_progs.values():
-# if not prog.found():
-# fn.write('BuildRequires: %%{_bindir}/%s # FIXME\n' %
-# prog.get_name())
-# else:
-# fn.write('BuildRequires: {}\n'.format(prog.get_path()))
- fn.write('\n')
- fn.write('%description\n')
- fn.write('\n')
- if devel_subpkg:
- fn.write('%package devel\n')
- fn.write('Summary: Development files for %{name}\n')
- fn.write('Requires: %{name}%{?_isa} = %{?epoch:%{epoch}:}{version}-%{release}\n')
- fn.write('\n')
- fn.write('%description devel\n')
- fn.write('Development files for %{name}.\n')
- fn.write('\n')
- fn.write('%prep\n')
- fn.write('%autosetup\n')
- fn.write('\n')
- fn.write('%build\n')
- fn.write('%meson\n')
- fn.write('%meson_build\n')
- fn.write('\n')
- fn.write('%install\n')
- fn.write('%meson_install\n')
- if to_delete:
- fn.write('rm -vf %s\n' % ' '.join(to_delete))
- fn.write('\n')
- fn.write('%check\n')
- fn.write('%meson_test\n')
- fn.write('\n')
- fn.write('%files\n')
- for f in files:
- fn.write('%s\n' % f)
- fn.write('\n')
- if devel_subpkg:
- fn.write('%files devel\n')
- for f in files_devel:
- fn.write('%s\n' % f)
- fn.write('\n')
- if so_installed:
- fn.write('%post -p /sbin/ldconfig\n')
- fn.write('%postun -p /sbin/ldconfig\n')
- fn.write('\n')
- fn.write('%changelog\n')
- fn.write('* %s meson <meson@example.com> - \n' %
- datetime.date.today().strftime('%a %b %d %Y'))
- fn.write('- \n')
- fn.write('\n')
- mlog.log('RPM spec template written to %s.spec.\n' % proj)
-
- def __get_required_compilers(self, state):
- required_compilers = set()
- 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')
- elif isinstance(compiler, compilers.GnuCPPCompiler):
- required_compilers.add('gcc-c++')
- elif isinstance(compiler, compilers.ElbrusCCompiler):
- required_compilers.add('lcc')
- elif isinstance(compiler, compilers.ElbrusCPPCompiler):
- required_compilers.add('lcc')
- elif isinstance(compiler, compilers.ElbrusFortranCompiler):
- required_compilers.add('lcc')
- elif isinstance(compiler, compilers.ValaCompiler):
- required_compilers.add('vala')
- elif isinstance(compiler, compilers.GnuFortranCompiler):
- required_compilers.add('gcc-gfortran')
- elif isinstance(compiler, compilers.GnuObjCCompiler):
- required_compilers.add('gcc-objc')
- elif compiler == compilers.GnuObjCPPCompiler:
- required_compilers.add('gcc-objc++')
- else:
- mlog.log('RPM spec file not created, generation not allowed for:',
- mlog.bold(compiler.get_id()))
- return required_compilers
-
-
-def initialize(*args, **kwargs):
- return RPMModule(*args, **kwargs)
diff --git a/mesonbuild/modules/sourceset.py b/mesonbuild/modules/sourceset.py
index ba8b300..515e670 100644
--- a/mesonbuild/modules/sourceset.py
+++ b/mesonbuild/modules/sourceset.py
@@ -154,8 +154,12 @@ class SourceSet(MutableModuleObject):
def _get_from_config_data(key):
nonlocal config_cache
if key not in config_cache:
- args = [key] if strict else [key, False]
- config_cache[key] = config_data.get_method(args, {})
+ if key in config_data:
+ config_cache[key] = config_data.get(key)[0]
+ elif strict:
+ raise InvalidArguments(f'sourceset.apply: key "{key}" not in passed configuration, and strict set.')
+ else:
+ config_cache[key] = False
return config_cache[key]
files = self.collect(_get_from_config_data, False)
diff --git a/mesonbuild/modules/unstable_simd.py b/mesonbuild/modules/unstable_simd.py
index 3339cea..8715a14 100644
--- a/mesonbuild/modules/unstable_simd.py
+++ b/mesonbuild/modules/unstable_simd.py
@@ -13,6 +13,7 @@
# limitations under the License.
from .. import mesonlib, compilers, mlog
+from .. import build
from . import ExtensionModule
@@ -57,8 +58,7 @@ class SimdModule(ExtensionModule):
compiler = kwargs['compiler']
if not isinstance(compiler, compilers.compilers.Compiler):
raise mesonlib.MesonException('Compiler argument must be a compiler object.')
- cdata = self.interpreter.func_configuration_data(None, [], {})
- conf = cdata.conf_data
+ conf = build.ConfigurationData()
for iset in self.isets:
if iset not in kwargs:
continue
@@ -82,7 +82,7 @@ class SimdModule(ExtensionModule):
all_lang_args = old_lang_args + args
lib_kwargs[langarg_key] = all_lang_args
result.append(self.interpreter.func_static_lib(None, [libname], lib_kwargs))
- return [result, cdata]
+ return [result, conf]
def initialize(*args, **kwargs):
return SimdModule(*args, **kwargs)