Mercurial > hg > xemacs-beta
comparison lisp/update-elc.el @ 1298:1b4bc72f433e
[xemacs-hg @ 2003-02-14 12:05:06 by ben]
speedups to build process
autoload.el: Factor out common code in generate-{c-,}file-autoloads-1 into new
function generate-autoload-ish-1. \(I was originally going to use
this for custom as well but ended up thinking better of it.)
cus-dep.el: Cache the old computed values in custom-load.el and reuse them as
necessary, to speed up running cus-dep (which would take 25-30
seconds to do all files in lisp/*, lisp/*/* on my Pentium III
700). Use `message' not `princ' to get correct newline behavior.
Output messages showing each file we do actually process.
update-elc-2.el: Rewrite algorithm to be much faster -- cache calls to
directory-files and don't make needless calls to file-exists-p,
file-directory-p because they're way way slow.
Autoload early and only when update-elc has told us to.
update-elc.el: If no files need byte compilation, signal to update-elc-2 to do
any necessary autoload updating (using the file REBUILD_AUTOLOADS)
rather than doing it ourselves, which would be way slow. Ignore
updates to custom-load.el and auto-autoloads.el when checking to
see whether autoloads need updating. Optimize out many
unnecessary calls to file-exists-p to speed it up somewhat. (####
The remaining time is 50% or more in locate-file; this is
presumably because, even though it has a cache, it's still
statting each file to determine it's actually there. By calling
directory-files ourselves, building a tree, and then looking in
that tree, we could drastically shorten the time needed to do the
locate operation.)
author | ben |
---|---|
date | Fri, 14 Feb 2003 12:05:07 +0000 |
parents | 57b76886836d |
children | f99d3d25df86 |
comparison
equal
deleted
inserted
replaced
1297:6c21360a544b | 1298:1b4bc72f433e |
---|---|
57 (defvar need-to-rebuild-autoloads nil) | 57 (defvar need-to-rebuild-autoloads nil) |
58 (defvar need-to-rebuild-mule-autoloads nil) | 58 (defvar need-to-rebuild-mule-autoloads nil) |
59 (defvar need-to-recompile-autoloads nil) | 59 (defvar need-to-recompile-autoloads nil) |
60 (defvar need-to-recompile-mule-autoloads nil) | 60 (defvar need-to-recompile-mule-autoloads nil) |
61 (defvar undumped-exe nil) | 61 (defvar undumped-exe nil) |
62 (defvar dumped-exe nil) | 62 ;(defvar dumped-exe nil) |
63 (defvar dumped-exe-out-of-date-wrt-dump-files nil) | 63 (defvar dumped-exe-out-of-date-wrt-dump-files nil) |
64 (defvar dumped-exe-out-of-date-wrt-undumped-exe nil) | 64 ;(defvar dumped-exe-out-of-date-wrt-undumped-exe nil) |
65 | 65 |
66 ;(setq update-elc-files-to-compile | 66 ;(setq update-elc-files-to-compile |
67 ; (delq nil | 67 ; (delq nil |
68 ; (mapcar (function | 68 ; (mapcar (function |
69 ; (lambda (x) | 69 ; (lambda (x) |
110 "raw-process.el" | 110 "raw-process.el" |
111 "version.el" | 111 "version.el" |
112 "very-early-lisp.el") | 112 "very-early-lisp.el") |
113 "Lisp files that should not be byte compiled.") | 113 "Lisp files that should not be byte compiled.") |
114 | 114 |
115 (defvar lisp-files-ignored-when-checking-for-autoload-updating | |
116 '("custom-load.el" | |
117 "auto-autoloads.el") | |
118 "Lisp files that should not trigger auto-autoloads rebuilding.") | |
119 | |
115 (defun update-elc-chop-extension (file) | 120 (defun update-elc-chop-extension (file) |
116 (if (string-match "\\.elc?$" file) | 121 (if (string-match "\\.elc?$" file) |
117 (substring file 0 (match-beginning 0)) | 122 (substring file 0 (match-beginning 0)) |
118 file)) | 123 file)) |
119 | 124 |
128 (setq dumped-exe | 133 (setq dumped-exe |
129 (cond ((file-exists-p "../src/xemacs.exe") "../src/xemacs.exe") | 134 (cond ((file-exists-p "../src/xemacs.exe") "../src/xemacs.exe") |
130 ((file-exists-p "../src/xemacs") "../src/xemacs") | 135 ((file-exists-p "../src/xemacs") "../src/xemacs") |
131 (t nil))) | 136 (t nil))) |
132 | 137 |
133 (let ((temacs-exe | 138 ;; Not currently used but might be at some point. |
134 (cond ((file-exists-p "../src/temacs.exe") "../src/temacs.exe") | 139 ; (let ((temacs-exe |
135 ((file-exists-p "../src/temacs") "../src/temacs") | 140 ; (cond ((file-exists-p "../src/temacs.exe") "../src/temacs.exe") |
136 (t nil))) | 141 ; ((file-exists-p "../src/temacs") "../src/temacs") |
137 (data-file | 142 ; (t nil))) |
138 (cond ((file-exists-p "../src/xemacs.dmp") "../src/xemacs.dmp") | 143 ; (data-file |
139 (t nil)))) | 144 ; (cond ((file-exists-p "../src/xemacs.dmp") "../src/xemacs.dmp") |
140 | 145 ; (t nil)))) |
141 ;; two setups here: | 146 |
142 ;; (1) temacs.exe is undumped, dumped into xemacs.exe. Happens with | 147 ; ;; two setups here: |
143 ;; unexec, but also with pdump under MS Windows native, since | 148 ; ;; (1) temacs.exe is undumped, dumped into xemacs.exe. Happens with |
144 ;; the dumped data is stored as a resource in the xemacs.exe | 149 ; ;; unexec, but also with pdump under MS Windows native, since |
145 ;; executable. | 150 ; ;; the dumped data is stored as a resource in the xemacs.exe |
146 ;; (2) xemacs.exe is dumped or undumped. Running `xemacs -nd' gets | 151 ; ;; executable. |
147 ;; you the equivalent of `temacs'. Dumping creates a file | 152 ; ;; (2) xemacs.exe is dumped or undumped. Running `xemacs -nd' gets |
148 ;; `xemacs.dmp'. | 153 ; ;; you the equivalent of `temacs'. Dumping creates a file |
149 | 154 ; ;; `xemacs.dmp'. |
150 (setq dumped-exe-out-of-date-wrt-undumped-exe | 155 |
151 (cond ((not dumped-exe) t) | 156 ; (setq dumped-exe-out-of-date-wrt-undumped-exe |
152 (temacs-exe (file-newer-than-file-p temacs-exe dumped-exe)) | 157 ; (cond ((not dumped-exe) t) |
153 ((not data-file) t) | 158 ; (temacs-exe (file-newer-than-file-p temacs-exe dumped-exe)) |
154 (t (file-newer-than-file-p dumped-exe data-file)))) | 159 ; ((not data-file) t) |
155 ) | 160 ; (t (file-newer-than-file-p dumped-exe data-file)))) |
156 | 161 ; (setq dumped-exe-exists (or (and temacs-exe dumped-exe) |
162 ; (and data-file dumped-exe)))) | |
157 | 163 |
158 ;; Path setup | 164 ;; Path setup |
159 (let ((package-preloaded-file-list | 165 (let ((package-preloaded-file-list |
160 (packages-collect-package-dumped-lisps late-package-load-path))) | 166 (packages-collect-package-dumped-lisps late-package-load-path))) |
161 | 167 |
198 ;; (print full-arg-el) | 204 ;; (print full-arg-el) |
199 | 205 |
200 ;; now check if .el or .elc is newer than the dumped exe. | 206 ;; now check if .el or .elc is newer than the dumped exe. |
201 ;; if so, need to redump. | 207 ;; if so, need to redump. |
202 (when (and dumped-exe arg-is-preloaded | 208 (when (and dumped-exe arg-is-preloaded |
203 (or (and (file-exists-p full-arg-el) | 209 ;; no need to check for existence of either of the files |
204 (file-newer-than-file-p full-arg-el dumped-exe)) | 210 ;; because of the definition of file-newer-than-file-p. |
205 (and (file-exists-p full-arg-elc) | 211 (or (file-newer-than-file-p full-arg-el dumped-exe) |
206 (file-newer-than-file-p full-arg-elc dumped-exe)))) | 212 (file-newer-than-file-p full-arg-elc dumped-exe))) |
207 (setq dumped-exe-out-of-date-wrt-dump-files t)) | 213 (setq dumped-exe-out-of-date-wrt-dump-files t)) |
208 | 214 |
209 (if (and (not (member (file-name-nondirectory arg) | 215 (if (and (not (member (file-name-nondirectory arg) |
210 unbytecompiled-lisp-files)) | 216 unbytecompiled-lisp-files)) |
211 (not (member full-arg-el processed)) | 217 (not (member full-arg-el processed)) |
212 (file-exists-p full-arg-el) | 218 ;; no need to check for existence of either of the files |
213 (or (not (file-exists-p full-arg-elc)) | 219 ;; because of the definition of file-newer-than-file-p. |
214 (file-newer-than-file-p full-arg-el full-arg-elc))) | 220 (file-newer-than-file-p full-arg-el full-arg-elc)) |
215 (setq processed (cons full-arg-el processed))) | 221 (setq processed (cons full-arg-el processed))) |
216 | 222 |
217 (setq files-to-process (cdr files-to-process)))) | 223 (setq files-to-process (cdr files-to-process)))) |
218 | 224 |
219 ;; Check if we need to rebuild the auto-autoloads.el files -- that is, | 225 ;; Check if we need to rebuild the auto-autoloads.el files -- that is, |
226 (autoload-file | 232 (autoload-file |
227 (expand-file-name "auto-autoloads.el" full-dir)) | 233 (expand-file-name "auto-autoloads.el" full-dir)) |
228 (autoload-is-mule (equal dir "../lisp/mule"))) | 234 (autoload-is-mule (equal dir "../lisp/mule"))) |
229 (while all-files-in-dir | 235 (while all-files-in-dir |
230 (let* ((full-arg (car all-files-in-dir))) | 236 (let* ((full-arg (car all-files-in-dir))) |
231 (when (or (not (file-exists-p autoload-file)) | 237 ;; custom-load.el always gets regenerated so don't let that |
232 (and (file-exists-p full-arg) | 238 ;; trigger us. |
233 (file-newer-than-file-p full-arg autoload-file))) | 239 (when (and (not |
240 (member | |
241 (file-name-nondirectory full-arg) | |
242 lisp-files-ignored-when-checking-for-autoload-updating | |
243 )) | |
244 (file-newer-than-file-p full-arg autoload-file)) | |
234 (if autoload-is-mule | 245 (if autoload-is-mule |
235 (setq need-to-rebuild-mule-autoloads t) | 246 (setq need-to-rebuild-mule-autoloads t) |
236 (setq need-to-rebuild-autoloads t)))) | 247 (setq need-to-rebuild-autoloads t)))) |
237 (setq all-files-in-dir (cdr all-files-in-dir)))) | 248 (setq all-files-in-dir (cdr all-files-in-dir)))) |
238 (setq dirs-to-check (cdr dirs-to-check)))) | 249 (setq dirs-to-check (cdr dirs-to-check)))) |
243 (file-error nil))) | 254 (file-error nil))) |
244 | 255 |
245 ) | 256 ) |
246 | 257 |
247 (when (or need-to-rebuild-autoloads | 258 (when (or need-to-rebuild-autoloads |
259 ;; no real need for the following check either, because if the file | |
260 ;; doesn't exist, need-to-rebuild-autoloads gets set above. but | |
261 ;; it's only one call, so it won't slow things down much and it keeps | |
262 ;; the logic cleaner. | |
248 (not (file-exists-p "../lisp/auto-autoloads.el")) | 263 (not (file-exists-p "../lisp/auto-autoloads.el")) |
249 (not (file-exists-p "../lisp/auto-autoloads.elc")) | 264 ;; no need to check for file-exists of .elc due to definition |
265 ;; of file-newer-than-file-p | |
250 (file-newer-than-file-p "../lisp/auto-autoloads.el" | 266 (file-newer-than-file-p "../lisp/auto-autoloads.el" |
251 "../lisp/auto-autoloads.elc")) | 267 "../lisp/auto-autoloads.elc")) |
252 (setq need-to-recompile-autoloads t)) | 268 (setq need-to-recompile-autoloads t)) |
253 | 269 |
254 (when (or need-to-rebuild-mule-autoloads | 270 (when (or need-to-rebuild-mule-autoloads |
271 ;; not necessary but ... see comment above. | |
255 (not (file-exists-p "../lisp/mule/auto-autoloads.el")) | 272 (not (file-exists-p "../lisp/mule/auto-autoloads.el")) |
256 (not (file-exists-p "../lisp/mule/auto-autoloads.elc")) | 273 ;; no need to check for file-exists of .elc due to definition |
274 ;; of file-newer-than-file-p | |
257 (file-newer-than-file-p "../lisp/mule/auto-autoloads.el" | 275 (file-newer-than-file-p "../lisp/mule/auto-autoloads.el" |
258 "../lisp/mule/auto-autoloads.elc")) | 276 "../lisp/mule/auto-autoloads.elc")) |
259 (setq need-to-recompile-mule-autoloads t)) | 277 (setq need-to-recompile-mule-autoloads t)) |
260 | 278 |
261 (when (not (featurep 'mule)) | 279 (when (not (featurep 'mule)) |
283 '("-f" "batch-byte-compile-one-file" | 301 '("-f" "batch-byte-compile-one-file" |
284 "../lisp/auto-autoloads.el")) | 302 "../lisp/auto-autoloads.el")) |
285 (if need-to-recompile-mule-autoloads | 303 (if need-to-recompile-mule-autoloads |
286 '("-f" "batch-byte-compile-one-file" | 304 '("-f" "batch-byte-compile-one-file" |
287 "../lisp/mule/auto-autoloads.el"))))) | 305 "../lisp/mule/auto-autoloads.el"))))) |
306 (condition-case nil | |
307 (delete-file "../src/REBUILD_AUTOLOADS") | |
308 (file-error nil)) | |
288 (cond ((and (not update-elc-files-to-compile) | 309 (cond ((and (not update-elc-files-to-compile) |
289 (not need-to-rebuild-autoloads) | 310 (not need-to-rebuild-autoloads) |
290 (not need-to-rebuild-mule-autoloads) | 311 (not need-to-rebuild-mule-autoloads) |
291 (not need-to-recompile-autoloads) | 312 (not need-to-recompile-autoloads) |
292 (not need-to-recompile-mule-autoloads)) | 313 (not need-to-recompile-mule-autoloads)) |
295 ;; for dump got recompiled, and hence the executable must be | 316 ;; for dump got recompiled, and hence the executable must be |
296 ;; redumped. We remove it if there were no files to compile. | 317 ;; redumped. We remove it if there were no files to compile. |
297 (condition-case nil | 318 (condition-case nil |
298 (delete-file "../src/BYTECOMPILE_CHANGE") | 319 (delete-file "../src/BYTECOMPILE_CHANGE") |
299 (file-error nil))) | 320 (file-error nil))) |
300 ((and (not update-elc-files-to-compile) | 321 ((not update-elc-files-to-compile) |
301 (not dumped-exe-out-of-date-wrt-dump-files) | |
302 (not dumped-exe-out-of-date-wrt-undumped-exe)) | |
303 ;; (2) We have no files to byte-compile, but we do need to | 322 ;; (2) We have no files to byte-compile, but we do need to |
304 ;; regenerate and compile the auto-autoloads file. (This will | 323 ;; regenerate and compile the auto-autoloads file, so signal |
305 ;; be needed to be up-to-date before we run update-elc-2.) | 324 ;; update-elc-2 to do it. This is much faster than loading |
306 ;; If the dumped exe exists and is up-to-date, both with | 325 ;; all the .el's and doing it here. (We only need to rebuild |
307 ;; respect to the undumped exe and the files that will be dumped | 326 ;; the autoloads here when we have files to compile, since |
308 ;; into it, then we can use the dumped exe to rebuild the | 327 ;; they may depend on the updated autoloads.) |
309 ;; autoloads. Else, we have to do it the "hard way" by loading | 328 (condition-case nil |
310 ;; raw temacs, running loadup, then regenerating the autoloads. | 329 (write-region-internal "foo" nil "../src/REBUILD_AUTOLOADS") |
311 ;; #### We should see whether it's possible to load up a | 330 (file-error nil)) |
312 ;; minimal number of files in order to get autoload.el to work. | |
313 (load "raw-process.el") | |
314 (apply 'call-process-internal dumped-exe nil t nil | |
315 (append | |
316 '("-batch -no-autoloads -no-packages") | |
317 do-autoload-commands)) | |
318 (condition-case nil | 331 (condition-case nil |
319 (delete-file "../src/BYTECOMPILE_CHANGE") | 332 (delete-file "../src/BYTECOMPILE_CHANGE") |
320 (file-error nil))) | 333 (file-error nil))) |
321 (t | 334 (t |
322 (let ((bc-bootstrap | 335 (let ((bc-bootstrap |
382 )))) | 395 )))) |
383 | 396 |
384 ;;(print command-line-args) | 397 ;;(print command-line-args) |
385 (load "loadup-el.el")))) | 398 (load "loadup-el.el")))) |
386 | 399 |
387 (kill-emacs) | 400 ;(kill-emacs) |
388 | 401 |
389 ;;; update-elc.el ends here | 402 ;;; update-elc.el ends here |