428
|
1 ;;; update-elc.el --- Bytecompile out-of-date dumped files
|
|
2
|
|
3 ;; Copyright (C) 1997 Free Software Foundation, Inc.
|
442
|
4 ;; Copyright (C) 1996 Sun Microsystems, Inc.
|
528
|
5 ;; Copyright (C) 2001 Ben Wing.
|
428
|
6
|
528
|
7 ;; Author: Ben Wing <ben@xemacs.org>
|
|
8 ;; Based On: Original by Steven L Baur <steve@xemacs.org>
|
428
|
9 ;; Maintainer: XEmacs Development Team
|
|
10 ;; Keywords: internal
|
|
11
|
|
12 ;; This file is part of XEmacs.
|
|
13
|
|
14 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
15 ;; under the terms of the GNU General Public License as published by
|
|
16 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
17 ;; any later version.
|
|
18
|
|
19 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
20 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
22 ;; General Public License for more details.
|
|
23
|
|
24 ;; You should have received a copy of the GNU General Public License
|
|
25 ;; along with XEmacs; see the file COPYING. If not, write to the
|
|
26 ;; Free Software Foundation, 59 Temple Place - Suite 330,
|
|
27 ;; Boston, MA 02111-1307, USA.
|
|
28
|
|
29 ;;; Synched up with: Not in FSF.
|
|
30
|
|
31 ;;; Commentary:
|
|
32
|
|
33 ;; Byte compile the .EL files necessary to dump out xemacs.
|
|
34 ;; Use this file like this:
|
|
35
|
|
36 ;; temacs -batch -l ../lisp/update-elc.el $lisp
|
|
37
|
|
38 ;; where $lisp comes from the Makefile. .elc files listed in $lisp will
|
|
39 ;; cause the corresponding .el file to be compiled. .el files listed in
|
|
40 ;; $lisp will be ignored.
|
|
41
|
|
42 ;; (the idea here is that you can bootstrap if your .ELC files
|
|
43 ;; are missing or badly out-of-date)
|
|
44
|
442
|
45 ;; See also update-elc-2.el
|
428
|
46
|
|
47 ;;; Code:
|
|
48
|
|
49 (defvar processed nil)
|
|
50 (defvar update-elc-files-to-compile nil)
|
528
|
51 (defvar need-to-rebuild-autoloads nil)
|
|
52 (defvar need-to-rebuild-mule-autoloads nil)
|
|
53 (defvar need-to-recompile-autoloads nil)
|
|
54 (defvar need-to-recompile-mule-autoloads nil)
|
428
|
55
|
|
56 ;(setq update-elc-files-to-compile
|
|
57 ; (delq nil
|
|
58 ; (mapcar (function
|
|
59 ; (lambda (x)
|
|
60 ; (if (string-match "\.elc$" x)
|
|
61 ; (let ((src (substring x 0 -1)))
|
|
62 ; (if (file-newer-than-file-p src x)
|
|
63 ; (progn
|
|
64 ; (and (file-exists-p x)
|
|
65 ; (null (file-writable-p x))
|
|
66 ; (set-file-modes x (logior (file-modes x) 128)))
|
|
67 ; src))))))
|
|
68 ; ;; -batch gets filtered out.
|
|
69 ; (nthcdr 3 command-line-args))))
|
|
70
|
442
|
71 (let ((build-root (expand-file-name ".." invocation-directory)))
|
|
72 (setq load-path (list (expand-file-name "lisp" build-root))))
|
428
|
73
|
|
74 (load "very-early-lisp" nil t)
|
|
75
|
|
76 (load "find-paths.el")
|
|
77 (load "packages.el")
|
|
78 (load "setup-paths.el")
|
|
79 (load "dump-paths.el")
|
|
80
|
528
|
81 (defun update-elc-chop-extension (file)
|
|
82 (if (string-match "\\.elc?$" file)
|
|
83 (substring file 0 (match-beginning 0))
|
|
84 file))
|
428
|
85
|
528
|
86 ;; we used to call packages-list-autoloads here, but it's false generality.
|
|
87 ;; we need to handle each autoload file differently and there are only
|
|
88 ;; two of them.
|
428
|
89
|
528
|
90 (let (preloaded-file-list site-load-packages need-to-dump dumped-exe
|
|
91 files-to-process)
|
|
92
|
428
|
93 (load (expand-file-name "../lisp/dumped-lisp.el"))
|
|
94
|
442
|
95 (setq dumped-exe
|
|
96 (cond ((file-exists-p "../src/xemacs.exe") "../src/xemacs.exe")
|
|
97 ((file-exists-p "../src/xemacs") "../src/xemacs")
|
|
98 (t nil)))
|
|
99
|
428
|
100 ;; Path setup
|
|
101 (let ((package-preloaded-file-list
|
|
102 (packages-collect-package-dumped-lisps late-package-load-path)))
|
|
103
|
|
104 (setq preloaded-file-list
|
|
105 (append package-preloaded-file-list
|
|
106 preloaded-file-list
|
|
107 packages-hardcoded-lisp)))
|
|
108
|
|
109 (load (concat default-directory "../site-packages") t t)
|
|
110 (setq preloaded-file-list
|
|
111 (append packages-hardcoded-lisp
|
|
112 preloaded-file-list
|
|
113 site-load-packages))
|
528
|
114 ;; bytecomp, byte-optimize, and autoload are mentioned in
|
|
115 ;; packages-useful-lisp.
|
|
116 (setq files-to-process (append packages-useful-lisp preloaded-file-list))
|
|
117 (while files-to-process
|
|
118 (let* ((arg (car files-to-process))
|
|
119 (arg-is-preloaded (member arg preloaded-file-list))
|
|
120 (arg-sans-extension (update-elc-chop-extension arg))
|
|
121 (full-arg (locate-library arg-sans-extension))
|
|
122 (full-arg-sans-extension
|
|
123 (if (null full-arg)
|
|
124 (progn
|
|
125 (print (format "Error: Library file %s not found" arg))
|
|
126 ;; Uncomment in case of trouble
|
|
127 ;;(print (format "late-packages: %S" late-packages))
|
|
128 ;;(print (format "guessed-roots: %S"
|
|
129 ;; (paths-find-emacs-roots
|
|
130 ;; invocation-directory invocation-name)))
|
|
131 (kill-emacs))
|
|
132 (update-elc-chop-extension full-arg)))
|
|
133 (full-arg-el (concat full-arg-sans-extension ".el"))
|
|
134 (full-arg-elc (concat full-arg-sans-extension ".elc"))
|
|
135 (full-arg-dir (file-name-directory full-arg-el))
|
|
136 (autoload-file (expand-file-name "auto-autoloads.el" full-arg-dir))
|
|
137 (autoload-is-mule (string-match "[/\\]mule[/\\]$" full-arg-dir)))
|
|
138
|
|
139 ;; (print full-arg-el)
|
442
|
140
|
|
141 ;; now check if .el or .elc is newer than the dumped exe.
|
|
142 ;; if so, need to redump.
|
528
|
143 (when (and dumped-exe arg-is-preloaded
|
|
144 (or (and (file-exists-p full-arg-el)
|
|
145 (file-newer-than-file-p full-arg-el dumped-exe))
|
|
146 (and (file-exists-p full-arg-elc)
|
|
147 (file-newer-than-file-p full-arg-elc dumped-exe))))
|
|
148 (setq need-to-dump t))
|
442
|
149
|
528
|
150 (when (or (not (file-exists-p autoload-file))
|
|
151 (and (file-exists-p full-arg-el)
|
|
152 (file-newer-than-file-p full-arg-el autoload-file)))
|
|
153 (if autoload-is-mule
|
|
154 (setq need-to-rebuild-mule-autoloads t)
|
|
155 (setq need-to-rebuild-autoloads t)))
|
|
156
|
|
157 (if (and (not (member (file-name-nondirectory arg)
|
|
158 packages-unbytecompiled-lisp))
|
|
159 (not (member full-arg-el processed))
|
|
160 (file-exists-p full-arg-el)
|
|
161 (or (not (file-exists-p full-arg-elc))
|
|
162 (file-newer-than-file-p full-arg-el full-arg-elc)))
|
|
163 (setq processed (cons full-arg-el processed)))
|
|
164
|
|
165 (setq files-to-process (cdr files-to-process))))
|
442
|
166
|
|
167 (if need-to-dump
|
|
168 (condition-case nil
|
|
169 (write-region-internal "foo" nil "../src/NEEDTODUMP")
|
|
170 (file-error nil)))
|
|
171
|
|
172 )
|
428
|
173
|
528
|
174 (when (or need-to-rebuild-autoloads
|
|
175 (not (file-exists-p "../lisp/auto-autoloads.el"))
|
|
176 (not (file-exists-p "../lisp/auto-autoloads.elc"))
|
|
177 (file-newer-than-file-p "../lisp/auto-autoloads.el"
|
|
178 "../lisp/auto-autoloads.elc"))
|
|
179 (setq need-to-recompile-autoloads t))
|
|
180
|
|
181 (when (or need-to-rebuild-mule-autoloads
|
|
182 (not (file-exists-p "../lisp/mule/auto-autoloads.el"))
|
|
183 (not (file-exists-p "../lisp/mule/auto-autoloads.elc"))
|
|
184 (file-newer-than-file-p "../lisp/mule/auto-autoloads.el"
|
|
185 "../lisp/mule/auto-autoloads.elc"))
|
|
186 (setq need-to-recompile-mule-autoloads t))
|
|
187
|
|
188 (when (not (featurep 'mule))
|
|
189 ;; sorry charlie.
|
|
190 (setq need-to-rebuild-mule-autoloads nil
|
|
191 need-to-recompile-mule-autoloads nil))
|
|
192
|
428
|
193 (setq update-elc-files-to-compile (append update-elc-files-to-compile
|
|
194 processed))
|
|
195
|
528
|
196 ;; (print update-elc-files-to-compile)
|
428
|
197
|
528
|
198 (if (and (not update-elc-files-to-compile)
|
|
199 (not need-to-rebuild-autoloads)
|
|
200 (not need-to-rebuild-mule-autoloads)
|
|
201 (not need-to-recompile-autoloads)
|
|
202 (not need-to-recompile-mule-autoloads))
|
|
203 (condition-case nil
|
|
204 (delete-file "../src/NOBYTECOMPILE")
|
|
205 (file-error nil))
|
|
206 (let* (
|
|
207 (bytecomp-arg (concat (update-elc-chop-extension
|
|
208 (locate-library "bytecomp")) ".el"))
|
|
209 (byte-opt-arg (concat (update-elc-chop-extension
|
|
210 (locate-library "byte-optimize")) ".el"))
|
|
211 (autoload-arg (concat (update-elc-chop-extension
|
|
212 (locate-library "autoload")) ".el"))
|
|
213 )
|
|
214 (setq inhibit-autoloads t)
|
|
215 (setq command-line-args
|
|
216 (append
|
|
217 '("-l" "loadup-el.el" "run-temacs" "-batch" "-q" "-no-site-file")
|
|
218 ;; if bytecomp or byte-optimize need recompiling, then load
|
|
219 ;; the .el version of them first, recompile them, and reload
|
|
220 ;; the .elc versions to recompile everything else (so we won't
|
|
221 ;; be waiting until the cows come home). we need to set
|
|
222 ;; load-ignore-elc-files because byte-optimize gets autoloaded
|
|
223 ;; from bytecomp.
|
|
224 (if (or (member bytecomp-arg update-elc-files-to-compile)
|
|
225 (member byte-opt-arg update-elc-files-to-compile))
|
|
226 (append
|
|
227 '("-eval" "(setq load-ignore-elc-files t)" "-l" "bytecomp")
|
|
228 (if (member bytecomp-arg update-elc-files-to-compile)
|
|
229 (append '("-f" "batch-byte-compile-one-file")
|
|
230 (list bytecomp-arg)))
|
|
231 (if (member byte-opt-arg update-elc-files-to-compile)
|
|
232 (append '("-f" "batch-byte-compile-one-file")
|
|
233 (list byte-opt-arg)))
|
|
234 '("-eval" "(setq load-ignore-elc-files nil)")))
|
|
235 '("-l" "bytecomp")
|
|
236 ;; likewise, recompile autoload.el if out-of-date.
|
|
237 (if (member autoload-arg update-elc-files-to-compile)
|
|
238 (append '("-f" "batch-byte-compile-one-file")
|
|
239 (list autoload-arg)))
|
|
240 ;; then generate autoloads for lisp and maybe lisp/mule.
|
|
241 (if (or need-to-rebuild-autoloads
|
|
242 need-to-rebuild-mule-autoloads)
|
|
243 '("-l" "autoload"))
|
|
244 (if need-to-rebuild-autoloads
|
|
245 '("-f" "batch-force-update-one-directory" "../lisp"))
|
|
246 (if need-to-rebuild-mule-autoloads
|
|
247 '("-f" "batch-force-update-one-directory" "../lisp/mule"))
|
|
248 (if need-to-recompile-autoloads
|
|
249 '("-f" "batch-byte-compile-one-file"
|
|
250 "../lisp/auto-autoloads.el"))
|
|
251 (if need-to-recompile-mule-autoloads
|
|
252 '("-f" "batch-byte-compile-one-file"
|
|
253 "../lisp/mule/auto-autoloads.el"))
|
|
254 ;; now load the autoloads and compile alles anderes.
|
|
255 '("-eval" "(setq inhibit-autoloads nil)"
|
|
256 "-f" "startup-load-autoloads"
|
|
257 "-f" "batch-byte-compile")
|
|
258 (delete autoload-arg
|
|
259 (delete byte-opt-arg
|
|
260 (delete bytecomp-arg
|
|
261 update-elc-files-to-compile))))))
|
|
262 (load "loadup-el.el"))
|
428
|
263
|
|
264 (kill-emacs)
|
|
265
|
|
266 ;;; update-elc.el ends here
|