/[slime]/slime/swank-loader.lisp
ViewVC logotype

Contents of /slime/swank-loader.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (show annotations)
Fri Dec 12 03:22:36 2003 UTC (10 years, 4 months ago) by dbarlow
Branch: MAIN
Changes since 1.7: +3 -3 lines
	* swank-source-path-parser.lisp: new file, excerpting part of
	swank-cmucl.lisp to where SBCL can find it as well.
1 ;;;; -*- Mode: lisp; indent-tabs-mode: nil -*-
2 ;;;
3 ;;; swank-loader.lisp --- Compile and load the Slime backend.
4 ;;;
5 ;;; Created 2003, James Bielman <jamesjb@jamesjb.com>
6 ;;;
7 ;;; This code has been placed in the Public Domain. All warranties
8 ;;; are disclaimed.
9 ;;;
10 ;;; $Id: swank-loader.lisp,v 1.8 2003/12/12 03:22:36 dbarlow Exp $
11 ;;;
12
13 (defpackage :swank-loader
14 (:use :common-lisp))
15
16 (in-package :swank-loader)
17
18 (defun make-swank-pathname (name &optional (type "lisp"))
19 "Return a pathname with name component NAME in the Slime directory."
20 (merge-pathnames name
21 (make-pathname
22 :type type
23 :directory
24 (pathname-directory
25 (or *compile-file-pathname* *load-pathname*
26 *default-pathname-defaults*)))))
27
28 (defparameter *sysdep-pathnames*
29 (mapcar #'make-swank-pathname
30 #+cmu '("swank-cmucl" "swank-source-path-parser")
31 #+sbcl '("swank-sbcl" "swank-source-path-parser" "swank-gray")
32 #+openmcl '("swank-openmcl" "swank-gray")
33 #+lispworks '("swank-lispworks" "swank-gray")
34 #+allegro '("swank-allegro" "swank-gray")
35 ))
36
37 (defparameter *swank-pathname* (make-swank-pathname "swank"))
38
39 (defun file-newer-p (new-file old-file)
40 "Returns true if NEW-FILE is newer than OLD-FILE."
41 (> (file-write-date new-file) (file-write-date old-file)))
42
43 (defun compile-files-if-needed-serially (files)
44 "Compile each file in FILES if the source is newer than
45 its corresponding binary, or the file preceding it was
46 recompiled."
47 (with-compilation-unit ()
48 (let ((needs-recompile nil))
49 (dolist (source-pathname files)
50 (let ((binary-pathname (compile-file-pathname source-pathname)))
51 (handler-case
52 (progn
53 (when (or needs-recompile
54 (not (probe-file binary-pathname))
55 (file-newer-p source-pathname binary-pathname))
56 (format t "~&;; Compiling ~A...~%" source-pathname)
57 (compile-file source-pathname)
58 (setq needs-recompile t))
59 (load binary-pathname))
60 (error ()
61 ;; If an error occurs compiling, load the source instead
62 ;; so we can try to debug it.
63 (load source-pathname))))))))
64
65 (defun user-init-file ()
66 "Return the name of the user init file or nil."
67 (let ((filename (format nil "~A/.swank.lisp"
68 (namestring (translate-logical-pathname
69 (user-homedir-pathname))))))
70 (cond ((probe-file filename) filename)
71 (t nil))))
72
73 (compile-files-if-needed-serially
74 (list* (make-swank-pathname "swank-backend") *swank-pathname*
75 *sysdep-pathnames*))
76
77 (when (user-init-file)
78 (load (user-init-file)))
79

  ViewVC Help
Powered by ViewVC 1.1.5