Newer
Older
#+xcvb
(module
(:build-depends-on ("driver")
:depends-on ("/asdf")))
;;; Versioning
(in-package :xcvb-driver)
(defun get-xcvb-directory ()
(asdf::probe-file* (asdf::subpathname (get-xcvb-directory) ".git/")))
(asdf::subpathname (get-xcvb-directory) "version.text"))
(defun get-xcvb-version-from-git ()
(and (xcvb-git-checkout-p)
(first
(run-program/
(format nil "cd ~A ; git describe --tags --dirty=+" (get-xcvb-directory))
:output :lines))))
(defun get-xcvb-version-from-file ()
(with-open-file (s (xcvb-version-file) :direction :input :if-does-not-exist nil)
(read s)))
(defun get-xcvb-version ()
(or
(get-xcvb-version-from-git)
(get-xcvb-version-from-file)
(error "Cannot determine XCVB version: neither .git/ nor version.text in ~A"
(get-xcvb-directory))))
(defun make-xcvb-version-file (&optional file)
(let ((version (get-xcvb-version-from-git))
(file (asdf::merge-pathnames* file (xcvb-version-file))))
(unless version
(error "Could not get XCVB version from git"))
(with-open-file (s file :direction :output
:if-does-not-exist :create :if-exists :rename-and-delete)
(format s "~
;;; This file was automatically generated by (xcvb::make-xcvb-version-file)
;;; from a git checkout. It is only consulted in a gitless code checkout.
;;; Edit manually at your own risk.
~S~%"
version))
(when (>= (or *xcvb-verbosity* 5) 5)
(format *error-output* "~&Saved version ~A in version file ~A~%"
version (truename file)))
(values)))