-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathsbcl-init.lisp
88 lines (72 loc) · 2.46 KB
/
sbcl-init.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
(require 'sb-posix)
;;; Define Portacle system support package
(defpackage #:portacle
(:use #:cl)
(:shadow
#:load)
(:export
#:*platform*
#:*binary*
#:*root*
#:find-root
#:path
#:load))
(in-package #:portacle)
(defvar *platform*
#+linux "lin"
#+win32 "win"
#+darwin "mac")
(defvar *binary*
(make-pathname :name NIL :type NIL :defaults (first sb-ext:*posix-argv*)))
(defun find-root (&optional (source *binary*))
(let ((dir (make-pathname :name NIL :type NIL :defaults source)))
(labels ((try (dir)
(cond ((probe-file (make-pathname :name ".portacle_root" :defaults dir))
dir)
((rest (pathname-directory dir))
(try (make-pathname :directory (butlast (pathname-directory dir)) :defaults dir)))
(T
(warn "Failed to find the Portacle root directory!")
*binary*))))
(try dir))))
(defvar *root*
(let ((envvar (sb-posix:getenv "ROOT")))
(if envvar
(sb-ext:parse-native-namestring envvar)
(find-root))))
(defun path (file &optional (platform *platform*))
(merge-pathnames (format NIL "~@[~a/~]~a" platform file) *root*))
(defun load (file &optional (platform *platform*))
(let ((file (path file platform)))
(when (probe-file file) (cl:load file))))
;;; Configure the system for Portacle.
(in-package #:cl-user)
;; Fix up the source locations
(sb-ext:set-sbcl-source-location (portacle:path "sbcl/share/src/"))
;; Load ASDF
#-asdf3
(or (portacle:load "asdf/asdf.fasl")
(portacle:load "asdf/asdf.lisp")
(warn "Failed to load ASDF."))
;; Fix up the ASDF cache location
#+asdf3
(setf asdf:*user-cache*
(merge-pathnames (format NIL "~a-~a-~a-~a/"
(lisp-implementation-type)
(lisp-implementation-version)
(software-type)
(machine-type))
(portacle:path "asdf/cache/")))
;; Load quicklisp
#-quicklisp
(or (portacle:load "quicklisp/setup.lisp" "all")
(warn "Failed to load quicklisp."))
;; Add the project folder to Quicklisp's local-projects directories.
#+quicklisp
(pushnew (portacle:path "projects/" NIL) ql:*local-project-directories*)
;; Ensure our d-p-d is sane
(setf *default-pathname-defaults* portacle:*root*)
;; Load user file if it exists
(portacle:load "config/user.lisp" NIL)
;; All set.
(push :portacle *features*)