CustomTarget_html.mk | 105 +++++++++++++++++++++------------------------------ 1 file changed, 44 insertions(+), 61 deletions(-)
New commits: commit 534e501e3ad4fef3ebee8788b45c063e96d50346 Author: Christian Lohmaier <cl...@documentfoundation.org> AuthorDate: Sun Dec 18 22:16:22 2022 +0100 Commit: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> CommitDate: Sun Dec 18 21:54:47 2022 +0000 janitorial cleanup/minor optimizations mostly making xstlproc and python order-only dependencies, simplifying some of the print statements/remove sed or grep calls that can be handled by make's own text functions Change-Id: If4f8ef145d7721384e914ae79494c500bbf244dc Reviewed-on: https://gerrit.libreoffice.org/c/help/+/144410 Tested-by: Jenkins Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> diff --git a/CustomTarget_html.mk b/CustomTarget_html.mk index 72576b04b1..3edcd1df80 100644 --- a/CustomTarget_html.mk +++ b/CustomTarget_html.mk @@ -43,10 +43,10 @@ $(eval $(call gb_CustomTarget_register_targets,helpcontent2/help3xsl,\ # trailing space for Windows so that xargs doesn't interpret the final CR (that # win-make adds as the newline character) as part of the last filename $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/hid2file.js : \ - $(SRCDIR)/helpcontent2/help3xsl/generate_hid2file.xsl \ - $(call gb_ExternalExecutable_get_dependencies,xsltproc) \ - $(foreach module,$(html_TEXT_MODULES),$(call gb_AllLangHelp_get_helpfiles_target,$(module))) \ - $(SRCDIR)/helpcontent2/CustomTarget_html.mk + $(SRCDIR)/helpcontent2/help3xsl/generate_hid2file.xsl \ + $(foreach module,$(html_TEXT_MODULES),$(call gb_AllLangHelp_get_helpfiles_target,$(module))) \ + $(SRCDIR)/helpcontent2/CustomTarget_html.mk \ + | $(call gb_ExternalExecutable_get_dependencies,xsltproc) $(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),XSL,1) ( \ RESPONSEFILE=$(call gb_var2file,$(shell $(gb_MKTEMP)),$(subst helpcontent2/source/text/,,$(gb_html_allhelpfiles)$(if $(filter WNT,$(OS)), ))) && \ @@ -69,9 +69,9 @@ endef $(eval $(foreach lang,$(gb_HELP_LANGS),$(call html_gen_xaptpl_dep,$(lang)))) $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/%/xap_tpl : \ - $(SRCDIR)/helpcontent2/help3xsl/xap_templ_query.xsl \ - $(call gb_ExternalExecutable_get_dependencies,xsltproc) \ - $(SRCDIR)/helpcontent2/CustomTarget_html.mk + $(SRCDIR)/helpcontent2/help3xsl/xap_templ_query.xsl \ + $(SRCDIR)/helpcontent2/CustomTarget_html.mk \ + | $(call gb_ExternalExecutable_get_dependencies,xsltproc) $(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),XAT,1) $(call gb_Helper_abbreviate_dirs,\ $(call gb_ExternalExecutable_get_command,xsltproc) \ @@ -96,10 +96,10 @@ endef $(eval $(foreach lang,$(gb_HELP_LANGS),$(call html_gen_noscript_dep,$(lang)))) $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/%/noscript.html : \ - $(SRCDIR)/helpcontent2/help3xsl/noscript.xsl \ - $(SRCDIR)/helpcontent2/help3xsl/brand.xsl \ - $(call gb_ExternalExecutable_get_dependencies,xsltproc) \ - $(SRCDIR)/helpcontent2/CustomTarget_html.mk + $(SRCDIR)/helpcontent2/help3xsl/noscript.xsl \ + $(SRCDIR)/helpcontent2/help3xsl/brand.xsl \ + $(SRCDIR)/helpcontent2/CustomTarget_html.mk \ + | $(call gb_ExternalExecutable_get_dependencies,xsltproc) \ $(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),NJS,1) $(call gb_Helper_abbreviate_dirs,\ $(call gb_ExternalExecutable_get_command,xsltproc) \ @@ -114,12 +114,8 @@ $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/%/noscript.html : \ # set of installed languages - has to be language independent $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/languages.js : \ - $(SRCDIR)/helpcontent2/CustomTarget_html.mk - ( \ - printf 'var languagesSet = new Set([' ; \ - for lang in $(gb_HELP_LANGS) ; do printf '%s' "'$$lang', " ; done | sed 's/, $$//' ; \ - printf ']);\n' \ - ) > $@ + $(SRCDIR)/helpcontent2/CustomTarget_html.mk + printf 'var languagesSet = new Set([%s]);\n' "$(subst $(WHITESPACE),$(COMMA) ,$(patsubst %,'%',$(gb_HELP_LANGS)))" > $@ define html_gen_langnames_js_dep $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/$(1)/langnames.js : \ @@ -131,11 +127,10 @@ $(eval $(foreach lang,$(gb_HELP_LANGS),$(call html_gen_langnames_js_dep,$(lang)) # names of the languages - has to be translated, ie. per language $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/%/langnames.js : \ - $(SRCDIR)/helpcontent2/CustomTarget_html.mk + $(SRCDIR)/helpcontent2/CustomTarget_html.mk ( \ echo 'var languageNames = {' ; \ - grep '<paragraph[^>]*id="lang_' $(if $(filter en-US,$*),$(SRCDIR),$(call gb_HelpTranslatePartTarget_get_workdir,$*))/helpcontent2/source/text/shared/help/browserhelp.xhp | \ - sed -e 's/^.*<variable id="\([^"]*\)"[^>]*>\([^<]*\)<.*$$/"\1": "\2",/' ; \ + sed -n -e 's/^.*<paragraph[^>]* id="lang_.*<variable id="\([^"]*\)"[^>]*>\([^<]*\)<.*$$/"\1": "\2",/p' $(filter %/browserhelp.xhp,$^) ; \ echo '};' \ ) > $@ @@ -168,9 +163,9 @@ $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/%/contents.js : ) $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/%/contents.part : \ - $(SRCDIR)/helpcontent2/help3xsl/get_tree.xsl \ - $(SRCDIR)/helpcontent2/help3xsl/brand.xsl \ - $(call gb_ExternalExecutable_get_dependencies,xsltproc) + $(SRCDIR)/helpcontent2/help3xsl/get_tree.xsl \ + $(SRCDIR)/helpcontent2/help3xsl/brand.xsl \ + | $(call gb_ExternalExecutable_get_dependencies,xsltproc) $(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),XSL,1) $(call gb_Helper_abbreviate_dirs,\ $(call gb_ExternalExecutable_get_command,xsltproc) \ @@ -186,20 +181,20 @@ $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/%/contents.part : \ # link txt file for icon replacement table - tdf#128519 # copy online_transform.xsl to workdir and build links.txt.xsl -$(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl/online_transform.xsl) : \ +$(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/online_transform.xsl : \ $(SRCDIR)/helpcontent2/help3xsl/online_transform.xsl cp $(SRCDIR)/helpcontent2/help3xsl/online_transform.xsl $@ -$(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl/links.txt.xsl) : \ - $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl/online_transform.xsl) \ - $(SRCDIR)/icon-themes/colibre/links.txt \ - $(SRCDIR)/helpcontent2/helpers/make_icon_link.txt.py \ - $(call gb_ExternalExecutable_get_dependencies,python) +$(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/links.txt.xsl : \ + $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/online_transform.xsl \ + $(SRCDIR)/icon-themes/colibre/links.txt \ + $(SRCDIR)/helpcontent2/helpers/make_icon_link.txt.py \ + | $(call gb_ExternalExecutable_get_dependencies,python) $(call gb_ExternalExecutable_get_command,python) $(SRCDIR)/helpcontent2/helpers/make_icon_link.txt.py $(SRCDIR)/icon-themes/colibre/links.txt $@ define html_gen_html_dep $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/$(1)/html.text : \ - $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl/links.txt.xsl) \ + $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/links.txt.xsl \ $(foreach module,$(html_TEXT_MODULES), \ $(if $(filter en-US,$(1)), \ $(call gb_AllLangHelp_get_helpfiles_target,$(module)), \ @@ -210,8 +205,8 @@ endef $(eval $(foreach lang,$(gb_HELP_LANGS),$(call html_gen_html_dep,$(lang)))) $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/%/html.text : \ - $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl/links.txt.xsl) \ - $(call gb_ExternalExecutable_get_dependencies,xsltproc) + $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/links.txt.xsl \ + | $(call gb_ExternalExecutable_get_dependencies,xsltproc) $(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),XSL,1) rm -rf $(dir $@)text && mkdir -p $(dir $@)text && cd $(dir $@)text && mkdir -p $(sort $(subst helpcontent2/source/text/,,$(dir $(gb_html_allhelpfiles)))) \ && cd $(if $(filter en-US,$*),$(SRCDIR),$(call gb_HelpTranslatePartTarget_get_workdir,$*)) \ @@ -225,7 +220,7 @@ $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/%/html.text : \ --stringparam productversion "$(PRODUCTVERSION)" \ --stringparam xapian $(if $(filter TRUE, $(HELP_OMINDEX_PAGE)),'yes','no') \ -o $(dir $@)$${xhp%.xhp}.html \ - $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl/online_transform.xsl) \ + $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/online_transform.xsl \ helpcontent2/source/$$xhp \ || exit \ ; done <"$$RESPONSEFILE" \ @@ -265,10 +260,7 @@ $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/$(1)/%/bookmarks.part endef -define html_gen_bookmarks_deps -$(call html__gen_bookmarks_deps,$(firstword $(1)),$(lastword $(1))) - -endef +html_gen_bookmarks_deps = $(call html__gen_bookmarks_deps,$(firstword $(1)),$(lastword $(1))) $(eval $(foreach module,$(html_BMARK_MODULES),$(call html_gen_bookmarks_deps,$(subst :, ,$(module))))) commit 6a83788dd6205cd600327ead7388bc5ad26fc7f7 Author: Christian Lohmaier <cl...@documentfoundation.org> AuthorDate: Sun Dec 18 22:03:35 2022 +0100 Commit: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> CommitDate: Sun Dec 18 21:54:39 2022 +0000 process files for bookmarks.part in bulk instead of running xsltproc for each file, pass multiple files at once, greatly reducing the overhead of the processing, especially on Windows/cygwin. since it not only removes the need for the xsltproc invocations, but also for the surrounding workarounds with the rm, touch, rm of the indicator file. Change-Id: I4588bfc869c668a41da29b5d4080a600ed02223b Reviewed-on: https://gerrit.libreoffice.org/c/help/+/144409 Tested-by: Jenkins Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> diff --git a/CustomTarget_html.mk b/CustomTarget_html.mk index f3ff31ca9e..72576b04b1 100644 --- a/CustomTarget_html.mk +++ b/CustomTarget_html.mk @@ -276,31 +276,22 @@ $(eval $(foreach module,$(html_BMARK_MODULES),$(call html_gen_bookmarks_deps,$(s # (similar to Bash's `set -o pipefail`; the final `rm $@.good` will fail, and fail the whole # command, if any xsltproc invocation failed): $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/%/bookmarks.part : \ - $(SRCDIR)/helpcontent2/help3xsl/get_bookmark.xsl \ - $(SRCDIR)/helpcontent2/help3xsl/brand.xsl \ - $(call gb_ExternalExecutable_get_dependencies,xsltproc) + $(SRCDIR)/helpcontent2/help3xsl/get_bookmark.xsl \ + $(SRCDIR)/helpcontent2/help3xsl/brand.xsl \ + | $(call gb_ExternalExecutable_get_dependencies,xsltproc) $(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),XSL,1) - $(call gb_Helper_abbreviate_dirs,\ - RESPONSEFILE=$(call gb_var2file,$(shell $(gb_MKTEMP)),$(addprefix $(if $(filter en-US,$(HELP_LANG)),$(SRCDIR),$(call gb_HelpTranslatePartTarget_get_workdir,$(HELP_LANG)))/,$(gb_AllLangHelp_$(APPDIR)_BOOKMARK_HELPFILES))) \ - && ( \ - <"$$RESPONSEFILE" $(if $(filter WNT,$(OS)),tr -d '\r' | env -i PATH="$$PATH") xargs -n 1 printf '%s\n' \ - | { rm -f $@.good && while read xhp; do \ - $(call gb_ExternalExecutable_get_command,xsltproc) \ - --stringparam app $(APP) \ - --stringparam Language $(HELP_LANG) \ - --stringparam local $(if $(HELP_ONLINE),'no','yes') \ - --stringparam productname "$(gb_PRODUCTNAME_HTML)" \ - --stringparam productversion "$(PRODUCTVERSION)" \ - $(SRCDIR)/helpcontent2/help3xsl/get_bookmark.xsl \ - $$xhp \ - || exit \ - ; done && touch $@.good; } \ - | sort -k3b -s \ - | awk 'NF' \ - && rm $@.good \ - ) > $@ \ - && rm "$$RESPONSEFILE" \ - ) + RESPONSEFILE=$(call gb_var2file,$(shell $(gb_MKTEMP)),$(subst helpcontent2/source/text/,,$(gb_AllLangHelp_$(APPDIR)_BOOKMARK_HELPFILES))$(if $(filter WNT,$(OS)), )) \ + && cd $(if $(filter en-US,$(HELP_LANG)),$(SRCDIR),$(call gb_HelpTranslatePartTarget_get_workdir,$(HELP_LANG)))/helpcontent2/source/text \ + && ( \ + $(call gb_ExternalExecutable_get_command,xsltproc,xargs) \ + --stringparam app $(APP) \ + --stringparam Language $(HELP_LANG) \ + --stringparam local $(if $(HELP_ONLINE),'no','yes') \ + --stringparam productname "$(gb_PRODUCTNAME_HTML)" \ + --stringparam productversion "$(PRODUCTVERSION)" \ + $(SRCDIR)/helpcontent2/help3xsl/get_bookmark.xsl \ + <$$RESPONSEFILE || { rm $$RESPONSEFILE; exit 1; } \ + ) | sort -k3b -s >$@ && rm "$$RESPONSEFILE" # The various gid_File_Help_*_Zip in scp2 that use EXTRA_ALL_GOOD_HELP_LOCALIZATIONS_LANG expect # $(module)/$(lang).filelist files containing lists of files (in instdir) for the corresponding