Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

Latest commit

 

History

History
96 lines (80 loc) · 4.32 KB

README.org

File metadata and controls

96 lines (80 loc) · 4.32 KB

(#| TMPL_VAR name |#)

This repository is a template for the pattern of libraries that emerged in Atlas Engineer (see nkeymaps, ndebug, nfiles for manifestations of this pattern). It saves some hour of repository set up and is as easy to use as

;; In your REPL.
(ql:quickload :quickproject)
;; IMPORTANT: Delete the .git directory to not break Quickproject copying.
;; FIXME: Make Quickproject ignore the .git directory.
(delete-directory #p"/path/to/ntemplate/.git/" :recursive t)
;; Finally, create the project based on a template.
(quickproject:make-project
 #p"/path/to/your/lib/"
 :template-directory #p"/path/to/ntemplate/"
 :author "Atlas Engineer LLC"
 :license "BSD-3 Clause")

To add submodules to the repository, you can leverage the Guix definition. This only works for packages using a git-reference as source:

(mapcar #'asdf:load-system '(:alexandria :serapeum :ospm :log4cl))
(defvar *git-program* "git")

(flet ((fetch-git-modules (local-repository &rest packages)
         "LOCAL-REPOSITORY is the path to the Git repository where to add the submodules.
PACKAGES are the Guix packages corresponding to the submodules to fetch.

Return 2 values:
- the list of inputs with a Git reference;
- the list of inputs without a Git reference; you will have to add these submodules manually."
         (labels ((repo-url-name (url)
                    (let ((pos (search "/" url :from-end t :end2 (1- (length url)))))
                      (serapeum:string-replace-all "/" (subseq url pos) "")))
                  (sbcl-recursive-inputs (pkg)
                    (let ((pkgs (mapcar (alexandria:compose #'first #'ospm:find-os-packages)
                                        (remove-if-not (lambda (input) (serapeum:string-prefix-p "sbcl-" input))
                                                       (ospm:inputs pkg)))))
                      (cons pkg
                            (alexandria:mappend #'sbcl-recursive-inputs pkgs)))))
           (multiple-value-bind (git-inputs non-git-inputs)
               (serapeum:partition (alexandria:compose #'ospm::guix-package-source-git-reference-p #'ospm:source)
                                   (delete-duplicates (alexandria:mappend
                                                       (lambda (pkg-name)
                                                         (sbcl-recursive-inputs (first (or (ospm:find-os-packages pkg-name)
                                                                                           (error "Package ~a not found" pkg-name)))))
                                                       packages)))
             (mapc (lambda (url)
                     (let ((target (uiop:strcat "_build/" (repo-url-name url))))
                       (uiop:with-current-directory (local-repository)
                         (if (uiop:directory-exists-p target)
                             (log:info "~s already exists" target)
                             (let ((cmd `(,*git-program* "submodule" "add" ,url ,target)))
                               (format t "~&~{~a~,^ ~}~&" cmd)
                               (uiop:run-program cmd
                                                 :output t
                                                 :error-output t))))))
                   (mapcar (alexandria:compose #'ospm:url #'ospm:source) (delete-duplicates git-inputs)))
             (values git-inputs non-git-inputs)))))
  (fetch-git-modules "/path/to/repository/checkout" "sbcl-lisp-unit2" "sbcl-MY-OTHER-LIB" "..."))

And then go on with doing the actual work, testing, and documentation ;)

What (#| TMPL_VAR name |#) is.

(#| TMPL_VAR name |#) does…

Getting Started

Clone the Git repository:

git clone --recursive https://github.com/atlas-engineer/(#| TMPL_VAR name |#) ~/common-lisp/

And then load :(#| TMPL_VAR name |#) in the REPL:

(asdf:load-system :(#| TMPL_VAR name |#))
;; or, if you use Quicklisp
(ql:quickload :(#| TMPL_VAR name |#))

Examples

;; Basic example here, see more in package.lisp.

How it works

Roadmap

  • [ ]