442
|
1 ;;; update-elc-2.el --- Recompile remaining .el files, post-dumping
|
|
2
|
|
3 ;; Copyright (C) 1997 by Free Software Foundation, Inc.
|
|
4 ;; Copyright (C) 2000 Ben Wing.
|
|
5
|
|
6 ;; Author: Ben Wing <ben@xemacs.org>, based on cleantree.el by
|
|
7 ;; Steven L Baur <steve@xemacs.org>
|
|
8 ;; Maintainer: XEmacs Development Team
|
|
9 ;; Keywords: internal
|
|
10
|
|
11 ;; This file is part of XEmacs.
|
|
12
|
|
13 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
14 ;; under the terms of the GNU General Public License as published by
|
|
15 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
16 ;; any later version.
|
|
17
|
|
18 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
21 ;; General Public License for more details.
|
|
22
|
|
23 ;; You should have received a copy of the GNU General Public License
|
|
24 ;; along with XEmacs; see the file COPYING. If not, write to the Free
|
|
25 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
26 ;; 02111-1307, USA.
|
|
27
|
|
28 ;;; Synched up with: Not in FSF
|
|
29
|
|
30 ;;; Commentary:
|
|
31
|
|
32 ;; This file should be used after XEmacs has been dumped, to recompile
|
|
33 ;; all remaining out-of-date .els and clean up orphaned .elcs. It should
|
|
34 ;; be called as
|
|
35 ;;
|
|
36 ;; xemacs -batch -vanilla -l update-elc-2.el -f batch-update-elc-2 ${dirname}
|
|
37 ;;
|
|
38 ;; where ${dirname} is the directory tree to recompile, usually `lisp'.
|
|
39 ;;
|
|
40 ;; Note that this is very different from update-elc.el, which is called
|
|
41 ;; BEFORE dumping, handles only the files needed to dump, and is called
|
|
42 ;; from temacs instead of xemacs.
|
|
43 ;;
|
|
44 ;; The original cleantree.el had the comment: This code is derived
|
|
45 ;; from Gnus based on a suggestion by David Moore <dmoore@ucsd.edu>
|
|
46
|
|
47 ;;; Code:
|
|
48
|
|
49 (defvar update-elc-ignored-dirs
|
|
50 `("." ".." "CVS" "SCCS" "RCS" ,@(unless (featurep 'mule) '("mule"))))
|
|
51
|
|
52 (defvar update-elc-ignored-files
|
|
53 ;; note: entries here are regexps
|
|
54 '("^," ;; #### huh?
|
444
|
55 "^paths\\.el$"
|
|
56 "^loadup\\.el$"
|
|
57 "^loadup-el\\.el$"
|
|
58 "^update-elc\\.el$"
|
|
59 "^update-elc-2\\.el$"
|
|
60 "^dumped-lisp\\.el$"
|
|
61 "^make-docfile\\.el$"
|
|
62 "^site-start\\.el$"
|
|
63 "^site-load\\.el$"
|
|
64 "^site-init\\.el$"
|
|
65 "^version\\.el$"
|
|
66 "^very-early-lisp\\.el$"))
|
442
|
67
|
|
68 ;; SEEN accumulates the list of already-handled dirs.
|
|
69 (defun do-update-elc-2 (dir compile-stage-p seen)
|
|
70 (setq dir (file-name-as-directory dir))
|
|
71 ;; Only scan this sub-tree if we haven't been here yet.
|
|
72 (unless (member (file-truename dir) seen)
|
|
73 (push (file-truename dir) seen)
|
|
74
|
|
75 ;; Do this directory.
|
|
76 (if compile-stage-p
|
|
77 ;; Stage 2: Recompile necessary .els
|
444
|
78 (let ((files (directory-files dir t "\\.el$"))
|
442
|
79 file file-c)
|
|
80 (while (setq file (car files))
|
|
81 (setq files (cdr files))
|
|
82 (setq file-c (concat file "c"))
|
|
83 (when (and (file-exists-p file)
|
|
84 (or (not (file-exists-p file-c))
|
|
85 (file-newer-than-file-p file file-c))
|
|
86 (let (ignore)
|
|
87 (mapcar
|
|
88 #'(lambda (regexp)
|
|
89 (if (string-match regexp
|
|
90 (file-name-nondirectory file))
|
|
91 (setq ignore t)))
|
|
92 update-elc-ignored-files)
|
|
93 (not ignore)))
|
|
94 (byte-compile-file file))))
|
|
95
|
|
96 ;; Stage 1.
|
|
97 ;; Remove out-of-date elcs
|
444
|
98 (let ((files (directory-files dir t "\\.el$"))
|
442
|
99 file file-c)
|
|
100 (while (setq file (car files))
|
|
101 (setq files (cdr files))
|
|
102 (setq file-c (concat file "c"))
|
|
103 (when (and (file-exists-p file-c)
|
|
104 (file-newer-than-file-p file file-c))
|
|
105 (message "Removing out-of-date %s" file-c)
|
|
106 (delete-file file-c))))
|
|
107 ;; Remove elcs without corresponding el
|
444
|
108 (let ((files (directory-files dir t "\\.elc$"))
|
442
|
109 file file-c)
|
|
110 (while (setq file-c (car files))
|
|
111 (setq files (cdr files))
|
|
112 (setq file (replace-in-string file-c "c$" ""))
|
|
113 (when (and (file-exists-p file-c)
|
|
114 (not (file-exists-p file)))
|
|
115 (message "Removing %s; no corresponding .el" file-c)
|
617
|
116 (delete-file file-c)))))
|
442
|
117
|
|
118 ;; We descend recursively
|
|
119 (let ((dirs (directory-files dir t nil t))
|
|
120 dir)
|
|
121 (while (setq dir (pop dirs))
|
|
122 (when (and (not (member (file-name-nondirectory dir)
|
|
123 update-elc-ignored-dirs))
|
|
124 (file-directory-p dir))
|
|
125 (do-update-elc-2 dir compile-stage-p seen))))
|
|
126
|
617
|
127 ))
|
442
|
128
|
|
129 (defun batch-update-elc-2 ()
|
|
130 (defvar command-line-args-left)
|
|
131 (unless noninteractive
|
|
132 (error "`batch-update-elc-2' is to be used only with -batch"))
|
|
133 (let ((dir (car command-line-args-left)))
|
|
134 ;; We remove all the bad .elcs before any byte-compilation, because
|
|
135 ;; there may be dependencies between one .el and another (even across
|
|
136 ;; directories), and we don't want to load an out-of-date .elc while
|
|
137 ;; byte-compiling a file.
|
|
138 (message "Removing old or spurious .elcs in directory tree `%s'..." dir)
|
|
139 (do-update-elc-2 dir nil nil)
|
|
140 (message "Removing old or spurious .elcs in directory tree `%s'...done"
|
|
141 dir)
|
|
142 (message "Recompiling updated .els in directory tree `%s'..." dir)
|
|
143 (do-update-elc-2 dir t nil)
|
528
|
144 (message "Recompiling updated .els in directory tree `%s'...done" dir)
|
|
145 ;; don't depend on being able to autoload `update-autoload-files'!
|
|
146 (load "autoload")
|
1232
|
147 ;; #### the API used here is deprecated, convert to one with explicit
|
|
148 ;; arguments when it is available
|
|
149 (let ((generated-autoload-file (expand-file-name "auto-autoloads.el" dir))
|
|
150 (autoload-package-name "auto")) ; feature prefix
|
|
151 (update-autoload-files (list dir))
|
|
152 (byte-recompile-file generated-autoload-file 0))
|
|
153 (when (featurep 'modules)
|
996
|
154 (let* ((moddir (expand-file-name "../modules" (file-truename dir)))
|
|
155 (generated-autoload-file
|
1232
|
156 (expand-file-name "auto-autoloads.el" moddir))
|
|
157 (autoload-package-name "modules")) ; feature prefix
|
|
158 (update-autoload-files
|
|
159 (delete (concat (file-name-as-directory moddir) ".")
|
|
160 (delete (concat (file-name-as-directory moddir) "..")
|
|
161 (directory-files moddir t nil nil 0)))
|
|
162 t)
|
996
|
163 (byte-recompile-file generated-autoload-file 0)))
|
528
|
164 (when (featurep 'mule)
|
1232
|
165 (let* ((muledir (expand-file-name "../modules" (file-truename dir)))
|
|
166 (generated-autoload-file
|
|
167 (expand-file-name "auto-autoloads.el" muledir))
|
|
168 (autoload-package-name "mule")) ; feature prefix
|
|
169 (update-autoload-files (list muledir))
|
|
170 (byte-recompile-file generated-autoload-file 0)))
|
528
|
171 ;; likewise here.
|
|
172 (load "cus-dep")
|
|
173 (Custom-make-dependencies dir)
|
|
174 (byte-recompile-file (expand-file-name "custom-load.el" dir) 0)
|
|
175 (when (featurep 'mule)
|
|
176 (Custom-make-dependencies (expand-file-name "mule" dir))
|
|
177 (byte-recompile-file (expand-file-name "mule/custom-load.el" dir) 0))
|
|
178 )
|
442
|
179 (setq command-line-args-left nil))
|
|
180
|
444
|
181 ;;; update-elc-2.el ends here
|