summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2021-04-29 09:45:39 -0400
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2021-04-29 15:30:27 -0400
commit0d353b06ec6571972d2e8a3e3a3f0b27aa950e1c (patch)
tree2b086ec976a4a36eb13c5216c2f2ccda38d90fc1
parenteaf79d319dd785b1d8b213ffa4dc6a3a338434e8 (diff)
build: Make doc-po-update and doc-pot-update targets idempotent.v1.3.0rc1
It used to be that the running the doc-po-update and doc-pot-update targets would redo the same work on every run. This change splits the problem in smaller chunks and specifies build dependencies in a way that outputs only get rebuilt when their inputs changed. * po/doc/local.mk (DOC_PO_FILES): Harmonize escapes. (POT_OPTIONS): Re-indent uniformly. (doc-po-update-%, doc-po-update-cookbook-%): Re-implement with... (make-update-po-files-rule): ... this new function. (TMP_POT_FILES): Remove variable. (%D%/%.pot, %D%/guix-manual.pot): New pattern rules. (doc-pot-update, doc-po-update): Adjust prerequisites accordingly.
-rw-r--r--po/doc/local.mk108
1 files changed, 35 insertions, 73 deletions
diff --git a/po/doc/local.mk b/po/doc/local.mk
index 90cb6a79bbe..da43c0a3147 100644
--- a/po/doc/local.mk
+++ b/po/doc/local.mk
@@ -1,5 +1,6 @@
1# GNU Guix --- Functional package management for GNU 1# GNU Guix --- Functional package management for GNU
2# Copyright © 2018 Julien Lepiller <julien@lepiller.eu> 2# Copyright © 2018 Julien Lepiller <julien@lepiller.eu>
3# Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
3# 4#
4# This file is part of GNU Guix. 5# This file is part of GNU Guix.
5# 6#
@@ -16,7 +17,7 @@
16# You should have received a copy of the GNU General Public License 17# You should have received a copy of the GNU General Public License
17# along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. 18# along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18 19
19DOC_PO_FILES= \ 20DOC_PO_FILES = \
20 %D%/guix-manual.es.po \ 21 %D%/guix-manual.es.po \
21 %D%/guix-manual.de.po \ 22 %D%/guix-manual.de.po \
22 %D%/guix-manual.fa.po \ 23 %D%/guix-manual.fa.po \
@@ -28,11 +29,11 @@ DOC_PO_FILES= \
28 %D%/guix-manual.sk.po \ 29 %D%/guix-manual.sk.po \
29 %D%/guix-manual.zh_CN.po 30 %D%/guix-manual.zh_CN.po
30 31
31DOC_COOKBOOK_PO_FILES= \ 32DOC_COOKBOOK_PO_FILES = \
32 %D%/guix-cookbook.de.po \ 33 %D%/guix-cookbook.de.po \
33 %D%/guix-cookbook.fa.po \ 34 %D%/guix-cookbook.fa.po \
34 %D%/guix-cookbook.fr.po \ 35 %D%/guix-cookbook.fr.po \
35 %D%/guix-cookbook.ko.po \ 36 %D%/guix-cookbook.ko.po \
36 %D%/guix-cookbook.zh_Hans.po 37 %D%/guix-cookbook.zh_Hans.po
37 38
38EXTRA_DIST = \ 39EXTRA_DIST = \
@@ -41,76 +42,37 @@ EXTRA_DIST = \
41 $(DOC_PO_FILES) \ 42 $(DOC_PO_FILES) \
42 $(DOC_COOKBOOK_PO_FILES) 43 $(DOC_COOKBOOK_PO_FILES)
43 44
44POT_OPTIONS = --package-name "guix manual" --package-version "$(VERSION)" \ 45POT_OPTIONS = \
45 --copyright-holder "the authors of Guix (msgids)" \ 46 --package-name "guix manual" --package-version "$(VERSION)" \
46 --msgid-bugs-address "bug-guix@gnu.org" 47 --copyright-holder "the authors of Guix (msgids)" \
48 --msgid-bugs-address "bug-guix@gnu.org"
47 49
48doc-po-update-%: 50# make-download-po-files-rule PO_FILES POT_FILE_INPUT
49 @lang=`echo "$@" | sed -e's/^doc-po-update-//'` ; \ 51define make-update-po-files-rule
50 output="$(srcdir)/po/doc/guix-manual.$$lang.po" ; \ 52$(1): $(2)
51 input="$(srcdir)/po/doc/guix-manual.pot" ; \ 53 @if ! [ -f "$$@" ]; then \
52 if test -f "$$output"; then \ 54 echo "File $$po_file does not exist. If you are a translator, \
53 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ 55you can create it with 'msginit'." 1>&2; \
54 echo "$${cdcmd}$(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} $$output $$input"; \ 56 exit 1; \
55 cd $(srcdir) \ 57 fi && \
56 && { case `$(MSGMERGE_UPDATE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \ 58 lang=$$$$(echo $$@ | $(SED) -E 's|.*\.([^.]*)\.po$$$$|\1|') && \
57 '' | 0.[0-9] | 0.[0-9].* | 0.1[0-7] | 0.1[0-7].*) \ 59 echo $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) \
58 $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) "$$output" "$$input";; \ 60 --lang=$$$${lang} "$$@" "$$<" && \
59 *) \ 61 $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$$$${lang} "$$@" "$$<"
60 $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} "$$output" "$$input";; \ 62endef
61 esac; \
62 }; \
63 touch "$$output"; \
64 else \
65 echo "File $$output does not exist. If you are a translator, you can create it with 'msginit'." 1>&2; \
66 exit 1; \
67 fi
68 63
69doc-po-update-cookbook-%: 64%D%/%.pot: $(srcdir)/doc/%.texi
70 @lang=`echo "$@" | sed -e's/^doc-po-update-cookbook-//'` ; \
71 output="$(srcdir)/po/doc/guix-cookbook.$$lang.po" ; \
72 input="$(srcdir)/po/doc/guix-cookbook.pot" ; \
73 if test -f "$$output"; then \
74 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
75 echo "$${cdcmd}$(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} $$output $$input"; \
76 cd $(srcdir) \
77 && { case `$(MSGMERGE_UPDATE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
78 '' | 0.[0-9] | 0.[0-9].* | 0.1[0-7] | 0.1[0-7].*) \
79 $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) "$$output" "$$input";; \
80 *) \
81 $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} "$$output" "$$input";; \
82 esac; \
83 }; \
84 touch "$$output"; \
85 else \
86 echo "File $$output does not exist. If you are a translator, you can create it with 'msginit'." 1>&2; \
87 exit 1; \
88 fi
89
90$(srcdir)/po/doc/%.pot-update: doc/%.texi
91 $(AM_V_PO4A)$(PO4A_UPDATEPO) -M UTF-8 -f texinfo -m "$<" \ 65 $(AM_V_PO4A)$(PO4A_UPDATEPO) -M UTF-8 -f texinfo -m "$<" \
92 -p "$$(echo $@ | sed 's|-update||')" $(POT_OPTIONS) 66 -p "$@" $(POT_OPTIONS) && \
93 @touch "$$(echo $@ | sed 's|-update||')" 67 touch $@
94
95TMP_POT_FILES = contributing.pot guix.pot
96
97doc-pot-update:
98 for f in $(TMP_POT_FILES); do \
99 $(MAKE) $(srcdir)/po/doc/$$f-update; \
100 done
101 $(MAKE) $(srcdir)/po/doc/guix-cookbook.pot-update;
102 msgcat $(addprefix $(srcdir)/po/doc/, $(TMP_POT_FILES)) > $(srcdir)/po/doc/guix-manual.pot
103 rm -f $(addprefix $(srcdir)/po/doc/, $(TMP_POT_FILES))
104 68
105doc-po-update: doc-pot-update 69%D%/guix-manual.pot: %D%/guix.pot %D%/contributing.pot
106 for f in $(DOC_PO_FILES); do \ 70 msgcat $< > $@
107 lang="`echo "$$f" | $(SED) -es'|.*/guix-manual\.\(.*\)\.po$$|\1|g'`"; \
108 $(MAKE) "doc-po-update-$$lang"; \
109 done
110 for f in $(DOC_COOKBOOK_PO_FILES); do \
111 lang="`echo "$$f" | $(SED) -es'|.*/guix-cookbook\.\(.*\)\.po$$|\1|g'`"; \
112 $(MAKE) "doc-po-update-cookbook-$$lang"; \
113 done
114 71
72$(eval $(call make-update-po-files-rule,$(DOC_PO_FILES),%D%/guix-manual.pot))
73$(eval $(call make-update-po-files-rule,\
74 $(DOC_COOKBOOK_PO_FILES),%D%/guix-cookbook.pot))
115 75
116.PHONY: doc-po-update doc-pot-update 76doc-pot-update: %D%/guix-manual.pot %D%/guix-cookbook.pot
77doc-po-update: $(DOC_PO_FILES) $(DOC_COOKBOOK_PO_FILES)
78.PHONY: doc-pot-update doc-po-update