diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2023-04-17 17:33:01 -0400 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2023-05-22 21:20:18 -0400 |
commit | 1f71911ae4d6c061a3704dbf17430656f874f5b8 (patch) | |
tree | 276f79878683ec879efb861ae8bfa01b9691c6cd | |
parent | af49e8010b41633d7271e0711f4776077419b1fe (diff) | |
download | meson-1f71911ae4d6c061a3704dbf17430656f874f5b8.zip meson-1f71911ae4d6c061a3704dbf17430656f874f5b8.tar.gz meson-1f71911ae4d6c061a3704dbf17430656f874f5b8.tar.bz2 |
i18n module: check for a good enough msgfmt before permitting merge_file
The concept of merge_file intrinsically requires some GNU-specific
functionality, so let's emit a useful error message during
configuration, when we don't have that.
The relevant GNU gettext versions date back to around 2015 so *probably*
anyone has that too, but we may as well verify that while we are here.
-rw-r--r-- | mesonbuild/modules/i18n.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/mesonbuild/modules/i18n.py b/mesonbuild/modules/i18n.py index 0022deb..11dd9ef 100644 --- a/mesonbuild/modules/i18n.py +++ b/mesonbuild/modules/i18n.py @@ -23,6 +23,7 @@ from .. import mlog from ..interpreter.type_checking import CT_BUILD_BY_DEFAULT, CT_INPUT_KW, INSTALL_TAG_KW, OUTPUT_KW, INSTALL_DIR_KW, INSTALL_KW, NoneType, in_set_validator from ..interpreterbase import FeatureNew from ..interpreterbase.decorators import ContainerTypeInfo, KwargInfo, noPosargs, typed_kwargs, typed_pos_args +from ..programs import ExternalProgram from ..scripts.gettext import read_linguas if T.TYPE_CHECKING: @@ -32,7 +33,6 @@ if T.TYPE_CHECKING: from ..build import Target from ..interpreter import Interpreter from ..interpreterbase import TYPE_var - from ..programs import ExternalProgram class MergeFile(TypedDict): @@ -166,6 +166,15 @@ class I18nModule(ExtensionModule): def merge_file(self, state: 'ModuleState', args: T.List['TYPE_var'], kwargs: 'MergeFile') -> ModuleReturnValue: if self.tools['msgfmt'] is None or not self.tools['msgfmt'].found(): self.tools['msgfmt'] = state.find_program('msgfmt', for_machine=mesonlib.MachineChoice.BUILD) + if isinstance(self.tools['msgfmt'], ExternalProgram): + try: + have_version = self.tools['msgfmt'].get_version() + except mesonlib.MesonException as e: + raise mesonlib.MesonException('i18n.merge_file requires GNU msgfmt') from e + want_version = '>=0.19' if kwargs['type'] == 'desktop' else '>=0.19.7' + if not mesonlib.version_compare(have_version, want_version): + msg = f'i18n.merge_file requires GNU msgfmt {want_version} to produce files of type: ' + kwargs['type'] + f' (got: {have_version})' + raise mesonlib.MesonException(msg) podir = path.join(state.build_to_src, state.subdir, kwargs['po_dir']) ddirs = self._get_data_dirs(state, kwargs['data_dirs']) |