From f6c0f8b9ed37f672c7fc17ab7c3292c03f27e011 Mon Sep 17 00:00:00 2001 From: Francois-Rene Rideau <tunes@google.com> Date: Sun, 17 Mar 2013 19:41:42 -0400 Subject: [PATCH] Add a new contrib, detect-multiply-used-files. --- contrib/detect-multiply-used-files.lisp | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 contrib/detect-multiply-used-files.lisp diff --git a/contrib/detect-multiply-used-files.lisp b/contrib/detect-multiply-used-files.lisp new file mode 100644 index 00000000..a8f0909f --- /dev/null +++ b/contrib/detect-multiply-used-files.lisp @@ -0,0 +1,30 @@ +(uiop:define-package :detect-multiply-used-files + (:use :asdf :uiop :common-lisp) + (: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*) + (map () 'register-component-files (table-keys asdf::*defined-systems*)) + (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: +(detect-multiply-used-files:find-fishy-components) +|# -- GitLab