aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorPatrick Griffis <tingping@tingping.se>2016-12-02 20:21:07 -0500
committerJussi Pakkanen <jpakkane@gmail.com>2016-12-03 21:00:20 +0200
commit7d68715297a611f50b256acf5358597ee037eb5d (patch)
treeab9520e199f91572d6e80461e265827afefb018f /mesonbuild
parent8be0df144376673801c2c374b58f45f6d916abe8 (diff)
downloadmeson-7d68715297a611f50b256acf5358597ee037eb5d.zip
meson-7d68715297a611f50b256acf5358597ee037eb5d.tar.gz
meson-7d68715297a611f50b256acf5358597ee037eb5d.tar.bz2
i18n: Add merge_file function
This is a repeated task that we can simplify Closes #1120
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/modules/i18n.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/mesonbuild/modules/i18n.py b/mesonbuild/modules/i18n.py
index bb1b2f8..838749b 100644
--- a/mesonbuild/modules/i18n.py
+++ b/mesonbuild/modules/i18n.py
@@ -14,10 +14,26 @@
from os import path
from .. import coredata, mesonlib, build
+from ..mesonlib import MesonException
import sys
class I18nModule:
+ def merge_file(self, state, args, kwargs):
+ podir = kwargs.pop('po_dir', None)
+ if not podir:
+ raise MesonException('i18n: po_dir is a required kwarg')
+ podir = path.join(state.build_to_src, state.subdir, podir)
+
+ file_type = kwargs.pop('type', 'xml')
+ VALID_TYPES = ('xml', 'desktop')
+ if not file_type in VALID_TYPES:
+ raise MesonException('i18n: "{}" is not a valid type {}'.format(file_type, VALID_TYPES))
+
+ kwargs['command'] = ['msgfmt', '--' + file_type,
+ '--template', '@INPUT@', '-d', podir, '-o', '@OUTPUT@']
+ return build.CustomTarget(kwargs['output'] + '_merge', state.subdir, kwargs)
+
@staticmethod
def _read_linguas(state):
linguas = path.join(state.environment.get_source_dir(), state.subdir, 'LINGUAS')