Skip to content

Instantly share code, notes, and snippets.

@windymelt
Created January 14, 2020 09:39
Show Gist options
  • Save windymelt/655de5ccec4e08a161d4c7a8f1870b72 to your computer and use it in GitHub Desktop.
Save windymelt/655de5ccec4e08a161d4c7a8f1870b72 to your computer and use it in GitHub Desktop.
provides package which links to all files under the named directory
;;; inside your ASD file
(in-package :cl-user)
(defpackage foo-asd
(:use :cl :asdf)
(:export :define-dependency-aggregator-package))
(in-package :foo-asd)
(ql:quickload :alexandria)
(defparameter *dependency-source-dir* (merge-pathnames #P"src/" (uiop:getcwd)))
(defun define-dependency-aggregator-package (name)
(let ((file-names-without-ext
(mapcar #'pathname-name
(uiop:directory-files
(merge-pathnames (pathname (format nil "~A/" (string-downcase (subseq (symbol-name name) (1+ (position #\/ (symbol-name name) :from-end t)))))) *dependency-source-dir*)))))
`(defpackage ,name
(:use :cl)
,@(mapcar #'(lambda (f) (list :import-from (alexandria:make-keyword (string-upcase (format nil "~A/~A" name f))))) file-names-without-ext))))
(in-package :cl-user)
#.(foo-asd:define-dependency-aggregator-package :foo/features)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment