mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
(loaddefs-generate--emacs-batch): Chdir to lisp-directory
Chdir once and for all at the beginning to simplify the code. Eliminate some redundant `expand-file-name`s and fix a broken use of `expand-file-name` where we passed a list as second arg. * lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate): Rename DIR to DIRS, to clarify that it can be a list. Use `ensure-list`. Don't pass DIR(S) directly to `expand-file-name`. Remove redundant `expand-file-name`. (loaddefs-generate--excluded-files): Add sanity checks. Return relative file names since `loaddefs-generate` will make them absolute anyway. Simplify. (loaddefs-generate--emacs-batch): Chdir to `lisp-directory` and simplify the rest accordingly.
This commit is contained in:
parent
02253b35af
commit
34ab8abdd2
1 changed files with 34 additions and 23 deletions
|
|
@ -593,7 +593,7 @@ If COMPILE, don't include a \"don't compile\" cookie."
|
||||||
(buffer-string))))
|
(buffer-string))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun loaddefs-generate (dir output-file &optional excluded-files
|
(defun loaddefs-generate (dirs output-file &optional excluded-files
|
||||||
extra-data include-package-version
|
extra-data include-package-version
|
||||||
generate-full)
|
generate-full)
|
||||||
"Generate loaddefs files for Lisp files in one or more directories given by DIR.
|
"Generate loaddefs files for Lisp files in one or more directories given by DIR.
|
||||||
|
|
@ -632,13 +632,18 @@ instead of just updating them with the new/changed autoloads."
|
||||||
(mapcar (lambda (d)
|
(mapcar (lambda (d)
|
||||||
(directory-files (expand-file-name d)
|
(directory-files (expand-file-name d)
|
||||||
t files-re))
|
t files-re))
|
||||||
(if (consp dir) dir (list dir)))))
|
(ensure-list dirs))))
|
||||||
(updating (and (file-exists-p output-file) (not generate-full)))
|
(updating (and (file-exists-p output-file) (not generate-full)))
|
||||||
(defs nil))
|
(defs nil))
|
||||||
;; Allow the excluded files to be relative.
|
;; Allow the excluded files to be relative.
|
||||||
(setq excluded-files
|
;; We used to do (expand-file-name file dir), which strangely enough
|
||||||
(mapcar (lambda (file) (expand-file-name file dir))
|
;; doesn't signal an error when DIR is a list but does something weird
|
||||||
excluded-files))
|
;; instead, so let's preserve the old behavior when DIR is a string,
|
||||||
|
;; even tho it's different from what we do when it's a list.
|
||||||
|
(let ((basedir (if (stringp dirs) dirs)))
|
||||||
|
(setq excluded-files
|
||||||
|
(mapcar (lambda (file) (expand-file-name file basedir))
|
||||||
|
excluded-files)))
|
||||||
|
|
||||||
;; Collect all the autoload data.
|
;; Collect all the autoload data.
|
||||||
(let ((progress (make-progress-reporter
|
(let ((progress (make-progress-reporter
|
||||||
|
|
@ -657,7 +662,7 @@ instead of just updating them with the new/changed autoloads."
|
||||||
(file-attributes file))))
|
(file-attributes file))))
|
||||||
;; If we're scanning for package versions, we want to look
|
;; If we're scanning for package versions, we want to look
|
||||||
;; at the file even if it's excluded.
|
;; at the file even if it's excluded.
|
||||||
(let* ((excluded (member (expand-file-name file dir) excluded-files))
|
(let* ((excluded (member file excluded-files))
|
||||||
(package-data
|
(package-data
|
||||||
(and include-package-version (if excluded 'only t))))
|
(and include-package-version (if excluded 'only t))))
|
||||||
(when (or package-data (not excluded))
|
(when (or package-data (not excluded))
|
||||||
|
|
@ -724,7 +729,7 @@ instead of just updating them with the new/changed autoloads."
|
||||||
(unless (equal (buffer-hash) hash)
|
(unless (equal (buffer-hash) hash)
|
||||||
(write-region (point-min) (point-max) loaddefs-file nil 'silent)
|
(write-region (point-min) (point-max) loaddefs-file nil 'silent)
|
||||||
(byte-compile-info
|
(byte-compile-info
|
||||||
(file-relative-name loaddefs-file (car (ensure-list dir)))
|
(file-relative-name loaddefs-file (car (ensure-list dirs)))
|
||||||
t "GEN")))))
|
t "GEN")))))
|
||||||
|
|
||||||
;; If processing files without any autoloads, the above loop will
|
;; If processing files without any autoloads, the above loop will
|
||||||
|
|
@ -776,19 +781,21 @@ instead of just updating them with the new/changed autoloads."
|
||||||
;; Exclude those files that are preloaded on ALL platforms.
|
;; Exclude those files that are preloaded on ALL platforms.
|
||||||
;; These are the ones in loadup.el where "(load" is at the start
|
;; These are the ones in loadup.el where "(load" is at the start
|
||||||
;; of the line (crude, but it works).
|
;; of the line (crude, but it works).
|
||||||
(let ((default-directory (file-name-directory lisp-directory))
|
(unless (equal default-directory (file-name-as-directory lisp-directory))
|
||||||
(excludes nil)
|
(error "PWD is not set as expected: %S" default-directory))
|
||||||
file)
|
(let ((excludes nil))
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(insert-file-contents "loadup.el")
|
(insert-file-contents "loadup.el")
|
||||||
|
(when (= (point-min) (point-max)) (error "Can't find loadup.el"))
|
||||||
(while (re-search-forward "^(load \"\\([^\"]+\\)\"" nil t)
|
(while (re-search-forward "^(load \"\\([^\"]+\\)\"" nil t)
|
||||||
(setq file (match-string 1))
|
(let ((file (match-string 1)))
|
||||||
(or (string-match "\\.el\\'" file)
|
(unless (string-match "\\`site-" file)
|
||||||
(setq file (format "%s.el" file)))
|
(push (if (string-match "\\.el\\'" file)
|
||||||
(or (string-match "\\`site-" file)
|
file
|
||||||
(push (expand-file-name file) excludes))))
|
(format "%s.el" file))
|
||||||
|
excludes)))))
|
||||||
;; Don't scan ldefs-boot.el, either.
|
;; Don't scan ldefs-boot.el, either.
|
||||||
(cons (expand-file-name "ldefs-boot.el") excludes)))
|
(cons "ldefs-boot.el" excludes)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun loaddefs-generate-batch ()
|
(defun loaddefs-generate-batch ()
|
||||||
|
|
@ -806,8 +813,12 @@ use."
|
||||||
"Generate the loaddefs for the Emacs build.
|
"Generate the loaddefs for the Emacs build.
|
||||||
This is like `loaddefs-generate-batch', but has some specific
|
This is like `loaddefs-generate-batch', but has some specific
|
||||||
rules for built-in packages and excluded files."
|
rules for built-in packages and excluded files."
|
||||||
(let ((args command-line-args-left)
|
(let* ((args command-line-args-left)
|
||||||
(output-file (expand-file-name "loaddefs.el" lisp-directory)))
|
;; We're run from $BUILDDIR/lisp but all the .el(c) files reside
|
||||||
|
;; (and are generated) in `lisp-directory' which is in $SRCDIR,
|
||||||
|
;; so go there and don't look back.
|
||||||
|
(default-directory lisp-directory)
|
||||||
|
(output-file (expand-file-name "loaddefs.el")))
|
||||||
(setq command-line-args-left nil)
|
(setq command-line-args-left nil)
|
||||||
(loaddefs-generate
|
(loaddefs-generate
|
||||||
args output-file
|
args output-file
|
||||||
|
|
@ -817,12 +828,12 @@ rules for built-in packages and excluded files."
|
||||||
;; updated.
|
;; updated.
|
||||||
(file-newer-than-file-p
|
(file-newer-than-file-p
|
||||||
(expand-file-name "emacs-lisp/loaddefs-gen.el" lisp-directory)
|
(expand-file-name "emacs-lisp/loaddefs-gen.el" lisp-directory)
|
||||||
output-file)))
|
output-file))
|
||||||
(let ((lisp-mode-autoload-regexp
|
(let ((lisp-mode-autoload-regexp
|
||||||
"^;;;###\\(\\(noexist\\)-\\)?\\(theme-autoload\\)"))
|
"^;;;###\\(\\(noexist\\)-\\)?\\(theme-autoload\\)"))
|
||||||
(loaddefs-generate
|
(loaddefs-generate
|
||||||
(expand-file-name "../etc/themes/" lisp-directory)
|
(expand-file-name "../etc/themes/")
|
||||||
(expand-file-name "theme-loaddefs.el" lisp-directory))))
|
(expand-file-name "theme-loaddefs.el")))))
|
||||||
|
|
||||||
;;;###autoload (load "theme-loaddefs.el" t)
|
;;;###autoload (load "theme-loaddefs.el" t)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue