diff --git a/mesonbuild/modules/i18n.py b/mesonbuild/modules/i18n.py index 33874fa6a..00787f884 100644 --- a/mesonbuild/modules/i18n.py +++ b/mesonbuild/modules/i18n.py @@ -24,8 +24,12 @@ class I18nModule: languages = mesonlib.stringlistify(kwargs.get('languages', [])) if len(languages) == 0: raise coredata.MesonException('List of languages empty.') + datadirs = mesonlib.stringlistify(kwargs.get('data_dirs', [])) extra_args = mesonlib.stringlistify(kwargs.get('args', [])) - potargs = [state.environment.get_build_command(), '--internal', 'gettext', 'pot', packagename] + extra_args + potargs = [state.environment.get_build_command(), '--internal', 'gettext', 'pot', packagename] + if datadirs: + potargs.append('--datadirs=' + ':'.join(datadirs)) + potargs += extra_args pottarget = build.RunTarget(packagename + '-pot', sys.executable, potargs, [], state.subdir) gmoargs = [state.environment.get_build_command(), '--internal', 'gettext', 'gen_gmo'] + languages gmotarget = build.RunTarget(packagename + '-gmo', sys.executable, gmoargs, [], state.subdir) diff --git a/mesonbuild/scripts/gettext.py b/mesonbuild/scripts/gettext.py index ba6b2429c..95fd45a5f 100644 --- a/mesonbuild/scripts/gettext.py +++ b/mesonbuild/scripts/gettext.py @@ -15,7 +15,7 @@ import os, subprocess, shutil from mesonbuild.scripts import destdir_join -def run_potgen(src_sub, pkgname, args): +def run_potgen(src_sub, pkgname, datadirs, args): listfile = os.path.join(src_sub, 'POTFILES') if not os.path.exists(listfile): listfile = os.path.join(src_sub, 'POTFILES.in') @@ -23,9 +23,14 @@ def run_potgen(src_sub, pkgname, args): print('Could not find file POTFILES in %s' % src_sub) return 1 + child_env = os.environ.copy() + if datadirs: + child_env['GETTEXTDATADIRS'] = datadirs + ofile = os.path.join(src_sub, pkgname + '.pot') return subprocess.call(['xgettext', '--package-name=' + pkgname, '-p', src_sub, '-f', listfile, - '-D', os.environ['MESON_SOURCE_ROOT'], '-k_', '-o', ofile] + args) + '-D', os.environ['MESON_SOURCE_ROOT'], '-k_', '-o', ofile] + args, + env=child_env) def gen_gmo(src_sub, bld_sub, langs): for l in langs: @@ -47,9 +52,12 @@ def do_install(src_sub, bld_sub, dest, pkgname, langs): def run(args): subcmd = args[0] if subcmd == 'pot': + pkgname = args[1] + datadirs = args[2][11:] if args[2].startswith('--datadirs=') else None + extra_args = args[3:] if datadirs is not None else args[2:] src_sub = os.path.join(os.environ['MESON_SOURCE_ROOT'], os.environ['MESON_SUBDIR']) bld_sub = os.path.join(os.environ['MESON_BUILD_ROOT'], os.environ['MESON_SUBDIR']) - return run_potgen(src_sub, args[1], args[2:]) + return run_potgen(src_sub, pkgname, datadirs, extra_args) elif subcmd == 'gen_gmo': src_sub = os.path.join(os.environ['MESON_SOURCE_ROOT'], os.environ['MESON_SUBDIR']) bld_sub = os.path.join(os.environ['MESON_BUILD_ROOT'], os.environ['MESON_SUBDIR'])