Move XSL updates to phase 1
This commit is contained in:
parent
2568a39396
commit
798f8f1458
17
Makefile
17
Makefile
@ -113,7 +113,7 @@ default_xsl:
|
||||
done
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Generate XML filelists
|
||||
# Update XML filelists
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# After this step, the following files will be up to date:
|
||||
@ -134,3 +134,18 @@ default_xsl:
|
||||
all: xmllists
|
||||
xmllists: $(SUBDIRS)
|
||||
@tools/make_xmllists.sh
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Update XSL stylesheets
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# This step updates (actually: just touches) all XSL files which depend on
|
||||
# another XSL file that has changed since the last build run. The phase 2
|
||||
# Makefile then only has to consider the directly used stylesheet as a
|
||||
# prerequisite for building each file and doesn't have to worry about other
|
||||
# stylesheets imported into that one.
|
||||
|
||||
.PHONY: stylesheets
|
||||
all: stylesheets
|
||||
stylesheets: $(SUBDIRS)
|
||||
@tools/update_stylesheets.sh
|
||||
|
@ -24,35 +24,6 @@ OUTPUTDIR = $output
|
||||
STATUSDIR = $statusdir
|
||||
LANGUAGES = $languages
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Touch all XSL files depending on a newer other XSL file
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
EOF
|
||||
|
||||
# Generate make dependencies for all .xsl files in input tree
|
||||
find "${input}" -name '*.xsl' -not -name '.default.xsl' -printf '%P\n' \
|
||||
| while read xsl_file; do
|
||||
prerequisites=$(echo $(
|
||||
cat "${input}/${xsl_file}" \
|
||||
| tr '\n\t\r' ' ' \
|
||||
| sed -r 's;(<xsl:(include|import)[^>]*>);\n\1\n;g' \
|
||||
| sed -nr '/<xsl:(include|import)[^>]*>/s;^.*href *= *"([^"]*)".*$;\1;gp' \
|
||||
| xargs -I'{}' realpath "${input}/$(dirname ${xsl_file})/{}" \
|
||||
| sed -r "s;^${input};\$(INPUTDIR);"
|
||||
))
|
||||
if [ -n "${prerequisites}" ]; then
|
||||
echo "all: \$(INPUTDIR)/${xsl_file}"
|
||||
echo "\$(INPUTDIR)/${xsl_file}: ${prerequisites}"
|
||||
echo ""
|
||||
fi
|
||||
done
|
||||
|
||||
cat <<EOF
|
||||
%.xsl:
|
||||
@echo "* Touching \$*"
|
||||
@touch \$@
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Build .html files from .xhtml sources
|
||||
# -----------------------------------------------------------------------------
|
||||
|
56
tools/update_stylesheets.sh
Executable file
56
tools/update_stylesheets.sh
Executable file
@ -0,0 +1,56 @@
|
||||
#!/bin/bash
|
||||
# -----------------------------------------------------------------------------
|
||||
# Update XSL stylesheets (*.xsl) according to their dependency
|
||||
# -----------------------------------------------------------------------------
|
||||
# This script is called from the phase 1 Makefile and updates (actually: just
|
||||
# touches) all XSL files which depend on another XSL file that has changed
|
||||
# since the last build run. The phase 2 Makefile then only has to consider the
|
||||
# directly used stylesheet as a prerequisite for building each file and doesn't
|
||||
# have to worry about other stylesheets imported into that one.
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
echo "* Updating XSL stylesheets"
|
||||
|
||||
pid=$$
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Generate a temporary makefile with dependencies for all .xsl files
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
makefile="/tmp/makefile-${pid}"
|
||||
|
||||
{
|
||||
for xsl_file in $(find * -name '*.xsl' -not -name '.default.xsl'); do
|
||||
prerequisites=$(echo $(
|
||||
cat "${xsl_file}" \
|
||||
| tr '\t\r\n' ' ' \
|
||||
| sed -r 's/(<xsl:(include|import)[^>]*>)/\n\1\n/g' \
|
||||
| sed -rn '/<xsl:(include|import)[^>]*>/s/^.*href *= *"([^"]*)".*$/\1/gp' \
|
||||
| xargs -I'{}' realpath "$(dirname ${xsl_file})/{}" \
|
||||
))
|
||||
if [ -n "${prerequisites}" ]; then
|
||||
echo "all: ${xsl_file}"
|
||||
echo "${xsl_file}: ${prerequisites}"
|
||||
echo ""
|
||||
fi
|
||||
done
|
||||
|
||||
echo '%.xsl:'
|
||||
echo -e '\techo "* Touching $*"'
|
||||
echo -e '\ttouch $@'
|
||||
} > "${makefile}"
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Execute the temporary makefile
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
make --silent --file="${makefile}"
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Clean up
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
rm -f "${makefile}"
|
Loading…
Reference in New Issue
Block a user