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