diff options
author | Christian Lohmaier <cloph@documentfoundation.org> | 2022-12-13 14:35:15 +0100 |
---|---|---|
committer | Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> | 2022-12-19 11:28:51 +0000 |
commit | 47d547be539ab2822babba4dc0fb230f971de450 (patch) | |
tree | 8f5bc5dc61696508519c51eb9ded757d2c660229 /CustomTarget_html.mk | |
parent | df678c89e22b980cac67717ed4b2a60754f2272d (diff) |
hid2file.js generation: process in batch, not each file one-by-one
xsltproc can happily process many files at once, no need to process them
individually and also no need to surround them with the rm, touch, rm
triplet each time to catch a possible error.
When letting xargs actually run the command, then xargs will report
error if any invocation failed. It will not stop execution commands for
remaining input unless the command exists with status 255 explicitly,
but this doesn't matter, processing the whole batch regardless is still
much faster than processing each file separately.
To maximize the number of files that can be processed in a single
command, don't prefix each file with $(SRCDIR)/, but instead cd to
$(SRCRDIR) before running the command.
Change-Id: I532a54f7298d7011900af5e618d75b37649b0477
Reviewed-on: https://gerrit.libreoffice.org/c/help/+/144050
Tested-by: Jenkins
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
(cherry picked from commit f048f02f505704a76c4f01b4ff3f369e8ed928b5)
Reviewed-on: https://gerrit.libreoffice.org/c/help/+/144065
Diffstat (limited to 'CustomTarget_html.mk')
-rw-r--r-- | CustomTarget_html.mk | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/CustomTarget_html.mk b/CustomTarget_html.mk index 7c6ed744da..46068e82b0 100644 --- a/CustomTarget_html.mk +++ b/CustomTarget_html.mk @@ -38,9 +38,6 @@ $(eval $(call gb_CustomTarget_register_targets,helpcontent2/help3xsl,\ ) \ )) -# In the below recipe, the file $@.good is used to communicate failure of xsltproc in the pipeline -# (similar to Bash's `set -o pipefail`; the final `rm $@.good` will fail, and fail the whole -# command, if the xsltproc invocation failed): $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/hid2file.js : \ $(SRCDIR)/helpcontent2/help3xsl/generate_hid2file.xsl \ $(call gb_ExternalExecutable_get_dependencies,xsltproc) \ @@ -49,15 +46,9 @@ $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/hid2file.js : \ $(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),XSL,1) $(call gb_Helper_abbreviate_dirs,\ ( \ + RESPONSEFILE=$(call gb_var2file,$(shell $(gb_MKTEMP)),$(foreach module,$(html_TEXT_MODULES),$(gb_AllLangHelp_$(module)_HELPFILES))) && \ echo 'var hid2fileMap = {' \ - && RESPONSEFILE=$(call gb_var2file,$(shell $(gb_MKTEMP)),$(foreach module,$(html_TEXT_MODULES),$(addprefix $(SRCDIR)/,$(gb_AllLangHelp_$(module)_HELPFILES)))) \ - && <"$$RESPONSEFILE" $(if $(filter WNT,$(OS)),tr -d '\r' | env -i PATH="$$PATH") xargs -n 1 printf '%s\n' \ - | while read xhp; do \ - rm -f $@.good && \ - { $(call gb_ExternalExecutable_get_command,xsltproc) $< $$xhp && touch $@.good; } \ - | $(gb_AWK) 'NF' \ - && rm $@.good || exit \ - ; done \ + && cd $(SRCDIR) && xargs $(call gb_ExternalExecutable_get_command,xsltproc) $< <$$RESPONSEFILE || { rm $$RESPONSEFILE; exit 1 ; } \ && rm "$$RESPONSEFILE" \ && echo '};' \ ) > $@ \ |