From: Lars Ingebrigtsen Date: Thu, 2 Jun 2022 11:52:58 +0000 (+0200) Subject: Fix out-of-tree build problems with loaddefs.el X-Git-Tag: emacs-29.0.90~1910^2~279 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=43b0210f83c38fb91cfcfc5a2d4a8c3131331476;p=emacs.git Fix out-of-tree build problems with loaddefs.el * lisp/Makefile.in ($(lisp)/loaddefs.el): Use the new function. * lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate): Pass in whether to inhibit a partial build (to make the code more general). (loaddefs-generate--emacs-batch): Add a new function specially for the Emacs build that has the special rules needed. (This also fixes out-of-tree builds.) loaddefs-generate-batch can be used in general for packages etc. (loaddefs-generate-batch): Remove the special code for Emacs builds. --- diff --git a/lisp/Makefile.in b/lisp/Makefile.in index 040b9a4ca3b..8728467977a 100644 --- a/lisp/Makefile.in +++ b/lisp/Makefile.in @@ -198,13 +198,13 @@ org-manuals: main-first # We make $(lisp)/loaddefs.el a dependency of .PHONY to cause Make to # ignore its time stamp. That's because the real dependencies of # loaddefs.el aren't known to Make, they are implemented in -# loaddefs-generate-batch. +# loaddefs-generate--emacs-batch. autoloads .PHONY: $(lisp)/loaddefs.el $(lisp)/loaddefs.el: gen-lisp $(LOADDEFS) $(lisp)/emacs-lisp/loaddefs-gen.elc $(AM_V_GEN)$(emacs) \ -l $(lisp)/emacs-lisp/loaddefs-gen.elc \ - -f loaddefs-generate-batch $(lisp)/loaddefs.el ${SUBDIRS_ALMOST} + -f loaddefs-generate--emacs-batch ${SUBDIRS_ALMOST} # autoloads only runs when loaddefs.el is nonexistent, although it # generates a number of different files. Provide a force option to enable diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el index 46aec173e86..2e345d6669e 100644 --- a/lisp/emacs-lisp/loaddefs-gen.el +++ b/lisp/emacs-lisp/loaddefs-gen.el @@ -480,7 +480,8 @@ if `autoload-timestamps' is non-nil, otherwise a fixed fake time is inserted)." ;;;###autoload (defun loaddefs-generate (dir output-file &optional excluded-files - extra-data include-package-version) + extra-data include-package-version + generate-full) "Generate loaddefs files for Lisp files in the directories DIRS. DIR can be either a single directory or a list of directories. @@ -493,7 +494,9 @@ directory or directories specified. If EXTRA-DATA, include this string at the start of the generated file. -If INCLUDE-PACKAGE-VERSION, include package version data." +If INCLUDE-PACKAGE-VERSION, include package version data. + +If GENERATE-FULL, don't update, but regenerate all the loaddefs files." (let* ((files-re (let ((tmp nil)) (dolist (suf (get-load-suffixes)) ;; We don't use module-file-suffix below because @@ -508,13 +511,7 @@ If INCLUDE-PACKAGE-VERSION, include package version data." (directory-files (expand-file-name d) t files-re)) (if (consp dir) dir (list dir))))) - (updating (and (file-exists-p output-file) - ;; Always do a complete update if loaddefs-gen.el - ;; has been updated and we're doing a base build. - include-package-version - (file-newer-than-file-p - output-file - (expand-file-name "emacs-lisp/loaddefs-gen.el")))) + (updating (and (file-exists-p output-file) (not generate-full))) (defs nil)) ;; Collect all the autoload data. @@ -647,16 +644,26 @@ This scans for ;;;###autoload forms and related things. The first element on the command line should be the (main) loaddefs.el output file, and the rest are the directories to use." - (let* ((args command-line-args-left) - (output-file (expand-file-name (car args) lisp-directory))) + (let ((args command-line-args-left)) + (setq command-line-args-left nil) + (loaddefs-generate (cdr args) (expand-file-name (car args))))) + +(defun loaddefs-generate--emacs-batch () + "Generate the loaddefs for the Emacs build. +This is like `loaddefs-generate-batch', but has some specific +rules for built-in packages and excluded files." + (let ((args command-line-args-left) + (output-file (expand-file-name "loaddefs.el" lisp-directory))) (setq command-line-args-left nil) (loaddefs-generate - (cdr args) output-file + args output-file (loaddefs-generate--excluded-files) - nil - ;; When generating the top-level Emacs loaddefs file, we want to - ;; include the `package--builtin-versions' things. - (equal (file-name-directory output-file) lisp-directory)))) + nil t + ;; Always do a complete update if loaddefs-gen.el has been + ;; updated. + (file-newer-than-file-p + (expand-file-name "emacs-lisp/loaddefs-gen.el" lisp-directory) + output-file)))) (provide 'loaddefs-gen)