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