# batch-update-autoloads, which only updates the autoloads whose
# sources have changed.
-# Write to a temporary file in case we're doing a parallel build and a
-# CANNOT_DUMP-mode Emacs needs to read loaddefs at startup.
-# (FIXME: This seems like something that batch-update-autoloads should
-# do internally, then it would Just Work for all loaddefs files.)
-# We start by copying an existing loaddefs.el to loaddefs.tmp to avoid
-# regenerating the entire file anew, which is slow; starting from an
-# almost-correct content will enable the "only update where necessary"
-# feature of batch-update-autoloads.
-
# Use expand-file-name rather than $abs_scrdir so that Emacs does not
# get confused when it compares file-names for equality.
autoloads .PHONY: $(lisp)/loaddefs.el
$(lisp)/loaddefs.el: gen-lisp $(LOADDEFS)
@echo Directories for loaddefs: ${SUBDIRS_ALMOST}
- @if test -f $@ ; then cp $@ $(lisp)/loaddefs.tmp ; fi
$(AM_V_GEN)$(emacs) -l autoload \
--eval '(setq autoload-ensure-writable t)' \
--eval '(setq autoload-builtin-package-versions t)' \
- --eval '(setq generated-autoload-file (expand-file-name (unmsys--file-name "$(lisp)/loaddefs.tmp")))' \
+ --eval '(setq generated-autoload-file (expand-file-name (unmsys--file-name "$@")))' \
-f batch-update-autoloads ${SUBDIRS_ALMOST}
- $(top_srcdir)/build-aux/move-if-change $(lisp)/loaddefs.tmp $@
# autoloads only runs when loaddefs.el is nonexistent, although it
# generates a number of different files. Provide a force option to enable
(error "%s:0:0: error: %s: %s" file (car err) (cdr err)))
))
\f
+;; For parallel builds, to stop another process reading a half-written file.
+(defun autoload--save-buffer ()
+ "Save current buffer to its file, atomically."
+ ;; Copied from byte-compile-file.
+ (let* ((version-control 'never)
+ (tempfile (make-temp-name buffer-file-name))
+ (kill-emacs-hook
+ (cons (lambda () (ignore-errors (delete-file tempfile)))
+ kill-emacs-hook)))
+ (write-region (point-min) (point-max) tempfile nil 1)
+ (backup-buffer)
+ (rename-file tempfile buffer-file-name t)
+ (set-buffer-modified-p nil)
+ (set-visited-file-modtime)
+ (or noninteractive (message "Wrote %s" buffer-file-name))))
+
(defun autoload-save-buffers ()
(while autoload-modified-buffers
(with-current-buffer (pop autoload-modified-buffers)
- (let ((version-control 'never))
- (save-buffer)))))
+ (autoload--save-buffer))))
;; FIXME This command should be deprecated.
;; See http://debbugs.gnu.org/22213#41
;; dependencies don't trigger unnecessarily.
(if (not changed)
(set-buffer-modified-p nil)
- (let ((version-control 'never))
- (save-buffer)))
+ (autoload--save-buffer))
;; In case autoload entries were added to other files because of
;; file-local autoload-generated-file settings.