[Libreoffice-commits] help.git: Branch 'libreoffice-6-1' - CustomTarget_html.mk

Stephan Bergmann sbergman at redhat.com
Wed Jun 6 15:31:55 UTC 2018


 CustomTarget_html.mk |   30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

New commits:
commit 228048839b6df667fbe9f78bba5a1f7df5835180
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Jun 6 09:45:58 2018 +0200

    (Partially) fix --with-help=html dependencies on .xhp files
    
    There are three rules in helpcontent2/CustomTarget_html.mk that process (with
    XSLT) all or some of the .xhp files in the helpcontent2/source/text/ tree (for
    en-US; or their translations in the
    workdir/HelpTranslatePartTarget/*/helpcontent2/source/text/ trees for other
    languages).  Lists of all those .xhp files are defined in
    helpcontent2/AllLangHelp_*.mk (with gb_AllLangHelp_add_helpfiles), but the code
    in helpcontent2/CustomTarget_html.mk used `find` to assemble the relevant lists.
    
    That has two issues (at least for the en-US case operating on the untranslated
    helpcontent2/source/text/ files):  For one, if the content of those .xhp files
    changes, the relevant XSLT processing is not re-run.  For another, if .xhp files
    are added to or removed from the lists in helpcontent2/AllLangHelp_*.mk, the
    relevant XSLT processeing is not re-run, either.
    
    For the processing of translated .xhp files, there were already dependencies on
    those translated files in place.  I assume (but have not really proved it) that
    those dependencies are already sufficient to cover both of the above issues.
    That only leaves the en-US case, operating on the untranslated files.
    
    The lists of .xhp files as defined in helpcontent2/AllLangHelp_*.mk (with "*"
    ranging over the various "modules": sbasic, scalc, schart, etc.) are now made
    available in gb_AllLangHelp_*_HELPFILES variables.  The contents of those
    variables is used instead of `find` to pass the relevant .xhp files to the XSLT
    processings.  (Needing some RESPONSEFILE and `xargs -n 1` boilerplate to feed
    individual files to the XSL processing without overflowing maximum command line
    lengths.  Also, on Windows, var2file apparently writes CRLF line ends but the CR
    parts need to be filtered out again, and xargs problems must be worked around
    similar to df9edbcd2883cec2d0596133131cfbc220dee91f "Work around 'xargs:
    environment is too large for exec' errors on Windows".)
    
    However, those variables apparently cannot be used to specify dependencies for
    the three XSLT-processing rules.  Presumably, the variables do not necessarily
    have their values assigned yet by the time the rules' dependencies are
    constructed (depending on the order in which .mk files are read?).  So "dummy"
    gb_AllLangHelp_get_helpfiles_target targets are introduced, which depend on all
    the relevant .xhp files (and which get constructed during
    gb_AllLangHelp_add_helpfiles, just like the gb_AllLangHelp_*_HELPFILES
    variables), and which the XSLT-processing rules in turn depend on.  That makes
    sure that the XSLT-processing rules are re-run when the content of .xhp files
    changes or when new .xhp files are added.
    
    However, the above still fails to re-run the XSLT-processing rules when .xhp
    files are removed.
    
    This is the helpcontent2 part of a commit spanning core and helpcontent2.
    
    Change-Id: I9a72c0f6837a8e13458a703fdecf7e5b0ef2076f
    Reviewed-on: https://gerrit.libreoffice.org/55364
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
    (cherry picked from commit 5197a6b9def2e1886e3edab75517864272115089)
    Reviewed-on: https://gerrit.libreoffice.org/55380

diff --git a/CustomTarget_html.mk b/CustomTarget_html.mk
index 1cd42d9a9..0f25d8347 100644
--- a/CustomTarget_html.mk
+++ b/CustomTarget_html.mk
@@ -28,16 +28,19 @@ $(eval $(call gb_CustomTarget_register_targets,helpcontent2/help3xsl,\
 
 $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/hid2file.js : \
 		$(SRCDIR)/helpcontent2/help3xsl/get_url.xsl \
-		$(call gb_ExternalExecutable_get_dependencies,xsltproc)
+		$(call gb_ExternalExecutable_get_dependencies,xsltproc) \
+		$(foreach module,$(html_TEXT_MODULES),$(call gb_AllLangHelp_get_helpfiles_target,$(module)))
 	$(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),XSL,1)
 	$(call gb_Helper_abbreviate_dirs,\
 		( \
 			echo 'var map={' \
-			&& find $(SRCDIR)/helpcontent2/source/text -type f -name '*.xhp' \
+			&& RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),100,$(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 \
 				$(call gb_ExternalExecutable_get_command,xsltproc) $< $$xhp \
 				| $(gb_AWK) 'NF' \
 			; done \
+			&& rm "$$RESPONSEFILE" \
 			&& echo '};' \
 		) > $@ \
 	)
@@ -85,11 +88,14 @@ $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/%/contents.part : \
 
 define html_gen_html_dep
 $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/$(1)/html.text : \
-	$(foreach module,$(html_TEXT_MODULES),$(call gb_HelpTranslateTarget_get_target,$(module)/$(1)))
+	$(foreach module,$(html_TEXT_MODULES), \
+		$(if $(filter en-US,$(1)), \
+			$(call gb_AllLangHelp_get_helpfiles_target,$(module)), \
+			$(call gb_HelpTranslateTarget_get_target,$(module)/$(1))))
 
 endef
 
-$(eval $(foreach lang,$(filter-out en-US,$(gb_HELP_LANGS)),$(call html_gen_html_dep,$(lang))))
+$(eval $(foreach lang,$(gb_HELP_LANGS),$(call html_gen_html_dep,$(lang))))
 
 $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/%/html.text : \
 		$(SRCDIR)/helpcontent2/help3xsl/online_transform.xsl \
@@ -98,7 +104,8 @@ $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/%/html.text : \
 	$(call gb_Helper_abbreviate_dirs,\
 		cd $(if $(filter en-US,$*),$(SRCDIR),$(call gb_HelpTranslatePartTarget_get_workdir,$*))/helpcontent2/source \
 		&& rm -rf $(dir $@)text \
-		&& find text -name "*.xhp" \
+		&& RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),100,$(foreach module,$(html_TEXT_MODULES),$(patsubst helpcontent2/source/%,%,$(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 \
 			mkdir -p $$(dirname $(dir $@)$$xhp) && \
 			$(call gb_ExternalExecutable_get_command,xsltproc) \
@@ -110,6 +117,7 @@ $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/%/html.text : \
 				$(SRCDIR)/helpcontent2/help3xsl/online_transform.xsl \
 				$(if $(filter WNT,$(OS)),$$(cygpath -m `pwd`),`pwd`)/$$xhp \
 		; done \
+		&& rm "$$RESPONSEFILE" \
 		&& touch $@ \
 	)
 
@@ -125,14 +133,16 @@ $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/%/bookmarks.js :
 
 define html__gen_bookmarks_lang_dep
 $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/$(2)/$(1)/bookmarks.part : \
-	$(call gb_HelpTranslateTarget_get_target,$(firstword $(subst /, ,$(2)))/$(1))
+    $(if $(filter en-US,$(1)), \
+        $(call gb_AllLangHelp_get_helpfiles_target,$(firstword $(subst /, ,$(2)))), \
+        $(call gb_HelpTranslateTarget_get_target,$(firstword $(subst /, ,$(2)))/$(1)))
 
 endef
 
 define html__gen_bookmarks_lang_deps
 $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/$(1)/bookmarks.js : \
 	$(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/$(2)/$(1)/bookmarks.part
-$(if $(filter-out en-US,$(1)),$(call html__gen_bookmarks_lang_dep,$(1),$(2)))
+$(call html__gen_bookmarks_lang_dep,$(1),$(2))
 $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/$(2)/$(1)/bookmarks.part : HELP_LANG := $(1)
 
 endef
@@ -156,8 +166,9 @@ $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/%/bookmarks.part : \
 		$(call gb_ExternalExecutable_get_dependencies,xsltproc)
 	$(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),XSL,1)
 	$(call gb_Helper_abbreviate_dirs,\
-		( \
-			find $(if $(filter en-US,$(HELP_LANG)),$(SRCDIR),$(call gb_HelpTranslatePartTarget_get_workdir,$(HELP_LANG)))/helpcontent2/source/text/$(APPDIR) -name "*.xhp" \
+		RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),100,$(addprefix $(if $(filter en-US,$(HELP_LANG)),$(SRCDIR),$(call gb_HelpTranslatePartTarget_get_workdir,$(HELP_LANG)))/,$(gb_AllLangHelp_$(APPDIR)_HELPFILES))) \
+		&& ( \
+			<"$$RESPONSEFILE" $(if $(filter WNT,$(OS)),tr -d '\r' | env -i PATH="$$PATH") xargs -n 1 printf '%s\n' \
  			| while read xhp; do \
  				$(call gb_ExternalExecutable_get_command,xsltproc) \
  					--stringparam app $(APP) \
@@ -170,6 +181,7 @@ $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/%/bookmarks.part : \
 			| sort -k3b -t\> -s \
 			| awk 'NF' \
 		) > $@ \
+		&& rm "$$RESPONSEFILE" \
 	)	
 
 # The various gid_File_Help_*_Zip in scp2 that use EXTRA_ALL_GOOD_HELP_LOCALIZATIONS_LANG expect


More information about the Libreoffice-commits mailing list