detect-multiply-used-files.lisp 1.23 KB
Newer Older
1
(uiop:define-package :detect-multiply-used-files
2
  (:nicknames :asdf/contrib/detect-multiply-used-files)
3
  (:use :asdf/component :asdf/system-registry :uiop :common-lisp)
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  (:export #:find-fishy-components #:register-component-files #:*file-components*))

(in-package :detect-multiply-used-files)

(defparameter *file-components* (make-hash-table :test 'equal))

(defun register-component-files (component)
  (let ((c (find-component () component)))
    (if-let (p (component-pathname c))
      (pushnew (component-find-path c) (gethash (namestring p) *file-components*)))
    (when (typep c 'parent-component)
      (dolist (cc (component-children c))
        (register-component-files cc)))))

(defun table-keys (table)
  (loop :for s :being :the :hash-keys :of table :collect s))

(defun find-fishy-components ()
  (clrhash *file-components*)
23
  (map () 'register-component-files (table-keys *registered-systems*))
24 25 26 27 28 29
  (loop :for p :in (sort (table-keys *file-components*) 'string<)
        :for l = (gethash p *file-components*)
        :when (and (file-pathname-p p) (not (length=n-p l 1)))
        :do (format t "~&~S =>~{ ~S~}~%" p l)))

#| ;; Use it like that:
30
(asdf:load-systems system1 system2 ...)
31 32
(detect-multiply-used-files:find-fishy-components)
|#