wild-modules.lisp 1.46 KB
Newer Older
Rahul Jain's avatar
 
Rahul Jain committed
1 2 3 4 5 6 7 8
(in-package :asdf)

(defclass wild-module (module)
  ((component-class :accessor wild-module-component-class
                    :initform 'static-file :initarg :component-class)
   (component-options :accessor wild-module-component-options
                      :initform nil :initarg :component-options)))

9
(defmethod (setf component-children) (new-value (module wild-module))
10 11
  (when new-value
    (sysdef-error "Cannot explicitly set wild-module ~A's children components. Please ~
12
use a wild pathname instead." module)))
Rahul Jain's avatar
 
Rahul Jain committed
13 14

(defmethod reinitialize-instance :after ((self wild-module) &key)
15 16 17 18
  (let ((pathname (component-pathname self)))
    (unless (and pathname (wild-pathname-p pathname))
      (sysdef-error "Wild-module ~A specified with non-wild pathname ~A."
                    self pathname))
Rahul Jain's avatar
 
Rahul Jain committed
19
    (setf (slot-value self 'components)
20
          (let* ((files (directory* pathname))
Rahul Jain's avatar
 
Rahul Jain committed
21 22 23 24
                 (class (wild-module-component-class self))
                 (options (wild-module-component-options self)))
            (mapcar (lambda (file)
                      (apply #'make-instance class
25
                             :name (namestring file)
Rahul Jain's avatar
 
Rahul Jain committed
26 27 28
                             :pathname file
                             :parent self
                             options))
29
                    files)))
30
    (compute-children-by-name self)
31
    (values)))
Rahul Jain's avatar
 
Rahul Jain committed
32

33 34 35
(defmethod input-files ((o compile-op) (c wild-module)) ())
(defmethod input-files ((o load-op) (c wild-module)) ())

36
(export 'wild-module)