aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/scripts
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2022-05-07 23:03:01 -0400
committerEli Schwartz <eschwartz@archlinux.org>2022-05-29 18:23:03 -0400
commit34da721ec2ad96d35a829f5e977ec253e82b9d91 (patch)
tree7b7d9aa58f51170d3fc6bebb3389c529db1e55dc /mesonbuild/scripts
parent6757e4f07c9f780ed33b21ac15f5f5727a6a10f3 (diff)
downloadmeson-34da721ec2ad96d35a829f5e977ec253e82b9d91.zip
meson-34da721ec2ad96d35a829f5e977ec253e82b9d91.tar.gz
meson-34da721ec2ad96d35a829f5e977ec253e82b9d91.tar.bz2
gettext: explicitly pass source root / subdir as cli args
Because this is a wrapper script and we could/should do this, we even have half the infra for it.
Diffstat (limited to 'mesonbuild/scripts')
-rw-r--r--mesonbuild/scripts/gettext.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/mesonbuild/scripts/gettext.py b/mesonbuild/scripts/gettext.py
index c329892..c31657a 100644
--- a/mesonbuild/scripts/gettext.py
+++ b/mesonbuild/scripts/gettext.py
@@ -23,6 +23,7 @@ parser.add_argument('--pkgname', default='')
parser.add_argument('--datadirs', default='')
parser.add_argument('--langs', default='')
parser.add_argument('--localedir', default='')
+parser.add_argument('--source-root', default='')
parser.add_argument('--subdir', default='')
parser.add_argument('--xgettext', default='xgettext')
parser.add_argument('--msgmerge', default='msgmerge')
@@ -45,7 +46,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, xgettext: 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], source_root: str) -> int:
listfile = os.path.join(src_sub, 'POTFILES.in')
if not os.path.exists(listfile):
listfile = os.path.join(src_sub, 'POTFILES')
@@ -59,7 +60,7 @@ def run_potgen(src_sub: str, xgettext: str, pkgname: str, datadirs: str, args: T
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', source_root, '-k_', '-o', ofile] + args,
env=child_env)
def update_po(src_sub: str, msgmerge: str, msginit: str, pkgname: str, langs: T.List[str]) -> int:
@@ -77,18 +78,16 @@ def run(args: T.List[str]) -> int:
subcmd = options.command
langs = options.langs.split('@@') if options.langs else None
extra_args = options.extra_args.split('@@') if options.extra_args else []
- subdir = os.environ.get('MESON_SUBDIR', '')
- if options.subdir:
- subdir = options.subdir
- src_sub = os.path.join(os.environ['MESON_SOURCE_ROOT'], subdir)
+ subdir = options.subdir
+ src_sub = os.path.join(options.source_root, subdir)
if not langs:
langs = read_linguas(src_sub)
if subcmd == 'pot':
- return run_potgen(src_sub, options.xgettext, options.pkgname, options.datadirs, extra_args)
+ return run_potgen(src_sub, options.xgettext, options.pkgname, options.datadirs, extra_args, options.source_root)
elif subcmd == 'update_po':
- if run_potgen(src_sub, options.xgettext, options.pkgname, options.datadirs, extra_args) != 0:
+ if run_potgen(src_sub, options.xgettext, options.pkgname, options.datadirs, extra_args, options.source_root) != 0:
return 1
return update_po(src_sub, options.msgmerge, options.msginit, options.pkgname, langs)
else: