Fix race in 'make info/dir', and speed it up.
* Makefile.in (AWK, srcdir_doc_info_dir_inputs, info_dir_inputs): New macros. (clean): Remove info-dir.*. (info_dir_deps): Depend on make-info-dir too. Fix bug with wildcards that weren't expanded. (${srcdir}/info/dir): Make sure info directory exists. Don't call pwd; just redirect make-info-dir's stdout to temp file. * build-aux/make-info-dir: Send output to stdout. Take input file names from args. Fix a "FIXME inefficient looping" by using awk's associative arrays. Basically, this rewrites the script from scratch, and speeds up 'make info/dir' from 2.6s to 0.07s on my platform.
This commit is contained in:
parent
d361bcfbc7
commit
78b215ffea
3 changed files with 73 additions and 79 deletions
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
|||
2014-10-23 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
Fix race in 'make info/dir', and speed it up.
|
||||
* Makefile.in (AWK, srcdir_doc_info_dir_inputs, info_dir_inputs):
|
||||
New macros.
|
||||
(clean): Remove info-dir.*.
|
||||
(info_dir_deps): Depend on make-info-dir too.
|
||||
Fix bug with wildcards that weren't expanded.
|
||||
(${srcdir}/info/dir): Make sure info directory exists.
|
||||
Don't call pwd; just redirect make-info-dir's stdout to temp file.
|
||||
* build-aux/make-info-dir: Send output to stdout.
|
||||
Take input file names from args.
|
||||
Fix a "FIXME inefficient looping" by using awk's associative arrays.
|
||||
Basically, this rewrites the script from scratch, and speeds up
|
||||
'make info/dir' from 2.6s to 0.07s on my platform.
|
||||
|
||||
2014-10-20 Glenn Morris <rgm@gnu.org>
|
||||
|
||||
* Merge in all changes up to 24.4 release.
|
||||
|
|
26
Makefile.in
26
Makefile.in
|
@ -80,6 +80,7 @@ AUTOCONF = @AUTOCONF@
|
|||
AUTOMAKE = @AUTOMAKE@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AWK = @AWK@
|
||||
|
||||
EXEEXT=@EXEEXT@
|
||||
|
||||
|
@ -817,6 +818,7 @@ clean: $(clean_dirs:=_clean)
|
|||
[ ! -d $$dir ] || $(MAKE) -C $$dir clean; \
|
||||
done
|
||||
-rm -f etc/emacs.tmpdesktop etc/emacs.tmpappdata
|
||||
-rm -rf info-dir.*
|
||||
|
||||
### `bootclean'
|
||||
### Delete all files that need to be remade for a clean bootstrap.
|
||||
|
@ -935,13 +937,19 @@ ps: $(PSS)
|
|||
|
||||
info-dir: ${srcdir}/info/dir
|
||||
|
||||
## Not strictly necessary, but speeds things up a bit by stopping
|
||||
## the info-dir rule from running when not needed.
|
||||
## Hopefully doc/misc/*.texi is not too long for some systems?
|
||||
info_dir_deps = ${srcdir}/build-aux/dir_top \
|
||||
${srcdir}/doc/emacs/emacs.texi \
|
||||
${srcdir}/doc/lispintro/emacs-lisp-intro.texi \
|
||||
${srcdir}/doc/lispref/elisp.texi ${srcdir}/doc/misc/*.texi
|
||||
srcdir_doc_info_dir_inputs = \
|
||||
${srcdir}/doc/emacs/emacs.texi \
|
||||
${srcdir}/doc/lispintro/emacs-lisp-intro.texi \
|
||||
${srcdir}/doc/lispref/elisp.texi \
|
||||
$(sort $(wildcard ${srcdir}/doc/misc/*.texi))
|
||||
info_dir_inputs = \
|
||||
../build-aux/dir_top \
|
||||
$(subst ${srcdir}/doc/,,${srcdir_doc_info_dir_inputs})
|
||||
info_dir_deps = \
|
||||
${srcdir}/build-aux/make-info-dir \
|
||||
${srcdir}/build-aux/dir_top \
|
||||
${srcdir_doc_info_dir_inputs}
|
||||
|
||||
## It would be much simpler if info/dir was only created in the
|
||||
## installation location by the install-info rule, but we also
|
||||
|
@ -950,10 +958,12 @@ info_dir_deps = ${srcdir}/build-aux/dir_top \
|
|||
## but then we would need to depend on info-real, which would
|
||||
## slow down parallelization.
|
||||
${srcdir}/info/dir: ${info_dir_deps}
|
||||
${MKDIR_P} ${srcdir}/info
|
||||
tempfile=info-dir.$$$$; \
|
||||
rm -f $${tempfile}; \
|
||||
thisdir=`pwd`; \
|
||||
(cd ${srcdir} && ./build-aux/make-info-dir $${thisdir}/$${tempfile}); \
|
||||
(cd ${srcdir}/doc && \
|
||||
AWK='${AWK}' ../build-aux/make-info-dir ${info_dir_inputs} \
|
||||
) >$$tempfile && \
|
||||
${srcdir}/build-aux/move-if-change $${tempfile} ${srcdir}/info/dir
|
||||
|
||||
INSTALL_DVI = install-emacs-dvi install-lispref-dvi \
|
||||
|
|
|
@ -31,76 +31,44 @@
|
|||
## installation directory. It does not handle info/dir being present
|
||||
## but missing some entries.
|
||||
|
||||
### Code:
|
||||
|
||||
if test $# -ne 1; then
|
||||
echo "Specify destination file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
outfile=$1
|
||||
|
||||
echo "Creating $outfile..."
|
||||
|
||||
if test -f "$outfile"; then
|
||||
echo "$outfile already present"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
## Header contains non-printing characters, so this is more
|
||||
## reliable than using echo.
|
||||
basefile=build-aux/dir_top
|
||||
## reliable than using awk.
|
||||
cat <"${1?}" || exit
|
||||
shift
|
||||
|
||||
if test ! -f "$basefile"; then
|
||||
echo "$basefile not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
cp $basefile $outfile
|
||||
|
||||
|
||||
## FIXME inefficient looping.
|
||||
## What we should do is loop once over files, collecting topic and
|
||||
## direntry information for each. Then loop over topics and write
|
||||
## out the results. But that seems to require associative arrays,
|
||||
## and I do not know how to do that with portable sh.
|
||||
## Could use Emacs instead of sh, but till now info generation does
|
||||
## not require Emacs to have been built.
|
||||
for topic in "Texinfo documentation system" "Emacs" "Emacs lisp" \
|
||||
"Emacs editing modes" "Emacs network features" "Emacs misc features" \
|
||||
"Emacs lisp libraries"; do
|
||||
|
||||
cat - <<EOF >> $outfile
|
||||
|
||||
$topic
|
||||
EOF
|
||||
## Bit faster than doc/*/*.texi.
|
||||
for file in doc/emacs/emacs.texi doc/lispintro/emacs-lisp-intro.texi \
|
||||
doc/lispref/elisp.texi doc/misc/*.texi; do
|
||||
|
||||
## FIXME do not ignore w32 if OS is w32.
|
||||
case $file in
|
||||
*-xtra.texi|*efaq-w32.texi|*doclicense.texi) continue ;;
|
||||
esac
|
||||
|
||||
dircat=`sed -n -e 's/@value{emacsname}/Emacs/' -e 's/^@dircategory //p' $file`
|
||||
|
||||
## TODO warn about unknown topics.
|
||||
## (check-info in top-level Makefile does that.)
|
||||
test "$dircat" = "$topic" || continue
|
||||
|
||||
|
||||
sed -n -e 's/@value{emacsname}/Emacs/' \
|
||||
-e 's/@acronym{\([A-Z]*\)}/\1/' \
|
||||
-e '/^@direntry/,/^@end direntry/ s/^\([^@]\)/\1/p' \
|
||||
$file >> $outfile
|
||||
|
||||
done
|
||||
done
|
||||
|
||||
echo "Created $outfile"
|
||||
|
||||
exit 0
|
||||
|
||||
### make-info-dir ends here
|
||||
exec "${AWK-awk}" '
|
||||
function detexinfo() {
|
||||
gsub(/@value{emacsname}/, "Emacs")
|
||||
gsub(/@[^{]*\{/, "")
|
||||
gsub(/}/, "")
|
||||
}
|
||||
BEGIN {
|
||||
ntopics = 0
|
||||
topic[ntopics++] = "Texinfo documentation system"
|
||||
topic[ntopics++] = "Emacs"
|
||||
topic[ntopics++] = "Emacs lisp"
|
||||
topic[ntopics++] = "Emacs editing modes"
|
||||
topic[ntopics++] = "Emacs network features"
|
||||
topic[ntopics++] = "Emacs misc features"
|
||||
topic[ntopics++] = "Emacs lisp libraries"
|
||||
topic[ntopics] = "Unknown category"
|
||||
}
|
||||
/^@dircategory / {
|
||||
sub(/^@dircategory /, "")
|
||||
detexinfo()
|
||||
for (dircat = 0; dircat < ntopics && topic[dircat] != $0; dircat++)
|
||||
continue;
|
||||
}
|
||||
/^@direntry/, /^@end direntry/ {
|
||||
# FIXME do not ignore w32 if OS is w32.
|
||||
if ($0 !~ /^@/ && $0 !~ /w32/) {
|
||||
detexinfo()
|
||||
data[dircat] = data[dircat] $0 "\n"
|
||||
}
|
||||
}
|
||||
END {
|
||||
for (dircat = 0; dircat <= ntopics; dircat++)
|
||||
if (data[dircat])
|
||||
printf "\n%s\n%s", topic[dircat], data[dircat]
|
||||
}
|
||||
' "${@?}"
|
||||
|
|
Loading…
Add table
Reference in a new issue