summaryrefslogtreecommitdiff
path: root/user/meson/meson-0.62.1-gettext-tiny.patch
blob: 4413a32dcdceb8e16984fa2212a73acb32147958 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
Upstream-URL: https://github.com/mesonbuild/meson/pull/10365

From 7606b19f8981f75b7076a765cec1ecf7b04220fb Mon Sep 17 00:00:00 2001
From: Eli Schwartz <eschwartz@archlinux.org>
Date: Sat, 7 May 2022 23:03:01 -0400
Subject: [PATCH 1/3] 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.
---
 mesonbuild/modules/i18n.py    |  6 ++++++
 mesonbuild/scripts/gettext.py | 15 +++++++--------
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/mesonbuild/modules/i18n.py b/mesonbuild/modules/i18n.py
index 2bdf9d30b97..4bbc69abfb1 100644
--- a/mesonbuild/modules/i18n.py
+++ b/mesonbuild/modules/i18n.py
@@ -251,6 +251,9 @@ def gettext(self, state: 'ModuleState', args: T.Tuple[str], kwargs: 'Gettext') -
         extra_arg = '--extra-args=' + '@@'.join(extra_args) if extra_args else None
 
         potargs = state.environment.get_build_command() + ['--internal', 'gettext', 'pot', pkg_arg]
+        potargs.append(f'--source-root={state.source_root}')
+        if state.subdir:
+            potargs.append(f'--subdir={state.subdir}')
         if datadirs:
             potargs.append(datadirs)
         if extra_arg:
@@ -292,6 +295,9 @@ def gettext(self, state: 'ModuleState', args: T.Tuple[str], kwargs: 'Gettext') -
         targets.append(allgmotarget)
 
         updatepoargs = state.environment.get_build_command() + ['--internal', 'gettext', 'update_po', pkg_arg]
+        updatepoargs.append(f'--source-root={state.source_root}')
+        if state.subdir:
+            updatepoargs.append(f'--subdir={state.subdir}')
         if lang_arg:
             updatepoargs.append(lang_arg)
         if datadirs:
diff --git a/mesonbuild/scripts/gettext.py b/mesonbuild/scripts/gettext.py
index c3298926ef8..c31657a71d3 100644
--- a/mesonbuild/scripts/gettext.py
+++ b/mesonbuild/scripts/gettext.py
@@ -23,6 +23,7 @@
 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: