[libvirt PATCH 2/7] syntax-check: Introduce sc_pot_comments

Andrea Bolognani abologna at redhat.com
Tue May 17 08:32:12 UTC 2022


We don't want comments to be present in the potfile, unless
they're specifically aimed at translators.

To achieve this, we pass the --add-comments=TRANSLATORS: option
to xgettext. However, we also use the 'glib' preset, which
contains the --add-comments option.

This should work fine, as later options override earlier ones,
but there's a problem: until 0.60, meson would not correctly
preserve the order of options, and so whether or not the potfile
would contain comments we don't care about was entirely down to
chance.

Add a check that will make the test suite fail if unwanted
comments have been added to the potfile.

Signed-off-by: Andrea Bolognani <abologna at redhat.com>
---
 build-aux/syntax-check.mk | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk
index 6664763faf..b14e2e57cc 100644
--- a/build-aux/syntax-check.mk
+++ b/build-aux/syntax-check.mk
@@ -1503,6 +1503,17 @@ sc_po_check:
 	  rm -f $@-1 $@-2;						\
 	fi
 
+pot_file = $(top_srcdir)/po/libvirt.pot
+
+# Before 0.60, meson would sometimes pass options to xgettext in the
+# wrong order, resulting in unwanted comments showing up in the
+# potfile after it was refreshed
+sc_pot_comments:
+	@if $(GREP) -E '^#\. ' $(pot_file) | $(GREP) -Ev 'TRANSLATORS:'; then \
+	  echo "Spurious comments in $(pot_file)" 1>&1; \
+	  exit 1; \
+	fi
+
 # #if WITH_... will evaluate to false for any non numeric string.
 # That would be flagged by using -Wundef, however gnulib currently
 # tests many undefined macros, and so we can't enable that option.
-- 
2.35.3



More information about the libvir-list mailing list