Commit 5b0fdefb authored by Glenn Morris's avatar Glenn Morris
Browse files

Generate each unicode lisp file independently

This is better for parallel builds, eg it eliminates race
conditions from having one process write multiple files.
* admin/unidata/Makefile.in (lparen, unifiles): New variables.
Parse unidata-gen.el, not charprop.el, to get the list of uni- files.
(all): Explicitly list the output lisp files.
(PHONY_EXTRAS): Remove.
(${unidir}/charprop.el): Change rule to just be for this file.
(${unifiles}): New rule to write each unicode lisp file.
(extraclean): Simplify.
* admin/unidata/unidata-gen.el (unidata-gen-charprop):
Quieten in batch mode.
(unidata-gen-files): Remove, no longer used.
* lisp/loadup.el: Update command-line parser.
parent c1e71d38
......@@ -33,6 +33,9 @@ EMACS = ${top_builddir}/src/emacs
unidir = ${top_srcdir}/lisp/international
emacs = "${EMACS}" -batch --no-site-file --no-site-lisp
lparen = (
unifiles = $(addprefix ${unidir}/,$(sort $(shell sed -n 's/^[ \t][ \t]*${lparen}"\(uni-[^"]*\)"$$/\1/p' ${srcdir}/unidata-gen.el)))
# 'make' verbosity.
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
......@@ -51,9 +54,10 @@ am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
.PHONY: all unifiles
.PHONY: all
all: ${top_srcdir}/src/macuvs.h unifiles ${unidir}/charscript.el
all: ${top_srcdir}/src/macuvs.h ${unifiles} ${unidir}/charscript.el \
${unidir}/charprop.el
## Specify .elc as an order-only prereq so as to not needlessly rebuild
## target just because the .elc is missing.
......@@ -71,30 +75,21 @@ unidata.txt: ${srcdir}/UnicodeData.txt
$(AM_V_GEN)sed -e 's/\([^;]*\);\(.*\)/(#x\1 "\2")/' -e 's/;/" "/g' \
< $< > $@
PHONY_EXTRAS =
.PHONY: $(PHONY_EXTRAS)
## charprop doesn't actually depend on unifiles, but for now at least
## pretend that it does since other Makefiles assume that if charprop
## is up-to-date, the unifiles are too.
${unidir}/charprop.el: ${unifiles} ${srcdir}/unidata-gen.el | ${srcdir}/unidata-gen.elc
$(AM_V_at)[ ! -f $@ ] || chmod +w $@
$(AM_V_GEN)${emacs} -L ${srcdir} -l unidata-gen \
-f unidata-gen-charprop $@
${unidir}/charprop.el: ${srcdir}/unidata-gen.el \
${unifiles}: ${srcdir}/unidata-gen.el \
${srcdir}/UnicodeData.txt ${srcdir}/BidiMirroring.txt \
${srcdir}/BidiBrackets.txt | \
${srcdir}/unidata-gen.elc unidata.txt
ifneq (,$(wildcard $@))
$(AM_V_at)cd $(unidir) && \
for f in charprop.el `sed -n 's/^;; FILE: //p' < charprop.el`; do \
[ ! -f $$f ] || [ -w $$f ] || chmod +w $$f || exit; \
done
endif
$(AM_V_GEN)${emacs} -L ${srcdir} -l unidata-gen -f unidata-gen-files \
${srcdir} "${unidir}"
## Check for deleted uni- files, and if any such, force a rebuild.
## Perhaps a more elegant way would be for the previous rule
## to generate a Makefile fragment explicitly listing the uni- files,
## which this file could include. If no fragment, rebuild everything.
unifiles: ${unidir}/charprop.el
$(AM_V_at)for f in `sed -n 's/^;; FILE: //p' < $<`; do \
[ -f $(unidir)/$$f ] || exec $(MAKE) PHONY_EXTRAS=$< $<; \
done
$(AM_V_at)[ ! -f $@ ] || chmod +w $@
$(AM_V_GEN)${emacs} -L ${srcdir} -l unidata-gen \
-f unidata-gen-file $@ ${srcdir}
.PHONY: charscript.el
......@@ -123,7 +118,5 @@ maintainer-clean: distclean
## Cf leim/ja-dic (which is much slower).
extraclean:
rm -f ${top_srcdir}/src/macuvs.h ${unidir}/charscript.el*
ifneq (,$(wildcard $(unidir)/charprop.el))
cd $(unidir) && \
rm -f `sed -n 's/^;; FILE: //p' < charprop.el` charprop.el
endif
rm -f ${unifiles} ${unidir}/charprop.el
......@@ -26,12 +26,12 @@
;; SPECIAL NOTICE
;;
;; This file must be byte-compilable/loadable by `temacs' and also
;; the entry function `unidata-gen-files' must be runnable by `temacs'.
;; the entry function `unidata-gen-file' must be runnable by `temacs'.
;; FILES TO BE GENERATED
;;
;; The entry function `unidata-gen-files' generates these files in
;; in directory specified by its dest-dir argument.
;; The entry functions `unidata-gen-file' and `unidata-gen-charprop'
;; generate these files:
;;
;; charprop.el
;; It contains a series of forms of this format:
......@@ -94,7 +94,7 @@
;; Name of the directory containing files of Unicode Character Database.
;; Dynamically bound in unidata-gen-files.
;; Dynamically bound in unidata-gen-file.
(defvar unidata-dir nil)
(defun unidata-setup-list (unidata-text-file)
......@@ -167,7 +167,10 @@
;; VAL-LIST: list of specially ordered property values
(defconst unidata-file-alist
'(("uni-name.el"
'(
;; NB this list is parsed by the Makefile to extract the names of
;; the uni-*.el files, so preserve the formatting of those lines.
("uni-name.el"
(name
1 unidata-gen-table-name
"Unicode character name.
......@@ -1388,6 +1391,9 @@ Property value is a symbol `o' (Open), `c' (Close), or `n' (None)."
char val1 char val2)))
(sit-for 0))))))))
;; The entry functions. They generate files described in the header
;; comment of this file.
(defun unidata-gen-file (&optional file data-dir unidata-text-file)
"Generate lisp file FILE from Unicode data."
(or file
......@@ -1443,7 +1449,7 @@ Property value is a symbol `o' (Open), `c' (Close), or `n' (None)."
(insert (format "(define-char-code-property '%S %S\n %S)\n"
(unidata-prop-prop proplist) (car elt)
(unidata-prop-docstring proplist)))))
(message "Writing %s..." charprop-file)
(or noninteractive (message "Writing %s..." charprop-file))
(insert ";; Local Variables:\n"
";; coding: utf-8\n"
";; version-control: never\n"
......@@ -1453,27 +1459,6 @@ Property value is a symbol `o' (Open), `c' (Close), or `n' (None)."
(format ";; %s ends here\n"
(file-name-nondirectory charprop-file)))))
;; The entry function. It generates files described in the header
;; comment of this file.
;; Write files (charprop.el, uni-*.el) to dest-dir (default PWD),
;; using as input files from data-dir, and
;; unidata-text-file (default "unidata.txt" in PWD).
(defun unidata-gen-files (&optional data-dir dest-dir unidata-text-file)
(or data-dir
(setq data-dir (pop command-line-args-left)
dest-dir (or (pop command-line-args-left) default-directory)
unidata-text-file (or (pop command-line-args-left)
(expand-file-name "unidata.txt"))))
(let ((coding-system-for-write 'utf-8-unix)
(coding-system-for-read 'utf-8)
(unidata-dir data-dir))
(unidata-setup-list unidata-text-file)
(dolist (elt unidata-file-alist)
(unidata-gen-file (expand-file-name (car elt) dest-dir)
data-dir unidata-text-file))
(unidata-gen-charprop (expand-file-name "charprop.el" dest-dir))))
;;; unidata-gen.el ends here
......@@ -59,8 +59,11 @@
;; This is because PATH_DUMPLOADSEARCH is just "../lisp".
(if (or (equal (member "bootstrap" command-line-args) '("bootstrap"))
;; FIXME this is irritatingly fragile.
(equal (nth 4 command-line-args) "unidata-gen.el")
(equal (nth 7 command-line-args) "unidata-gen-files")
(and (stringp (nth 4 command-line-args))
(string-match "^unidata-gen\\(\\.elc?\\)?$"
(nth 4 command-line-args)))
(member (nth 7 command-line-args) '("unidata-gen-file"
"unidata-gen-charprop"))
(if (fboundp 'dump-emacs)
(string-match "src/bootstrap-emacs" (nth 0 command-line-args))
t))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment