aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/markdown/i18n-module.md6
-rw-r--r--mesonbuild/modules/i18n.py44
2 files changed, 31 insertions, 19 deletions
diff --git a/docs/markdown/i18n-module.md b/docs/markdown/i18n-module.md
index 13c64f8..dc4186a 100644
--- a/docs/markdown/i18n-module.md
+++ b/docs/markdown/i18n-module.md
@@ -49,6 +49,9 @@ This merges translations into a text file using `msgfmt`. See
[[@custom_tgt]]
for normal keywords. In addition it accepts these keywords:
+* `output`: same as `custom_target` but only accepts one item
+* `install_dir`: same as `custom_target` but only accepts one item
+* `install_tag`: same as `custom_target` but only accepts one item
* `data_dirs`: (*Added 0.41.0*) list of directories for its files (See
also `i18n.gettext()`)
* `po_dir`: directory containing translations, relative to current directory
@@ -63,6 +66,9 @@ This joins translations into a XML file using `itstool`. See
[[@custom_tgt]]
for normal keywords. In addition it accepts these keywords:
+* `output`: same as `custom_target` but only accepts one item
+* `install_dir`: same as `custom_target` but only accepts one item
+* `install_tag`: same as `custom_target` but only accepts one item
* `its_files`: filenames of ITS files that should be used explicitly
(XML translation rules are autodetected otherwise).
* `mo_targets` *required*: mo file generation targets as returned by `i18n.gettext()`.
diff --git a/mesonbuild/modules/i18n.py b/mesonbuild/modules/i18n.py
index 4ea5772..5fd3171 100644
--- a/mesonbuild/modules/i18n.py
+++ b/mesonbuild/modules/i18n.py
@@ -20,7 +20,7 @@ from . import ExtensionModule, ModuleReturnValue
from .. import build
from .. import mesonlib
from .. import mlog
-from ..interpreter.type_checking import CT_BUILD_BY_DEFAULT, CT_INPUT_KW, CT_INSTALL_DIR_KW, CT_INSTALL_TAG_KW, MULTI_OUTPUT_KW, INSTALL_KW, NoneType, in_set_validator
+from ..interpreter.type_checking import CT_BUILD_BY_DEFAULT, CT_INPUT_KW, INSTALL_TAG_KW, OUTPUT_KW, INSTALL_KW, NoneType, in_set_validator
from ..interpreterbase import FeatureNew
from ..interpreterbase.decorators import ContainerTypeInfo, KwargInfo, noPosargs, typed_kwargs, typed_pos_args
from ..scripts.gettext import read_linguas
@@ -41,11 +41,11 @@ if T.TYPE_CHECKING:
str, build.BuildTarget, build.CustomTarget, build.CustomTargetIndex,
build.ExtractedObjects, build.GeneratedList, ExternalProgram,
mesonlib.File]]
- output: T.List[str]
+ output: str
build_by_default: bool
install: bool
- install_dir: T.List[T.Union[str, bool]]
- install_tag: T.List[str]
+ install_dir: T.Optional[str]
+ install_tag: T.Optional[str]
args: T.List[str]
data_dirs: T.List[str]
po_dir: str
@@ -66,11 +66,11 @@ if T.TYPE_CHECKING:
str, build.BuildTarget, build.CustomTarget, build.CustomTargetIndex,
build.ExtractedObjects, build.GeneratedList, ExternalProgram,
mesonlib.File]]
- output: T.List[str]
+ output: str
build_by_default: bool
install: bool
- install_dir: T.List[T.Union[str, bool]]
- install_tag: T.List[str]
+ install_dir: T.Optional[str]
+ install_tag: T.Optional[str]
its_files: T.List[str]
mo_targets: T.List[T.Union[build.BuildTarget, build.CustomTarget, build.CustomTargetIndex]]
@@ -152,9 +152,9 @@ class I18nModule(ExtensionModule):
'i18n.merge_file',
CT_BUILD_BY_DEFAULT,
CT_INPUT_KW,
- CT_INSTALL_DIR_KW,
- CT_INSTALL_TAG_KW,
- MULTI_OUTPUT_KW,
+ KwargInfo('install_dir', (str, NoneType)),
+ INSTALL_TAG_KW,
+ OUTPUT_KW,
INSTALL_KW,
_ARGS.evolve(since='0.51.0'),
_DATA_DIRS.evolve(since='0.41.0'),
@@ -187,6 +187,9 @@ class I18nModule(ExtensionModule):
if build_by_default is None:
build_by_default = kwargs['install']
+ install_dir = [kwargs['install_dir']] if kwargs['install_dir'] is not None else None
+ install_tag = [kwargs['install_tag']] if kwargs['install_tag'] is not None else None
+
ct = build.CustomTarget(
'',
state.subdir,
@@ -194,11 +197,11 @@ class I18nModule(ExtensionModule):
state.environment,
command,
kwargs['input'],
- kwargs['output'],
+ [kwargs['output']],
build_by_default=build_by_default,
install=kwargs['install'],
- install_dir=kwargs['install_dir'],
- install_tag=kwargs['install_tag'],
+ install_dir=install_dir,
+ install_tag=install_tag,
)
return ModuleReturnValue(ct, [ct])
@@ -321,9 +324,9 @@ class I18nModule(ExtensionModule):
'i18n.itstool_join',
CT_BUILD_BY_DEFAULT,
CT_INPUT_KW,
- CT_INSTALL_DIR_KW,
- CT_INSTALL_TAG_KW,
- MULTI_OUTPUT_KW,
+ KwargInfo('install_dir', (str, NoneType)),
+ INSTALL_TAG_KW,
+ OUTPUT_KW,
INSTALL_KW,
_ARGS.evolve(),
KwargInfo('its_files', ContainerTypeInfo(list, str)),
@@ -359,6 +362,9 @@ class I18nModule(ExtensionModule):
if build_by_default is None:
build_by_default = kwargs['install']
+ install_dir = [kwargs['install_dir']] if kwargs['install_dir'] is not None else None
+ install_tag = [kwargs['install_tag']] if kwargs['install_tag'] is not None else None
+
ct = build.CustomTarget(
'',
state.subdir,
@@ -366,12 +372,12 @@ class I18nModule(ExtensionModule):
state.environment,
command,
kwargs['input'],
- kwargs['output'],
+ [kwargs['output']],
build_by_default=build_by_default,
extra_depends=mo_targets,
install=kwargs['install'],
- install_dir=kwargs['install_dir'],
- install_tag=kwargs['install_tag'],
+ install_dir=install_dir,
+ install_tag=install_tag,
)
return ModuleReturnValue(ct, [ct])