1 | ;;; compile-system.lisp |
---|
2 | ;;; |
---|
3 | ;;; Copyright (C) 2004-2005 Peter Graves |
---|
4 | ;;; $Id: compile-system.lisp,v 1.40 2005-02-01 15:21:09 piso Exp $ |
---|
5 | ;;; |
---|
6 | ;;; This program is free software; you can redistribute it and/or |
---|
7 | ;;; modify it under the terms of the GNU General Public License |
---|
8 | ;;; as published by the Free Software Foundation; either version 2 |
---|
9 | ;;; of the License, or (at your option) any later version. |
---|
10 | ;;; |
---|
11 | ;;; This program is distributed in the hope that it will be useful, |
---|
12 | ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | ;;; GNU General Public License for more details. |
---|
15 | ;;; |
---|
16 | ;;; You should have received a copy of the GNU General Public License |
---|
17 | ;;; along with this program; if not, write to the Free Software |
---|
18 | ;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
19 | |
---|
20 | (in-package #:system) |
---|
21 | |
---|
22 | (require '#:loop) |
---|
23 | (require '#:collect) |
---|
24 | (require '#:jvm) |
---|
25 | |
---|
26 | (defun check-lisp-home () |
---|
27 | (loop |
---|
28 | (cond ((and *lisp-home* |
---|
29 | (probe-directory (pathname *lisp-home*))) |
---|
30 | (return)) |
---|
31 | (t |
---|
32 | (cerror "Continue" |
---|
33 | "*LISP-HOME* is NIL or invalid.~% Please set *LISP-HOME* to the full pathname of the directory containing the Lisp system files."))))) |
---|
34 | |
---|
35 | (defun grovel-java-definitions-in-file (file out) |
---|
36 | (with-open-file (in file) |
---|
37 | (let ((system-package (find-package "SYSTEM")) |
---|
38 | (line-number 1)) |
---|
39 | (loop |
---|
40 | (let ((text (read-line in nil in)) |
---|
41 | position) |
---|
42 | (cond ((eq text in) |
---|
43 | (return)) |
---|
44 | ((setf position (search "###" text)) |
---|
45 | ;; The following code is based on the assumption that all the |
---|
46 | ;; Java builtins are accessible in the SYSTEM package (which |
---|
47 | ;; uses CL and EXT). |
---|
48 | (let* ((name (string (read-from-string (subseq text (+ position 3))))) |
---|
49 | (symbol (find-symbol name system-package))) |
---|
50 | (when symbol |
---|
51 | ;; Force the symbol's package prefix to be written out. |
---|
52 | (let ((*package* +keyword-package+)) |
---|
53 | (format out "~S ~S ~S~%" symbol file line-number)))))) |
---|
54 | (incf line-number)))))) |
---|
55 | |
---|
56 | (defun grovel-java-definitions () |
---|
57 | (check-lisp-home) |
---|
58 | (time |
---|
59 | (let ((files (directory (merge-pathnames "*.java" *lisp-home*)))) |
---|
60 | (with-open-file (stream (merge-pathnames "tags" *lisp-home*) |
---|
61 | :direction :output :if-exists :supersede) |
---|
62 | (dolist (file files) |
---|
63 | (grovel-java-definitions-in-file file stream)))))) |
---|
64 | |
---|
65 | (defun maybe-compile-file (source-file &key force) |
---|
66 | (if force |
---|
67 | (compile-file source-file) |
---|
68 | (let* ((source-write-time (file-write-date source-file)) |
---|
69 | (target-file (compile-file-pathname source-file)) |
---|
70 | (target-write-time (and (probe-file target-file) |
---|
71 | (file-write-date target-file)))) |
---|
72 | (if (or (null target-write-time) |
---|
73 | (<= target-write-time source-write-time)) |
---|
74 | (compile-file source-file) |
---|
75 | target-file)))) |
---|
76 | |
---|
77 | (defun %compile-system () |
---|
78 | (let ((*default-pathname-defaults* (pathname *lisp-home*)) |
---|
79 | (*warn-on-redefinition* nil)) |
---|
80 | (load (maybe-compile-file "precompiler.lisp")) |
---|
81 | (load (maybe-compile-file "source-transform.lisp")) |
---|
82 | (load (maybe-compile-file "opcodes.lisp")) |
---|
83 | (load (maybe-compile-file "jvm.lisp")) |
---|
84 | (load (maybe-compile-file "compile-file.lisp")) |
---|
85 | ;; FIXME We need to load clos.lisp before we can compile clos.lisp. |
---|
86 | (load "clos.lisp") |
---|
87 | ;; Order matters for these files. |
---|
88 | (mapc #'maybe-compile-file '("collect.lisp" |
---|
89 | "macros.lisp" |
---|
90 | "loop.lisp")) |
---|
91 | (load (maybe-compile-file "backquote.lisp")) |
---|
92 | (load (maybe-compile-file "early-defuns.lisp")) |
---|
93 | (load (maybe-compile-file "typep.lisp")) |
---|
94 | (load (maybe-compile-file "find.lisp")) |
---|
95 | (load (maybe-compile-file "print.lisp")) |
---|
96 | (load (maybe-compile-file "pprint-dispatch.lisp")) |
---|
97 | (load (maybe-compile-file "pprint.lisp")) |
---|
98 | (load (maybe-compile-file "format.lisp")) |
---|
99 | (load (maybe-compile-file "delete.lisp")) |
---|
100 | (load (maybe-compile-file "coerce.lisp")) |
---|
101 | (load (maybe-compile-file "concatenate.lisp")) |
---|
102 | (load (maybe-compile-file "make-sequence.lisp")) |
---|
103 | ;; But not for these. |
---|
104 | (mapc #'maybe-compile-file '("adjoin.lisp" |
---|
105 | "and.lisp" |
---|
106 | "apropos.lisp" |
---|
107 | "arrays.lisp" |
---|
108 | "asdf.lisp" |
---|
109 | "assert.lisp" |
---|
110 | "assoc.lisp" |
---|
111 | "autoloads.lisp" |
---|
112 | "aver.lisp" |
---|
113 | ;;"backquote.lisp" |
---|
114 | "bit-array-ops.lisp" |
---|
115 | "boole.lisp" |
---|
116 | ;;"boot.lisp" |
---|
117 | "butlast.lisp" |
---|
118 | "byte-io.lisp" |
---|
119 | "case.lisp" |
---|
120 | "chars.lisp" |
---|
121 | "check-type.lisp" |
---|
122 | "clos.lisp" |
---|
123 | ;;"coerce.lisp" |
---|
124 | ;;"compile-file.lisp" |
---|
125 | "compile-file-pathname.lisp" |
---|
126 | "compiler-macro.lisp" |
---|
127 | ;;"concatenate.lisp" |
---|
128 | "cond.lisp" |
---|
129 | "copy-list.lisp" |
---|
130 | "copy-seq.lisp" |
---|
131 | "copy-symbol.lisp" |
---|
132 | "count.lisp" |
---|
133 | "debug.lisp" |
---|
134 | "define-modify-macro.lisp" |
---|
135 | "define-symbol-macro.lisp" |
---|
136 | "defpackage.lisp" |
---|
137 | ;;"defsetf.lisp" |
---|
138 | "defstruct.lisp" |
---|
139 | "deftype.lisp" |
---|
140 | "delete-duplicates.lisp" |
---|
141 | ;;"delete.lisp" |
---|
142 | "deposit-field.lisp" |
---|
143 | "destructuring-bind.lisp" |
---|
144 | "directory.lisp" |
---|
145 | "do-all-symbols.lisp" |
---|
146 | "do-external-symbols.lisp" |
---|
147 | "do-symbols.lisp" |
---|
148 | "do.lisp" |
---|
149 | "documentation.lisp" |
---|
150 | "dolist.lisp" |
---|
151 | "dotimes.lisp" |
---|
152 | "dribble.lisp" |
---|
153 | "dump-class.lisp" |
---|
154 | ;;"early-defuns.lisp" |
---|
155 | "ed.lisp" |
---|
156 | "enough-namestring.lisp" |
---|
157 | "ensure-directories-exist.lisp" |
---|
158 | "error.lisp" |
---|
159 | "fill.lisp" |
---|
160 | "find-all-symbols.lisp" |
---|
161 | ;;"find.lisp" |
---|
162 | "fixme.lisp" |
---|
163 | "gentemp.lisp" |
---|
164 | "gray-streams.lisp" |
---|
165 | "inspect.lisp" |
---|
166 | ;;"j.lisp" |
---|
167 | "java.lisp" |
---|
168 | "late-setf.lisp" |
---|
169 | "lcm.lisp" |
---|
170 | "ldb.lisp" |
---|
171 | "ldiff.lisp" |
---|
172 | "list-length.lisp" |
---|
173 | "list.lisp" |
---|
174 | "load.lisp" |
---|
175 | "make-hash-table.lisp" |
---|
176 | "make-load-form-saving-slots.lisp" |
---|
177 | ;;"make-sequence.lisp" |
---|
178 | "make-string-output-stream.lisp" |
---|
179 | "make-string.lisp" |
---|
180 | "map-into.lisp" |
---|
181 | "map.lisp" |
---|
182 | "map1.lisp" |
---|
183 | "maphash.lisp" |
---|
184 | "mask-field.lisp" |
---|
185 | "member-if.lisp" |
---|
186 | "mismatch.lisp" |
---|
187 | "multiple-value-bind.lisp" |
---|
188 | "multiple-value-list.lisp" |
---|
189 | "multiple-value-setq.lisp" |
---|
190 | "nsubstitute.lisp" |
---|
191 | "nth-value.lisp" |
---|
192 | "numbers.lisp" |
---|
193 | "open.lisp" |
---|
194 | "or.lisp" |
---|
195 | "parse-integer.lisp" |
---|
196 | "parse-lambda-list.lisp" |
---|
197 | "parse-namestring.lisp" |
---|
198 | "pathnames.lisp" |
---|
199 | ;;"print.lisp" |
---|
200 | ;;"print-object.lisp" |
---|
201 | "print-unreadable-object.lisp" |
---|
202 | "profiler.lisp" |
---|
203 | "prog.lisp" |
---|
204 | "psetf.lisp" |
---|
205 | "query.lisp" |
---|
206 | "read-sequence.lisp" |
---|
207 | "reduce.lisp" |
---|
208 | "remf.lisp" |
---|
209 | "remove-duplicates.lisp" |
---|
210 | "remove.lisp" |
---|
211 | "replace.lisp" |
---|
212 | "restart.lisp" |
---|
213 | "revappend.lisp" |
---|
214 | "rotatef.lisp" |
---|
215 | ;;"rt.lisp" |
---|
216 | ;;"run-benchmarks.lisp" |
---|
217 | "run-shell-command.lisp" |
---|
218 | ;;"runtime-class.lisp" |
---|
219 | "search.lisp" |
---|
220 | "sequences.lisp" |
---|
221 | "setf.lisp" |
---|
222 | "sets.lisp" |
---|
223 | "shiftf.lisp" |
---|
224 | "signal.lisp" |
---|
225 | "socket.lisp" |
---|
226 | "sort.lisp" |
---|
227 | "step.lisp" |
---|
228 | "strings.lisp" |
---|
229 | "sublis.lisp" |
---|
230 | "subst.lisp" |
---|
231 | "substitute.lisp" |
---|
232 | "subtypep.lisp" |
---|
233 | "tailp.lisp" |
---|
234 | "time.lisp" |
---|
235 | "top-level.lisp" |
---|
236 | "trace.lisp" |
---|
237 | "translate-logical-pathname.lisp" |
---|
238 | "tree-equal.lisp" |
---|
239 | ;;"typep.lisp" |
---|
240 | "upgraded-complex-part-type.lisp" |
---|
241 | "with-accessors.lisp" |
---|
242 | "with-hash-table-iterator.lisp" |
---|
243 | "with-input-from-string.lisp" |
---|
244 | "with-open-file.lisp" |
---|
245 | "with-output-to-string.lisp" |
---|
246 | "with-package-iterator.lisp" |
---|
247 | "with-slots.lisp" |
---|
248 | "with-standard-io-syntax.lisp" |
---|
249 | "with-thread-lock.lisp" |
---|
250 | "write-sequence.lisp")) |
---|
251 | (mapc #'maybe-compile-file '("swank-protocol.lisp" |
---|
252 | "slime.lisp" |
---|
253 | "swank-abcl.lisp" |
---|
254 | "swank.lisp")) |
---|
255 | t)) |
---|
256 | |
---|
257 | (defun compile-system () |
---|
258 | (check-lisp-home) |
---|
259 | (time |
---|
260 | (with-compilation-unit () |
---|
261 | (%compile-system)))) |
---|