File: asdf-support.lisp

package info (click to toggle)
cl-asdf-finalizers 20170403-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 104 kB
  • ctags: 46
  • sloc: lisp: 294; makefile: 13
file content (37 lines) | stat: -rw-r--r-- 1,749 bytes parent folder | download | duplicates (3)
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
#+xcvb (module (:depends-on ("finalizers")))

(in-package :asdf-finalizers)

(defun compile-check-finalizers (input-file &rest keys &key &allow-other-keys)
  (declare (ignore keys))
  (let ((okp (no-finalizer-left-behind-p)))
    (unless okp
      (warn 'missing-final-forms
	    :format-control "Source file ~A uses finalizers but fails to ~
             include ~S between the last finalizer and the end of file"
	    :format-arguments `(,input-file (final-forms))))
    okp))

(defun check-finalizers-around-compile (fun)
  "Assuming your system :depends-on (:asdf-finalizers),
  you may use this function as your :around-compile function
  for an ASDF system, module or file, as in
	:around-compile \"asdf-finalizers:check-finalizers-around-compile\"
  This will allow you to use finalizers within covered source files,
  and will issue an error if you fail to evaluate (FINAL-FORMS)
  after the last finalizer was used and before the end of the file.
  Alternatively, you may use ASDF::FINALIZED-CL-SOURCE-FILE below.
  You may also have your own custom :around-compile hooks
  chain into CHECK-FINALIZERS-AROUND-COMPILE
  to achieve the same effect and more."
  (with-finalizers ()
    (funcall fun :compile-check 'compile-check-finalizers)))

(defclass asdf::finalized-cl-source-file (cl-source-file)
  ((around-compile :initform 'check-finalizers-around-compile))
  (:documentation "Assuming your system :defsystem-depends-on (:asdf-finalizers),
  you may use this class as your system's :default-component-class,
  or as the class of a component as in
	(:finalized-cl-source-file \"foo\" :depends-on (\"bar\" \"baz\"))
  This will automatically declare CHECK-FINALIZERS-AROUND-COMPILE
  as the relevant component's :around-compile hook."))