-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathasdf.lisp
49 lines (42 loc) · 1.82 KB
/
asdf.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
;;;; This is largely structured around the CFFI Groveller:
;;;;
;;;; https://github.com/cffi/cffi/blob/master/grovel/asdf.lisp
;;;;
(in-package :asdf)
(defclass ten-template (source-file)
((type :initform "ten"
:initarg :file-extension)
(package :initform :ten-templates
:initarg :package
:reader template-package)))
(defmethod compiled-template-path ((component ten-template))
(make-pathname :type "lisp"
:defaults (component-pathname component)))
(defmethod output-files (op (component ten-template))
nil)
(defmethod perform ((op compile-op) (component ten-template))
(let ((compiled-template-path (compiled-template-path component)))
(with-open-file (stream compiled-template-path
:direction :output
:if-exists :supersede
:if-does-not-exist :create)
(let* ((parsed (ten/parser:parse-template
(component-pathname component)))
(compiled (ten/compiler:compile-template
parsed
(template-package component)))
;; Need to maintain reference EQuality for uninterned symbols.
(*print-circle* t))
(if (atom (first compiled))
(print compiled stream)
(mapcar (lambda (code)
(print code stream))
compiled))))))
(defmethod perform ((op load-op) (component ten-template))
(let ((compiled-template-path (compiled-template-path component)))
(perform 'load-source-op
(make-instance 'cl-source-file
:name (component-name component)
:parent (component-parent component)
:pathname compiled-template-path))))
(import 'ten-test :asdf)