summaryrefslogtreecommitdiffstats
path: root/extras/CustomTarget_autocorr.mk
diff options
context:
space:
mode:
Diffstat (limited to 'extras/CustomTarget_autocorr.mk')
-rw-r--r--extras/CustomTarget_autocorr.mk87
1 files changed, 40 insertions, 47 deletions
diff --git a/extras/CustomTarget_autocorr.mk b/extras/CustomTarget_autocorr.mk
index 8ac2dd86502a..bfc6177105e9 100644
--- a/extras/CustomTarget_autocorr.mk
+++ b/extras/CustomTarget_autocorr.mk
@@ -9,6 +9,8 @@
$(eval $(call gb_CustomTarget_CustomTarget,extras/source/autocorr))
+autocorr_PYTHONCOMMAND := $(call gb_ExternalExecutable_get_command,python)
+
extras_AUTOCORR_LANGS := \
af-ZA:af-ZA \
bg:bg-BG \
@@ -53,12 +55,15 @@ extras_AUTOCORR_LANGS := \
sr-ME:sr-ME \
sr-RS:sr-RS \
sv:sv-SE \
+ th:th-TH \
tr:tr-TR \
vi:vi-VN \
vro:vro-EE \
zh-CN:zh-CN \
zh-TW:zh-TW \
+extras_AUTOCORR_SHORTLANG = $(firstword $(subst :, ,$(filter %:$(1),$(extras_AUTOCORR_LANGS))))
+
extras_AUTOCORR_XMLFILES := \
af-ZA/DocumentList.xml \
af-ZA/META-INF/manifest.xml \
@@ -132,6 +137,7 @@ extras_AUTOCORR_XMLFILES := \
hu/META-INF/manifest.xml \
hu/SentenceExceptList.xml \
hu/WordExceptList.xml \
+ is/DocumentList.xml \
is/META-INF/manifest.xml \
is/SentenceExceptList.xml \
it/DocumentList.xml \
@@ -218,6 +224,8 @@ extras_AUTOCORR_XMLFILES := \
sv/META-INF/manifest.xml \
sv/SentenceExceptList.xml \
sv/WordExceptList.xml \
+ th/DocumentList.xml \
+ th/META-INF/manifest.xml \
tr/DocumentList.xml \
tr/META-INF/manifest.xml \
tr/SentenceExceptList.xml \
@@ -234,62 +242,47 @@ extras_AUTOCORR_XMLFILES := \
zh-TW/META-INF/manifest.xml \
zh-TW/SentenceExceptList.xml \
+# param: shortlang
+extras_AUTOCORR_XMLFILES_LANG = $(subst $(1)/,,$(filter $(1)/%,$(extras_AUTOCORR_XMLFILES)))
-extras_AUTOCORR_MIMETYPEFILES := $(foreach lang,$(extras_AUTOCORR_LANGS),$(firstword $(subst :, ,$(lang)))/mimetype)
-
-
-$(call gb_CustomTarget_get_target,extras/source/autocorr) : \
- $(foreach lang,$(extras_AUTOCORR_LANGS),$(call gb_CustomTarget_get_workdir,extras/source/autocorr)/acor_$(lastword $(subst :, ,$(lang))).dat)
-
-$(call gb_CustomTarget_get_workdir,extras/source/autocorr)/%/mimetype : $(SRCDIR)/extras/source/autocorr/lang/%/mimetype
- $(call gb_Output_announce,autocorr/$*/mimetype,$(true),CPY,1)
- $(call gb_Trace_StartRange,autocorr/$*/mimetype,CPY)
- cp $< $@
- $(call gb_Trace_EndRange,autocorr/$*/mimetype,CPY)
+$(call gb_CustomTarget_get_workdir,extras/source/autocorr)/%/mimetype : \
+ | $(dir $(call gb_CustomTarget_get_workdir,extras/source/autocorr)/%/mimetype).dir
+ $(call gb_Output_announce,autocorr/$*/mimetype,$(true),TCH,1)
+ $(call gb_Trace_StartRange,autocorr/$*/mimetype,TCH)
+ touch $@
+ $(call gb_Trace_EndRange,autocorr/$*/mimetype,TCH)
+.SECONDEXPANSION:
+# secondexpansion since the pattern not just covers a file, but also a directory portion with
+# different number of elements (just the lang or lang/META-INF) and thus the directory dependency
+# needs the stem of the actual target to work as intended
$(call gb_CustomTarget_get_workdir,extras/source/autocorr)/%.xml : $(SRCDIR)/extras/source/autocorr/lang/%.xml \
- | $(call gb_ExternalExecutable_get_dependencies,xsltproc)
+ | $(call gb_ExternalExecutable_get_dependencies,xsltproc) \
+ $$(dir $(call gb_CustomTarget_get_workdir,extras/source/autocorr)/$$*.xml).dir
$(call gb_Output_announce,autocorr/$*.xml,$(true),XSL,1)
$(call gb_Trace_StartRange,autocorr/$*.xml,XSL)
$(call gb_ExternalExecutable_get_command,xsltproc) --nonet -o $@ $(SRCDIR)/extras/util/compact.xsl $<
$(call gb_Trace_EndRange,autocorr/$*.xml,XSL)
-$(call gb_CustomTarget_get_workdir,extras/source/autocorr)/%.dat :
- $(call gb_Output_announce,autocorr/$*.dat,$(true),ZIP,2)
- $(call gb_Trace_StartRange,autocorr/$*.dat,ZIP)
+# secondexpansion necessary since the .dat are created with longlang form, while the other files
+# are created in the shortlang directory, and thus % cannot be used verbatim, the second expansion
+# allows the actual stem from the target to be used in the macro calls
+# there's no reason for the different directories though, so a janitorial cleanup would be
+# TODO: get rid of the shortform:longform language names when assembling the autocorr files
+$(call gb_CustomTarget_get_workdir,extras/source/autocorr)/acor_%.dat : \
+ $$(addprefix \
+ $(call gb_CustomTarget_get_workdir,extras/source/autocorr)/$$(call extras_AUTOCORR_SHORTLANG,$$*)/,\
+ mimetype \
+ $$(call extras_AUTOCORR_XMLFILES_LANG,$$(call extras_AUTOCORR_SHORTLANG,$$*))) \
+ | $(call gb_ExternalExecutable_get_dependencies,python)
+ $(call gb_Output_announce,autocorr/acor_$*.dat,$(true),ZIP,2)
+ $(call gb_Trace_StartRange,autocorr/acor_$*.dat,ZIP)
$(call gb_Helper_abbreviate_dirs,\
- cd $(EXTRAS_AUTOCORR_DIR) && \
- zip -q0X --filesync --must-match $@ $(EXTRAS_AUTOCORR_MIMEFILES_FILTER) && \
- zip -qrX --must-match $@ $(EXTRAS_AUTOCORR_XMLFILES_FILTER) \
+ cd $(dir $<) && \
+ $(autocorr_PYTHONCOMMAND) $(SRCDIR)/bin/check-autocorr.py DocumentList.xml && \
+ zip -q0X --filesync --must-match $@ mimetype && \
+ zip -qrX --must-match $@ $(call extras_AUTOCORR_XMLFILES_LANG,$(call extras_AUTOCORR_SHORTLANG,$*)) \
)
- $(call gb_Trace_EndRange,autocorr/$*.dat,ZIP)
-
-define extras_Autocorr_make_file_deps
-$(call gb_CustomTarget_get_workdir,$(1))/$(2) : $(SRCDIR)/$(1)/lang/$(2) \
- | $(dir $(call gb_CustomTarget_get_workdir,$(1))/$(2)).dir
-
-endef
-
-define extras_Autocorr_make_zip_deps
-$(call gb_CustomTarget_get_workdir,$(1))/$(2) : \
- $(addprefix $(call gb_CustomTarget_get_workdir,$(1))/,$(filter $(3)/%,$(extras_AUTOCORR_MIMETYPEFILES) $(extras_AUTOCORR_XMLFILES))) \
- | $(dir $(call gb_CustomTarget_get_workdir,$(1))/$(2)).dir
-
-$(call gb_CustomTarget_get_workdir,$(1))/$(2) : \
- EXTRAS_AUTOCORR_MIMEFILES_FILTER := $(foreach file,$(filter $(3)/%,$(extras_AUTOCORR_MIMETYPEFILES)),$(subst $(3)/,,$(file)))
-$(call gb_CustomTarget_get_workdir,$(1))/$(2) : \
- EXTRAS_AUTOCORR_XMLFILES_FILTER := $(foreach file,$(filter $(3)/%,$(extras_AUTOCORR_XMLFILES)),$(subst $(3)/,,$(file)))
-$(call gb_CustomTarget_get_workdir,$(1))/$(2) : \
- EXTRAS_AUTOCORR_DIR := $(call gb_CustomTarget_get_workdir,$(1))/$(3)
-
-endef
-
-$(eval $(foreach file,$(extras_AUTOCORR_MIMETYPEFILES) $(extras_AUTOCORR_XMLFILES),\
- $(call extras_Autocorr_make_file_deps,extras/source/autocorr,$(file)) \
-))
-
-$(eval $(foreach lang,$(extras_AUTOCORR_LANGS),\
- $(call extras_Autocorr_make_zip_deps,extras/source/autocorr,acor_$(lastword $(subst :, ,$(lang))).dat,$(firstword $(subst :, ,$(lang)))) \
-))
+ $(call gb_Trace_EndRange,autocorr/acor_$*.dat,ZIP)
# vim: set noet sw=4 ts=4: