introduces refglobs as "dependency guard", to prevent documents from rebuilding due to unimportant changes

svn path=/branches/test/; revision=31644
This commit is contained in:
2015-08-03 17:12:52 +00:00
parent acba823ecb
commit c7e970e296
5 changed files with 42 additions and 21 deletions
+7 -2
View File
@@ -62,11 +62,15 @@ if [ -z "$inc_arguments" ]; then
command="$1$command"
[ "$#" -gt 0 ] && shift 1 && sourcesfile="$1"
;;
cast_globfile)
lang_sources)
command="$1$command"
[ "$#" -gt 0 ] && shift 1 && sourceglobfile="$1"
[ "$#" -gt 0 ] && shift 1 && lang="$1"
;;
cast_refglobs)
command="$1$command"
[ "$#" -gt 0 ] && shift 1 && globfile="$1"
[ "$#" -gt 0 ] && shift 1 && reffile="$1"
;;
*)
print_error "Unknown option: $1"
@@ -93,7 +97,8 @@ if [ -z "$inc_arguments" ]; then
build_xmlstream) [ -z "$workfile" ] && die "Missing xhtml file name" ;;
tree_maker) [ -z "$target" ] && die "Missing target location" ;;
sourceglobs) [ -z "$sourcesfile" ] && die "Missing .sources file" ;;
cast_globfile) [ -z "$sourceglobfile" -o -z "$lang" -o -z "$globfile" ] && die "Need source globfile language and globfile" ;;
lang_sources) [ -z "$sourceglobfile" -o -z "$lang" ] && die "Need source globfile and language" ;;
cast_refglobs) [ -z "$globfile" -o -z "$reffile" ] && die "Need globfile and reffile" ;;
map_tags) true;;
*help*) print_help; exit 0 ;;
*) die "Urecognised command or no command given" ;;
+2 -1
View File
@@ -40,5 +40,6 @@ case "$command" in
build_xmlstream) build_xmlstream "$(get_shortname "$workfile")" "$(get_language "$workfile")" "$olang" ;;
tree_maker) tree_maker "$tree" "$target" ;;
sourceglobs) sourceglobs "$sourcesfile" ;;
cast_globfile) cast_globfile "$sourceglobfile" "$lang" "$globfile" ;;
lang_sources) lang_sources "$sourceglobfile" "$lang" ;;
cast_refglobs) cast_refglobs "$globfile" "$reffile" ;;
esac
+9 -5
View File
@@ -47,9 +47,12 @@ MakeEND
for lang in $(get_languages); do
globfile="${filedir%/.}/._._${shortbase}.${lang}.sourceglobs"
refglobs="${filedir%/.}/._._${shortbase}.${lang}.refglobs"
cat <<MakeEND
$(mes "$globfile"): $(mes "$sourceglobfile")
\${PGLOBBER} \${PROCFLAGS} cast_globfile "$sourceglobfile" "$lang" "$globfile"
\${PGLOBBER} \${PROCFLAGS} lang_sources "$sourceglobfile" "$lang" >"$globfile"
$(mes "$refglobs"): $(mes "$globfile")
\${PGLOBBER} \${PROCFLAGS} cast_refglobs "$globfile" "$refglobs"
MakeEND
done
}
@@ -114,7 +117,7 @@ xhtml_maker(){
textsfile="$(get_textsfile "$lang")"
fundraisingfile="$(get_fundraisingfile "$lang")"
$bool_sourceinc && sourceglobs="${filedir#./}/._._${shortbase}.${lang}.sourceglobs" || unset sourceglobs
$bool_sourceinc && sourceglobs="${filedir#./}/._._${shortbase}.${lang}.refglobs" || unset sourceglobs
cat <<MakeEND
all: $(mes "$outfile" "$outlink")
@@ -179,8 +182,9 @@ MakeEND
copy_makers(){
# generate copy rules for entire input tree
sourcefind \! -name 'Makefile' \! -name '*.sourceglobs' \! -name '*.sources' \
\! -name '*.xhtml' \! -name '*.xml' \! -name '*.xsl' \! -name 'tagmap' \
sourcefind \! -name 'Makefile' \! -name '*.sourceglobs' \! -name '*.refglobs' \
\! -name '*.sources' \! -name '*.xhtml' \! -name '*.xml' \
\! -name '*.xsl' \! -name 'tagmap' \
| while read filepath; do
copy_maker "$filepath" "$(dirname "$filepath")"
done
@@ -188,7 +192,7 @@ copy_makers(){
copy_additions(){
printf "%s\n" "$@" \
| egrep -v '.+(\.sources|\.sourceglobs|\.xhtml|\.xml|\.xsl|/Makefile|/)$' \
| egrep -v '.+(\.sources|\.sourceglobs|\.refglobs|\.xhtml|\.xml|\.xsl|/Makefile|/)$' \
| xargs realpath \
| while read addition; do
copy_maker "${addition#$input/}" "$(dirname "${addition#$input/}")"
+2 -1
View File
@@ -8,6 +8,7 @@ basedir="$(dirname $0)/.."
case "$command" in
map_tags) map_tags "$@";;
sourceglobs) sourceglobs "$sourcesfile" ;;
cast_globfile) cast_globfile "$sourceglobfile" "$lang" "$globfile" ;;
lang_sources) lang_sources "$sourceglobfile" "$lang" ;;
cast_refglobs) cast_refglobs "$globfile" "$reffile" ;;
*) die "Urecognised command or no command given" ;;
esac
+22 -12
View File
@@ -46,6 +46,7 @@ tagging_sourceglobs(){
for tag in $tags ; do
matchline="/ $tag( |$)/{${matchline}}"
done
printf '%s\n' "$matchline"
if [ -z "$tags" ]; then
# save the i/o if tags are empty, i.e. always match
@@ -125,20 +126,29 @@ auto_sources(){
| sed -r 's:^([^\t]+)\t[^<]*(< *[^ >]+)([^>]*>):\2 filename="\1" \3:'
}
cast_globfile(){
#cast_globfile(){
# sourceglobfile="$1"
# lang="$2"
# globfile="$3"
#
# list_sources "###" "$lang" "$(cat "$sourceglobfile")" >"$globfile"
#}
lang_sources(){
sourceglobfile="$1"
lang="$2"
globfile="$3"
sources="$(list_sources "###" "$lang" "$(cat "$sourceglobfile")")"
[ -f "$globfile" ] && [ "$sources" = "$(cat "$globfile")" ] \
|| printf %s "$sources" >"$globfile"
if [ "$sourceglobfile" -nt "$globfile" ]; then
printf %s "$sources" |while read incfile; do
[ "$incfile" -nt "$globfile" ] && touch "$globfile" || true
done
fi
list_sources "###" "$lang" "$(cat "$sourceglobfile")"
}
cast_refglobs(){
globfile="$1"
reffile="$2"
if [ -f "$globfile" ] && diff "$globfile" "$reffile" >/dev/null; then
incfile="$(cat "$globfile" |xargs -d\\n ls -t |sed -n '1p')"
[ "$incfile" -nt "$globfile" ] && touch "$globfile"
else
cp "$globfile" "$reffile"
fi
}