diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2022-03-05 20:07:10 -0500 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2022-03-06 10:48:34 -0500 |
commit | 768616b0f8c0a0349e84517b51b1b8e51c79d6b6 (patch) | |
tree | aee0e9eb61a93e21f9fd6976ab615583d3848255 /mesonbuild/scripts/gettext.py | |
parent | e67fd1f55135c2a80257efcb9a19607024568f8d (diff) | |
download | meson-768616b0f8c0a0349e84517b51b1b8e51c79d6b6.zip meson-768616b0f8c0a0349e84517b51b1b8e51c79d6b6.tar.gz meson-768616b0f8c0a0349e84517b51b1b8e51c79d6b6.tar.bz2 |
scripts: accept the path of the gettext commands to run as an argument
Don't assume itstool, msgfmt et al. are just magically on the path.
Normally for commands being processed in build.ninja we'd look up the
program in order to run it. Offer the same guarantee for programs being
passed through an awkward script wrapper.
Diffstat (limited to 'mesonbuild/scripts/gettext.py')
-rw-r--r-- | mesonbuild/scripts/gettext.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/mesonbuild/scripts/gettext.py b/mesonbuild/scripts/gettext.py index d6bd366..c329892 100644 --- a/mesonbuild/scripts/gettext.py +++ b/mesonbuild/scripts/gettext.py @@ -24,6 +24,9 @@ parser.add_argument('--datadirs', default='') parser.add_argument('--langs', default='') parser.add_argument('--localedir', default='') parser.add_argument('--subdir', default='') +parser.add_argument('--xgettext', default='xgettext') +parser.add_argument('--msgmerge', default='msgmerge') +parser.add_argument('--msginit', default='msginit') parser.add_argument('--extra-args', default='') def read_linguas(src_sub: str) -> T.List[str]: @@ -42,7 +45,7 @@ def read_linguas(src_sub: str) -> T.List[str]: print(f'Could not find file LINGUAS in {src_sub}') return [] -def run_potgen(src_sub: str, pkgname: str, datadirs: str, args: T.List[str]) -> int: +def run_potgen(src_sub: str, xgettext: str, pkgname: str, datadirs: str, args: T.List[str]) -> int: listfile = os.path.join(src_sub, 'POTFILES.in') if not os.path.exists(listfile): listfile = os.path.join(src_sub, 'POTFILES') @@ -55,18 +58,18 @@ def run_potgen(src_sub: str, pkgname: str, datadirs: str, args: T.List[str]) -> child_env['GETTEXTDATADIRS'] = datadirs ofile = os.path.join(src_sub, pkgname + '.pot') - return subprocess.call(['xgettext', '--package-name=' + pkgname, '-p', src_sub, '-f', listfile, + return subprocess.call([xgettext, '--package-name=' + pkgname, '-p', src_sub, '-f', listfile, '-D', os.environ['MESON_SOURCE_ROOT'], '-k_', '-o', ofile] + args, env=child_env) -def update_po(src_sub: str, pkgname: str, langs: T.List[str]) -> int: +def update_po(src_sub: str, msgmerge: str, msginit: str, pkgname: str, langs: T.List[str]) -> int: potfile = os.path.join(src_sub, pkgname + '.pot') for l in langs: pofile = os.path.join(src_sub, l + '.po') if os.path.exists(pofile): - subprocess.check_call(['msgmerge', '-q', '-o', pofile, pofile, potfile]) + subprocess.check_call([msgmerge, '-q', '-o', pofile, pofile, potfile]) else: - subprocess.check_call(['msginit', '--input', potfile, '--output-file', pofile, '--locale', l, '--no-translator']) + subprocess.check_call([msginit, '--input', potfile, '--output-file', pofile, '--locale', l, '--no-translator']) return 0 def run(args: T.List[str]) -> int: @@ -83,11 +86,11 @@ def run(args: T.List[str]) -> int: langs = read_linguas(src_sub) if subcmd == 'pot': - return run_potgen(src_sub, options.pkgname, options.datadirs, extra_args) + return run_potgen(src_sub, options.xgettext, options.pkgname, options.datadirs, extra_args) elif subcmd == 'update_po': - if run_potgen(src_sub, options.pkgname, options.datadirs, extra_args) != 0: + if run_potgen(src_sub, options.xgettext, options.pkgname, options.datadirs, extra_args) != 0: return 1 - return update_po(src_sub, options.pkgname, langs) + return update_po(src_sub, options.msgmerge, options.msginit, options.pkgname, langs) else: print('Unknown subcommand.') return 1 |