annotate lisp/update-elc.el @ 445:34f3776fcf0e

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