This commit is contained in:
parent
22ead941c7
commit
9537759d6a
@ -41,7 +41,6 @@ if [ -z "$inc_arguments" ]; then
|
||||
build_xmlstream)
|
||||
command="$1$command"
|
||||
[ "$#" -gt 0 ] && shift 1 && workfile="$1"
|
||||
[ "$#" -gt 0 ] && shift 1 && olang="$1"
|
||||
;;
|
||||
tree_maker)
|
||||
command="$1$command"
|
||||
@ -52,7 +51,6 @@ if [ -z "$inc_arguments" ]; then
|
||||
command="$1$command"
|
||||
[ "$#" -gt 0 ] && shift 1 && workfile="$1"
|
||||
[ "$#" -gt 0 ] && shift 1 && processor="$1"
|
||||
[ "$#" -gt 0 ] && shift 1 && olang="$1"
|
||||
;;
|
||||
sourceglobs)
|
||||
command="$1$command"
|
||||
@ -80,7 +78,6 @@ if [ -z "$inc_arguments" ]; then
|
||||
[ "$#" -gt 0 ] && shift 1
|
||||
done
|
||||
|
||||
olang="${olang:-en}"
|
||||
tree="${tree:-$basedir}"
|
||||
stagedir="${stagedir:-$target}"
|
||||
today="${today:-$(date +%F)}"
|
||||
|
@ -66,8 +66,8 @@ case "$command" in
|
||||
svn_build_into
|
||||
fi ;;
|
||||
build_into) build_into ;;
|
||||
process_file) process_file "$workfile" "$processor" "$olang" ;;
|
||||
build_xmlstream) build_xmlstream "$(get_shortname "$workfile")" "$(get_language "$workfile")" "$olang" ;;
|
||||
process_file) process_file "$workfile" "$processor" ;;
|
||||
build_xmlstream) build_xmlstream "$(get_shortname "$workfile")" "$(get_language "$workfile")" ;;
|
||||
tree_maker) tree_maker "$tree" "$target" ;;
|
||||
sourceglobs) sourceglobs "$sourcesfile" ;;
|
||||
lang_sources) lang_sources "$sourceglobfile" "$lang" ;;
|
||||
|
@ -49,15 +49,6 @@ xhtml_maker(){
|
||||
[ -f "$shortname".rss.xsl ] && bool_rss=true || bool_rss=false
|
||||
[ -f "$shortname".ics.xsl ] && bool_ics=true || bool_ics=false
|
||||
|
||||
olang="$(echo "${shortname}".[a-z][a-z].xhtml "${shortname}".[e]n.xhtml |sed -rn 's;^.*\.([a-z]{2})\.xhtml.*$;\1;p')"
|
||||
|
||||
if [ "${shortbase}" = "${filedir##*/}" ] && \
|
||||
[ ! -f "${filedir}/index.${olang}.xhtml" ]; then
|
||||
bool_indexname=true
|
||||
else
|
||||
bool_indexname=false
|
||||
fi
|
||||
|
||||
[ -f "${shortname}.sources" ] && sourcesfile="${shortname}.sources" || unset sourcesfile
|
||||
|
||||
# For speed considerations: avoid all disk I/O in this loop
|
||||
@ -68,37 +59,14 @@ xhtml_maker(){
|
||||
infile="$(mio "$infile")"
|
||||
outbase="${shortbase}.${lang}.html"
|
||||
outfile="${outpath}/${outbase}"
|
||||
outlink="${outpath}/${shortbase}.html.$lang"
|
||||
rssfile="${outpath}/${shortbase}.${lang}.rss"
|
||||
icsfile="${outpath}/${shortbase}.${lang}.ics"
|
||||
|
||||
textsfile="$(get_textsfile "$lang")"
|
||||
fundraisingfile="$(get_fundraisingfile "$lang")"
|
||||
# $bool_sourceinc && sourceglobs="${filedir#./}/._._${shortbase}.${lang}.refglobs" || unset sourceglobs
|
||||
|
||||
cat <<MakeEND
|
||||
all: $(mes "$outfile" "$outlink")
|
||||
all: $(mes "$outfile")
|
||||
$(mes "$outfile"): $(mes "$depfile" "$processor" "$textsen" "$textsfile" "$fundraisingfile" "$menufile" "$sourcesfile")
|
||||
\${PROCESSOR} \${PROCFLAGS} process_file "${infile}" "$(mio "$processor")" "$olang" >"$outfile" || { rm $outfile; exit 1; }
|
||||
$(mes "$outlink"):
|
||||
ln -sf "${outbase}" "${outlink}"
|
||||
MakeEND
|
||||
$bool_rss && cat<<MakeEND
|
||||
all: $(mes "$rssfile")
|
||||
$(mes "$rssfile"): $(mes "$depfile" "${shortname}.rss.xsl" "$textsen" "$textsfile" "$fundraisingfile" "$menufile" "$sourcesfile")
|
||||
\${PROCESSOR} \${PROCFLAGS} process_file "${infile}" "$(mio "${shortname}.rss.xsl")" "$olang" >"$rssfile" || { rm $rssfile; exit 1; }
|
||||
MakeEND
|
||||
$bool_ics && cat<<MakeEND
|
||||
all: $(mes "$icsfile")
|
||||
$(mes "$icsfile"): $(mes "$depfile" "${shortname}.ics.xsl" "$textsen" "$textsfile" "$fundraisingfile" "$menufile" "$sourcesfile")
|
||||
\${PROCESSOR} \${PROCFLAGS} process_file "${infile}" "$(mio "${shortname}.ics.xsl")" "$olang" >"$icsfile" || { rm $icsfile; exit 1; }
|
||||
MakeEND
|
||||
$bool_indexname && cat <<MakeEND
|
||||
all: $(mes "$outpath/index.${lang}.html" "$outpath/index.html.$lang")
|
||||
$(mes "$outpath/index.${lang}.html"):
|
||||
ln -sf "$outbase" "$outpath/index.${lang}.html"
|
||||
$(mes "$outpath/index.html.$lang"):
|
||||
ln -sf "$outbase" "$outpath/index.html.$lang"
|
||||
\${PROCESSOR} \${PROCFLAGS} process_file "${infile}" "$(mio "$processor")" >"$outfile" || { rm $outfile; exit 1; }
|
||||
MakeEND
|
||||
done
|
||||
}
|
||||
@ -123,37 +91,6 @@ xhtml_additions(){
|
||||
done
|
||||
}
|
||||
|
||||
copy_maker(){
|
||||
# generate make rule for copying a plain file
|
||||
infile="\${INPUTDIR}/$1"
|
||||
outfile="\${OUTPUTDIR}/$2"
|
||||
|
||||
cat <<MakeEND
|
||||
all: $(mes "$outfile")
|
||||
$(mes "$outfile"): $(mes "$infile")
|
||||
cp "$infile" "$outfile"
|
||||
MakeEND
|
||||
}
|
||||
|
||||
copy_makers(){
|
||||
# generate copy rules for entire input tree
|
||||
sourcefind \! -name 'Makefile' \! -name '*.sourceglobs' \! -name '*.refglobs' \
|
||||
\! -name '*.sources' \! -name '*.xhtml' \! -name '*.xml' \
|
||||
\! -name '*.xsl' \! -name 'tagmap' \! -name '*.langglob' \
|
||||
| while read filepath; do
|
||||
copy_maker "$filepath" "$filepath"
|
||||
done
|
||||
}
|
||||
|
||||
copy_additions(){
|
||||
printf "%s\n" "$@" \
|
||||
| egrep -v '.+(\.sources|\.sourceglobs|\.refglobs|\.xhtml|\.xml|\.xsl|/Makefile|/)$' \
|
||||
| xargs realpath \
|
||||
| while read addition; do
|
||||
copy_maker "${addition#$input/}" "${addition#$input/}"
|
||||
done
|
||||
}
|
||||
|
||||
xslt_dependencies(){
|
||||
# list referenced xsl files for a given xsl file
|
||||
# *not* recursive since Make will handle recursive
|
||||
@ -197,34 +134,19 @@ xslt_additions(){
|
||||
done
|
||||
}
|
||||
|
||||
copy_sources(){
|
||||
# generate rules to copy all .xhtml files in the input to
|
||||
# the public source directory
|
||||
sourcefind -name '*.xhtml' \
|
||||
| while read filepath; do
|
||||
copy_maker "$filepath" "source/$filepath"
|
||||
done
|
||||
}
|
||||
|
||||
copy_sourceadditions(){
|
||||
printf "%s\n" "$@" \
|
||||
| egrep '.+\.xhtml$' \
|
||||
| xargs realpath \
|
||||
| while read addition; do
|
||||
copy_maker "${addition#$input/}" "source/${addition#$input/}"
|
||||
done
|
||||
}
|
||||
|
||||
tree_maker(){
|
||||
# walk through file tree and issue Make rules according to file type
|
||||
input="$(realpath "$1")"
|
||||
output="$(realpath "$2")"
|
||||
shift 2
|
||||
|
||||
# List of languages in a single line, separated by blanks
|
||||
languages=$(echo $(get_languages))
|
||||
|
||||
cache_textsfile
|
||||
cache_fundraising
|
||||
|
||||
cat <<MakeHead
|
||||
cat <<EOF
|
||||
.PHONY: all
|
||||
.DELETE_ON_ERROR:
|
||||
PROCESSOR = "$basedir/build/process_file.sh"
|
||||
@ -232,7 +154,7 @@ PROCFLAGS = --source "$basedir" --statusdir "$statusdir" --domain "$domain"
|
||||
INPUTDIR = $input
|
||||
OUTPUTDIR = $output
|
||||
STATUSDIR = $statusdir
|
||||
LANGUAGES = $(echo $(get_languages))
|
||||
LANGUAGES = $languages
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Build .html files from .xhtml sources
|
||||
@ -254,13 +176,6 @@ HTML_DST_BASES := \$(patsubst \$(INPUTDIR)/%,\$(OUTPUTDIR)/%,\$(HTML_SRC_BASES))
|
||||
# List of .<lang>.html files to build
|
||||
HTML_DST_FILES := \$(foreach base,\$(HTML_DST_BASES),\$(foreach lang,\$(LANGUAGES),\$(base).\$(lang).html))
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Create symlinks from file.<lang>.html to file.html.<lang>
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# List of .html.<lang> symlinks to create
|
||||
HTML_DST_LINKS := \$(foreach base,\$(HTML_DST_BASES),\$(foreach lang,\$(LANGUAGES),\$(base).html.\$(lang)))
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Create index.* symlinks
|
||||
# -----------------------------------------------------------------------------
|
||||
@ -283,6 +198,39 @@ INDEX_DST_DIRS := \$(patsubst \$(INPUTDIR)/%,\$(OUTPUTDIR)/%,\$(INDEX_SRC_DIRS))
|
||||
# List of index.<lang>.html and index.html.<lang> symlinks to create
|
||||
INDEX_DST_LINKS := \$(foreach base,\$(INDEX_DST_DIRS),\$(foreach lang,\$(LANGUAGES),\$(base)index.\$(lang).html \$(base)index.html.\$(lang)))
|
||||
|
||||
all: \$(INDEX_DST_LINKS)
|
||||
EOF
|
||||
|
||||
for lang in ${languages}; do
|
||||
cat<<EOF
|
||||
\$(OUTPUTDIR)/%/index.${lang}.html:
|
||||
@echo "* Creating symlink \$*/index.${lang}.html"
|
||||
@ln -sf \$(notdir \$*).${lang}.html \$@
|
||||
EOF
|
||||
done
|
||||
|
||||
cat <<EOF
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Create symlinks from file.<lang>.html to file.html.<lang>
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# List of .html.<lang> symlinks to create
|
||||
HTML_DST_LINKS := \$(foreach base,\$(HTML_DST_BASES) \$(addsuffix index,\$(INDEX_DST_DIRS)),\$(foreach lang,\$(LANGUAGES),\$(base).html.\$(lang)))
|
||||
|
||||
all: \$(HTML_DST_LINKS)
|
||||
EOF
|
||||
|
||||
for lang in ${languages}; do
|
||||
cat<<EOF
|
||||
\$(OUTPUTDIR)/%.html.${lang}:
|
||||
@echo "* Creating symlink \$*.html.${lang}"
|
||||
@ln -sf \$(notdir \$*).${lang}.html \$@
|
||||
EOF
|
||||
done
|
||||
|
||||
cat <<EOF
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Build .rss files from .xhtml sources
|
||||
# -----------------------------------------------------------------------------
|
||||
@ -299,6 +247,19 @@ RSS_DST_BASES := \$(patsubst \$(INPUTDIR)/%,\$(OUTPUTDIR)/%,\$(RSS_SRC_BASES))
|
||||
# List of .<lang>.rss files to build
|
||||
RSS_DST_FILES := \$(foreach base,\$(RSS_DST_BASES),\$(foreach lang,\$(LANGUAGES),\$(base).\$(lang).rss))
|
||||
|
||||
all: \$(RSS_DST_FILES)
|
||||
EOF
|
||||
|
||||
for lang in ${languages}; do
|
||||
cat<<EOF
|
||||
\$(OUTPUTDIR)/%.${lang}.rss: \$(INPUTDIR)/%.*.xhtml \$(INPUTDIR)/%.sources \$(INPUTDIR)/%.rss.xsl \$(INPUTDIR)/tools/menu-global.xml $(get_textsfile "en") $(get_fundraisingfile "${lang}")
|
||||
@echo "* Building \$*.${lang}.rss"
|
||||
@\${PROCESSOR} \${PROCFLAGS} process_file \$(INPUTDIR)/%.${lang}.xhtml \$(INPUTDIR)/%.rss.xsl > \$@
|
||||
EOF
|
||||
done
|
||||
|
||||
cat <<EOF
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Build .ics files from .xhtml sources
|
||||
# -----------------------------------------------------------------------------
|
||||
@ -315,6 +276,19 @@ ICS_DST_BASES := \$(patsubst \$(INPUTDIR)/%,\$(OUTPUTDIR)/%,\$(ICS_SRC_BASES))
|
||||
# List of .<lang>.ics files to build
|
||||
ICS_DST_FILES := \$(foreach base,\$(ICS_DST_BASES),\$(foreach lang,\$(LANGUAGES),\$(base).\$(lang).ics))
|
||||
|
||||
all: \$(ICS_DST_FILES)
|
||||
EOF
|
||||
|
||||
for lang in ${languages}; do
|
||||
cat<<EOF
|
||||
\$(OUTPUTDIR)/%.${lang}.ics: \$(INPUTDIR)/%.*.xhtml \$(INPUTDIR)/%.sources \$(INPUTDIR)/%.ics.xsl \$(INPUTDIR)/tools/menu-global.xml $(get_textsfile "en") $(get_fundraisingfile "${lang}")
|
||||
@echo "* Building \$*.${lang}.ics"
|
||||
@\${PROCESSOR} \${PROCFLAGS} process_file \$(INPUTDIR)/%.${lang}.xhtml \$(INPUTDIR)/%.ics.xsl > \$@
|
||||
EOF
|
||||
done
|
||||
|
||||
cat <<EOF
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Copy images, docments etc
|
||||
# -----------------------------------------------------------------------------
|
||||
@ -325,40 +299,46 @@ COPY_SRC_FILES := \$(shell find \$(INPUTDIR) -type f -not -path '\$(INPUTDIR)/.g
|
||||
# The same as above, but moved to the output directory
|
||||
COPY_DST_FILES := \$(patsubst \$(INPUTDIR)/%,\$(OUTPUTDIR)/%,\$(COPY_SRC_FILES))
|
||||
|
||||
all: \$(COPY_DST_FILES)
|
||||
\$(COPY_DST_FILEST): \$(OUTPUTDIR)/%: \$(INPUTDIR)/%
|
||||
@echo "* Copying file \$*"
|
||||
@cp \$< \$@
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Copy .xhtml files to "source" directory in target directory tree
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
SOURCE_DST_FILES := \$(patsubst \$(INPUTDIR)/%,\$(OUTPUTDIR)/source/%,\$(HTML_SRC_FILES))
|
||||
|
||||
all: \$(SOURCE_DST_FILES)
|
||||
\$(SOURCE_DST_FILES): \$(OUTPUTDIR)/source/%: \$(INPUTDIR)/%
|
||||
@echo "* Copying source \$*"
|
||||
cp \$< \$@
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Clean up excess files in target directory
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
ALL_DST := \$(HTML_DST_FILES) \$(HTML_DST_LINKS) \$(INDEX_DST_LINKS) \$(RSS_DST_FILES) \$(ICS_DST_FILES) \$(COPY_DST_FILES) \$(SOURCE_DST_FILES)
|
||||
ALL_DST := \$(HTML_DST_FILES) \$(INDEX_DST_LINKS) \$(HTML_DST_LINKS) \$(RSS_DST_FILES) \$(ICS_DST_FILES) \$(COPY_DST_FILES) \$(SOURCE_DST_FILES)
|
||||
|
||||
.PHONY: clean
|
||||
all: clean
|
||||
clean:
|
||||
@echo "Cleaning up excess files"
|
||||
@# Write all destination filenames into "manifest" file, one per line
|
||||
\$(file >manifest)
|
||||
\$(file >\$(STATUSDIR)/manifest)
|
||||
\$(foreach filename,\$(ALL_DST),\$(file >>\$(STATUSDIR)/manifest,\$(filename)))
|
||||
@sort \$(STATUSDIR)/manifest > \$(STATUSDIR)/manifest.sorted
|
||||
@find -L \$(OUTPUTDIR) -type f \\
|
||||
| sort \\
|
||||
| diff - \$(STATUSDIR)/manifest.sorted \\
|
||||
| diff - \$(STATUSDIR)/manifest.sorted \\
|
||||
| sed -rn 's;^< ;;p' \\
|
||||
| while read file; do echo "* Deleting \$\${file}"; rm "\$\${file}"; done
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
MakeHead
|
||||
EOF
|
||||
|
||||
forcelog Make_globs; Make_globs="$(logname Make_globs)"
|
||||
forcelog Make_xslt; Make_xslt="$(logname Make_xslt)"
|
||||
forcelog Make_copy; Make_copy="$(logname Make_copy)"
|
||||
forcelog Make_sourcecopy; Make_sourcecopy="$(logname Make_sourcecopy)"
|
||||
Make_xhtml="$(logname Make_xhtml)"
|
||||
|
||||
trap "trap - 0 2 3 6 9 15; killall \"${0##*/}\"" 0 2 3 6 9 15
|
||||
@ -366,12 +346,6 @@ MakeHead
|
||||
[ "$regen_xslt" = false -a -s "$Make_xslt" ] && \
|
||||
xslt_additions "$@" >>"$Make_xslt" \
|
||||
|| xslt_makers >"$Make_xslt" &
|
||||
[ "$regen_copy" = false -a -s "$Make_copy" ] && \
|
||||
copy_additions "$@" >>"$Make_copy" \
|
||||
|| copy_makers >"$Make_copy" &
|
||||
[ "$regen_xhtml" = false -a -s "$Make_sourcecopy" ] && \
|
||||
copy_sourceadditions "$@" >>"$Make_sourcecopy" \
|
||||
|| copy_sources >"$Make_sourcecopy" &
|
||||
|
||||
if [ "$regen_xhtml" = false -a -s "$Make_xhtml" ]; then
|
||||
cat "$Make_xhtml"
|
||||
@ -383,6 +357,6 @@ MakeHead
|
||||
wait
|
||||
trap - 0 2 3 6 9 15
|
||||
|
||||
cat "$Make_xslt" "$Make_copy" "$Make_sourcecopy"
|
||||
cat "$Make_xslt"
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,6 @@ basedir="${0%/*}/.."
|
||||
. "$basedir/build/arguments.sh"
|
||||
|
||||
case "$command" in
|
||||
process_file) process_file "$workfile" "$processor" "$olang" ;;
|
||||
process_file) process_file "$workfile" "$processor" ;;
|
||||
*) die "Unrecognised command or no command given" ;;
|
||||
esac
|
||||
|
@ -7,7 +7,6 @@ inc_processor=true
|
||||
process_file(){
|
||||
infile="$1"
|
||||
processor="$2"
|
||||
olang="$3"
|
||||
|
||||
shortname=$(get_shortname "$infile")
|
||||
lang=$(get_language "$infile")
|
||||
@ -17,7 +16,7 @@ process_file(){
|
||||
# of the commands fails.
|
||||
set -o pipefail
|
||||
|
||||
build_xmlstream "$shortname" "$lang" "$olang" \
|
||||
build_xmlstream "$shortname" "$lang" \
|
||||
| xsltproc "$processor" - \
|
||||
| sed -r ':X; N; $!bX;
|
||||
s;<[\r\n\t ]*(a|link)([\r\n\t ][^>]*)?[\r\n\t ]href="(https?:)?//'"$domain"'/([^"]*)";<\1\2 href="/\4";gI
|
||||
|
@ -13,8 +13,8 @@ build_xmlstream(){
|
||||
# a single xhtml page to be built
|
||||
shortname="$1"
|
||||
lang="$2"
|
||||
olang="$3"
|
||||
|
||||
olang="$(echo "${shortname}".[a-z][a-z].xhtml "${shortname}".[e]n.xhtml |sed -rn 's;^.*\.([a-z]{2})\.xhtml.*$;\1;p')"
|
||||
dirname="${shortname%/*}/"
|
||||
texts_xml=$(get_textsfile $lang)
|
||||
fundraising_xml=$(get_fundraisingfile $lang)
|
||||
|
@ -41,8 +41,6 @@ t_svnupdate=$(stat -c %Y "SVNlatest" ||echo 0)
|
||||
t_gitupdate=$(stat -c %Y "GITlatest" ||echo 0)
|
||||
t_premake=$(stat -c %Y "premake" ||echo 0)
|
||||
t_makefile=$(stat -c %Y "Makefile" ||echo 0)
|
||||
t_makecopy=$(stat -c %Y "Make_copy" ||echo 0)
|
||||
t_makesourcecopy=$(stat -c %Y "Make_sourcecopy" ||echo 0)
|
||||
t_makexslt=$(stat -c %Y "Make_xslt" ||echo 0)
|
||||
t_makexhtml=$(stat -c %Y "Make_xhtml" ||echo 0)
|
||||
t_manifest=$(stat -c %Y "manifest" ||echo 0)
|
||||
@ -220,8 +218,6 @@ label {
|
||||
if [ $start_time -lt $t_makefile ]; then
|
||||
web_tab Makefiletab "Generation time: $(duration $(($t_makefile - $t_premake)) )" "
|
||||
<h3>Header</h3>$(web_tab Makeheadertab "" "<pre>$(head Makefile |htmlcat)</pre>")
|
||||
<h3>Copy rules</h3>$(web_tab Makecopytab "Generation time: $(duration $(($t_makecopy - $t_premake)))" "<pre>$(tail Make_copy |htmlcat)</pre>")
|
||||
<h3>Source copy rules</h3>$(web_tab Makescopytab "Generation time: $(duration $(($t_makesourcecopy - $t_premake)))" "<pre>$(tail Make_sourcecopy |htmlcat)</pre>")
|
||||
<h3>XSLT rules</h3>$(web_tab Makexslttab "Generation time: $(duration $(($t_makexslt - $t_premake)))" "<pre>$(tail Make_xslt |htmlcat)</pre>")
|
||||
<h3>XHTML rules</h3>$(web_tab Makexhtmltab "Generation time: $(duration $(($t_makexhtml - $t_premake)))" "<pre>$(tail Make_xhtml |htmlcat)</pre>")
|
||||
<h3>Full Makefile</h3>$(web_tab Makefilefull "<a href="Makefile">view</a>" "")"
|
||||
|
Loading…
x
Reference in New Issue
Block a user