comparison lisp/update-elc.el @ 442:abe6d1db359e r21-2-36

Import from CVS: tag r21-2-36
author cvs
date Mon, 13 Aug 2007 11:35:02 +0200
parents 3ecd8885ac67
children 5bdbc721d46a
comparison
equal deleted inserted replaced
441:72a7cfa4a488 442:abe6d1db359e
1 ;;; update-elc.el --- Bytecompile out-of-date dumped files 1 ;;; update-elc.el --- Bytecompile out-of-date dumped files
2 2
3 ;; Copyright (C) 1997 Free Software Foundation, Inc. 3 ;; Copyright (C) 1997 Free Software Foundation, Inc.
4 ;; Copyright (C) 1996 Unknown 4 ;; Copyright (C) 1996 Sun Microsystems, Inc.
5 5
6 ;; Author: Ben Wing <ben@xemacs.org>, Steven L Baur <steve@xemacs.org>
6 ;; Maintainer: XEmacs Development Team 7 ;; Maintainer: XEmacs Development Team
7 ;; Keywords: internal 8 ;; Keywords: internal
8 9
9 ;; This file is part of XEmacs. 10 ;; This file is part of XEmacs.
10 11
37 ;; $lisp will be ignored. 38 ;; $lisp will be ignored.
38 39
39 ;; (the idea here is that you can bootstrap if your .ELC files 40 ;; (the idea here is that you can bootstrap if your .ELC files
40 ;; are missing or badly out-of-date) 41 ;; are missing or badly out-of-date)
41 42
42 ;; Currently this code gets the list of files to check passed to it from 43 ;; See also update-elc-2.el
43 ;; src/Makefile. This must be fixed. -slb
44 44
45 ;;; Code: 45 ;;; Code:
46 46
47 (defvar processed nil) 47 (defvar processed nil)
48 (defvar update-elc-files-to-compile nil) 48 (defvar update-elc-files-to-compile nil)
60 ; (set-file-modes x (logior (file-modes x) 128))) 60 ; (set-file-modes x (logior (file-modes x) 128)))
61 ; src)))))) 61 ; src))))))
62 ; ;; -batch gets filtered out. 62 ; ;; -batch gets filtered out.
63 ; (nthcdr 3 command-line-args)))) 63 ; (nthcdr 3 command-line-args))))
64 64
65 (setq load-path (split-path (getenv "EMACSBOOTSTRAPLOADPATH"))) 65 (let ((build-root (expand-file-name ".." invocation-directory)))
66 (setq load-path (list (expand-file-name "lisp" build-root))))
66 67
67 (load "very-early-lisp" nil t) 68 (load "very-early-lisp" nil t)
68 69
69 (load "find-paths.el") 70 (load "find-paths.el")
70 (load "packages.el") 71 (load "packages.el")
81 (cons src update-elc-files-to-compile)))) 82 (cons src update-elc-files-to-compile))))
82 (setq autol (cdr autol)))) 83 (setq autol (cdr autol))))
83 84
84 ;; (print (prin1-to-string update-elc-files-to-compile)) 85 ;; (print (prin1-to-string update-elc-files-to-compile))
85 86
86 (let (preloaded-file-list site-load-packages) 87 (let (preloaded-file-list site-load-packages need-to-dump dumped-exe)
87 (load (expand-file-name "../lisp/dumped-lisp.el")) 88 (load (expand-file-name "../lisp/dumped-lisp.el"))
89
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)))
88 94
89 ;; Path setup 95 ;; Path setup
90 (let ((package-preloaded-file-list 96 (let ((package-preloaded-file-list
91 (packages-collect-package-dumped-lisps late-package-load-path))) 97 (packages-collect-package-dumped-lisps late-package-load-path)))
92 98
93 (setq preloaded-file-list 99 (setq preloaded-file-list
94 (append package-preloaded-file-list 100 (append package-preloaded-file-list
95 preloaded-file-list 101 preloaded-file-list
102 '("bytecomp")
96 packages-hardcoded-lisp))) 103 packages-hardcoded-lisp)))
97 104
98 (load (concat default-directory "../site-packages") t t) 105 (load (concat default-directory "../site-packages") t t)
99 (setq preloaded-file-list 106 (setq preloaded-file-list
100 (append packages-hardcoded-lisp 107 (append packages-hardcoded-lisp
102 packages-useful-lisp 109 packages-useful-lisp
103 site-load-packages)) 110 site-load-packages))
104 (while preloaded-file-list 111 (while preloaded-file-list
105 (let ((arg (car preloaded-file-list))) 112 (let ((arg (car preloaded-file-list)))
106 ;; (print (prin1-to-string arg)) 113 ;; (print (prin1-to-string arg))
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
107 (if (null (member (file-name-nondirectory arg) 134 (if (null (member (file-name-nondirectory arg)
108 packages-unbytecompiled-lisp)) 135 packages-unbytecompiled-lisp))
109 (progn 136 (progn
110 (setq arg (locate-library arg)) 137 (setq arg (locate-library arg))
111 (if (null arg) 138 (if (null arg)
121 (if (and (null (member arg processed)) 148 (if (and (null (member arg processed))
122 (file-exists-p (concat arg ".el")) 149 (file-exists-p (concat arg ".el"))
123 (file-newer-than-file-p (concat arg ".el") 150 (file-newer-than-file-p (concat arg ".el")
124 (concat arg ".elc"))) 151 (concat arg ".elc")))
125 (setq processed (cons (concat arg ".el") processed))))) 152 (setq processed (cons (concat arg ".el") processed)))))
126 (setq preloaded-file-list (cdr preloaded-file-list))))) 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 )
127 161
128 (setq update-elc-files-to-compile (append update-elc-files-to-compile 162 (setq update-elc-files-to-compile (append update-elc-files-to-compile
129 processed)) 163 processed))
130 164
131 ;; (print (prin1-to-string update-elc-files-to-compile)) 165 ;; (print (prin1-to-string update-elc-files-to-compile))
137 "-batch" "-q" "-no-site-file" 171 "-batch" "-q" "-no-site-file"
138 "-l" "bytecomp" "-f" "batch-byte-compile") 172 "-l" "bytecomp" "-f" "batch-byte-compile")
139 update-elc-files-to-compile)) 173 update-elc-files-to-compile))
140 (load "loadup-el.el")) 174 (load "loadup-el.el"))
141 (condition-case nil 175 (condition-case nil
142 (delete-file "./NOBYTECOMPILE") 176 (delete-file "../src/NOBYTECOMPILE")
143 (file-error nil))) 177 (file-error nil)))
144 178
145 (kill-emacs) 179 (kill-emacs)
146 180
147 ;;; update-elc.el ends here 181 ;;; update-elc.el ends here