Fix race in ProcessMarkdown.
--- a/make/common/ProcessMarkdown.gmk Fri Nov 23 11:32:02 2018 +0100
+++ b/make/common/ProcessMarkdown.gmk Fri Nov 23 12:19:38 2018 +0100
@@ -75,17 +75,13 @@
$1_$2_VARDEPS_FILE := $$(call DependOnVariable, $1_$2_VARDEPS, \
$$(SUPPORT_OUTPUTDIR)/markdown/$$($1_$2_MARKER).vardeps)
-$$($1_$2_OUTPUT_FILE): $$($1_$2_PANDOC_INPUT) $$($1_$2_VARDEPS_FILE) $$($1_EXTRA_DEPS)
+$$($1_$2_PANDOC_OUTPUT): $$($1_$2_PANDOC_INPUT) $$($1_$2_VARDEPS_FILE) $$($1_EXTRA_DEPS)
$$(call LogInfo, Converting $2 to $$($1_FORMAT))
- $$(call MakeDir, $$($1_$2_TARGET_DIR) $$(SUPPORT_OUTPUTDIR)/markdown)
+ $$(call MakeDir, $$(SUPPORT_OUTPUTDIR)/markdown $$(dir $$($1_$2_PANDOC_OUTPUT)))
$$(call ExecuteWithLog, $$(SUPPORT_OUTPUTDIR)/markdown/$$($1_$2_MARKER), \
$$(PANDOC) $$($1_OPTIONS) -f markdown -t $$($1_FORMAT) --standalone \
$$($1_$2_CSS_OPTION) $$($1_$2_OPTIONS) '$$($1_$2_PANDOC_INPUT)' \
-o '$$($1_$2_PANDOC_OUTPUT)')
- ifneq ($$($1_POST_PROCESS), )
- $$(call ExecuteWithLog, $$(SUPPORT_OUTPUTDIR)/markdown/$$($1_$2_MARKER)_post, \
- $$($1_POST_PROCESS) < $$($1_$2_PANDOC_OUTPUT) > $$($1_$2_OUTPUT_FILE))
- endif
ifneq ($$(findstring $$(LOG_LEVEL), debug trace),)
TOO_LONG_LINES=`$$(GREP) -E -e '^.{80}.+$$$$' $$<` || true ; \
if [ "x$$$$TOO_LONG_LINES" != x ]; then \
@@ -95,6 +91,16 @@
fi
endif
+ # If we have no post processing, PANDOC_OUTPUT is set to OUTPUT_FILE. Otherwise
+ # PANDOC_OUTPUT is a temporary file, and we must now create the real OUTPUT_FILE.
+ ifneq ($$($1_POST_PROCESS), )
+$$($1_$2_OUTPUT_FILE): $$($1_$2_PANDOC_OUTPUT)
+ $$(call LogInfo, Post-processing markdown file $2)
+ $$(call MakeDir, $$(SUPPORT_OUTPUTDIR)/markdown $$($1_$2_TARGET_DIR))
+ $$(call ExecuteWithLog, $$(SUPPORT_OUTPUTDIR)/markdown/$$($1_$2_MARKER)_post, \
+ $$($1_POST_PROCESS) < $$($1_$2_PANDOC_OUTPUT) > $$($1_$2_OUTPUT_FILE))
+ endif
+
$1 += $$($1_$2_OUTPUT_FILE)
endef