From 58a9509014d2d133b91e96c7956957f82bc000a4 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Mon, 14 Sep 2015 18:10:06 +0100 Subject: [PATCH] Eliminate the separately maintained Lisp system version number. * Have `configure.ac' derive a version string which ASDF won't choke on and make that available as an output variable. * Move the ASD files to `.in' files, and substitute the source path into them at build time, so that they actually still work. * At build time, construct an `auto.lisp' file with the relevant version information; modify the ASD `.in' files to load this. * At install time, construct the ASD files differently, by stripping out the source path and substituting the version information bodily into the files. * Actually install the `sod-frontend' system definition, just in case it's useful to someone. * Actually remove the ASDF symlinks when we're finished. --- configure.ac | 26 ++++++++++ src/Makefile.am | 75 +++++++++++++++++++-------- src/auto.lisp.in | 7 +++ src/package.lisp | 2 +- src/{sod-frontend.asd => sod-frontend.asd.in} | 5 +- src/{sod-test.asd => sod-test.asd.in} | 9 ++-- src/{sod.asd => sod.asd.in} | 8 ++- src/test-base.lisp | 11 ---- vars.am | 3 +- 9 files changed, 105 insertions(+), 41 deletions(-) create mode 100644 src/auto.lisp.in rename src/{sod-frontend.asd => sod-frontend.asd.in} (95%) rename src/{sod-test.asd => sod-test.asd.in} (93%) rename src/{sod.asd => sod.asd.in} (97%) diff --git a/configure.ac b/configure.ac index cb1c5a6..c1fed50 100644 --- a/configure.ac +++ b/configure.ac @@ -39,6 +39,32 @@ AX_CFLAGS_WARN_ALL mdw_LIBTOOL_VERSION_INFO dnl-------------------------------------------------------------------------- +dnl Convert the version number for ASDF. + +## This is surprisingly awful. The convention for official version numbers +## is that they look like MAJOR.MINOR.PATCH[.BPB][-N-gHEX[+]]. ASDF +## insists on simple numeric things separated by dots. If there's no Git +## thing on the end, then the main version number will do fine. If there +## is, then we insert /two/ `0's in, followed by N and the HEX converted to +## decimal. Why two? Because if there's no brown-paper-bag number, we +## want to make sure that the first BPB release is higher than any of the +## preceding Git revisions. +ver=AC_PACKAGE_VERSION +case $ver in + *-*-g*) + base=${ver%%-*} tail=${ver#*-} + n=${tail%%-*} tail=${tail#*-g} + case $tail in *+) grubby=.1 tail=${tail%+} ;; *) grubby= ;; esac + rev=$(( 0x$tail )) + ASDF_VERSION=$base.0.0.$n.$rev$grubby + ;; + *) + ASDF_VERSION=$ver + ;; +esac +AC_SUBST([ASDF_VERSION]) + +dnl-------------------------------------------------------------------------- dnl Common Lisp things. AC_ARG_WITH([lisp-system], diff --git a/src/Makefile.am b/src/Makefile.am index c7779f9..7b23dd8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -27,13 +27,11 @@ include $(top_srcdir)/vars.am nobase_dist_pkglispsrc_DATA = $(LISP_SOURCES) LISP_SOURCES = +SYSDEFS = ###-------------------------------------------------------------------------- ### The source files. -## The system definition file. -LISP_SOURCES += sod.asd - ## The package definition file. LISP_SOURCES += package.lisp @@ -87,7 +85,6 @@ LISP_SOURCES += method-proto.lisp method-impl.lisp LISP_SOURCES += method-aggregate.lisp ## User interface. -LISP_SOURCES += sod-frontend.asd LISP_SOURCES += frontend.lisp optparse.lisp ## Finishing touches. @@ -98,20 +95,39 @@ LISP_SOURCES += final.lisp CLEANFILES += *.$(fasl) parser/*.$(fasl) +## Autodetected configuration. +EXTRA_DIST += auto.lisp.in +CLEANFILES += auto.lisp +auto.lisp: auto.lisp.in Makefile + $(SUBST) $(srcdir)/auto.lisp.in >$@.new $(SUBSTITUTIONS) && \ + grep '^[^;]' $@.new >$@.strip && \ + rm -f $@.new && mv $@.strip $@ + +## Building a working-tree system definition. +EXTRA_DIST += sod.asd.in +CLEANFILES += sod.asd +sod.asd: sod.asd.in Makefile + $(SUBST) $(srcdir)/sod.asd.in >$@.new $(SUBSTITUTIONS) && \ + mv $@.new $@ + +EXTRA_DIST += sod-frontend.asd.in +CLEANFILES += sod-frontend.asd +sod-frontend.asd: sod-frontend.asd.in Makefile + $(SUBST) $(srcdir)/sod-frontend.asd.in >$@.new $(SUBSTITUTIONS) && \ + mv $@.new $@ + ## Building the executable image. bin_PROGRAMS += sod sod_SOURCES = -sod: $(LISP_SOURCES) - $(V_DUMP)true_srcdir=$$(cd $(srcdir); pwd); \ - ASDF_OUTPUT_TRANSLATIONS=$$true_srcdir:$(abs_builddir): \ - $(CL_LAUNCH) -o sod -d ! -l $(LISPSYS) +I -S $$true_srcdir/: \ +sod: $(LISP_SOURCES) sod.asd sod-frontend.asd auto.lisp + $(V_DUMP)$(CL_LAUNCH) -o sod -d ! -l $(LISPSYS) +I \ -s sod-frontend -r sod-frontend:main ###-------------------------------------------------------------------------- ### Unit testing. ## The system definition. -EXTRA_DIST += sod-test.asd +EXTRA_DIST += sod-test.asd.in ## Basic utilities. EXTRA_DIST += test-base.lisp @@ -125,15 +141,17 @@ EXTRA_DIST += c-types-test.lisp EXTRA_DIST += codegen-test.lisp EXTRA_DIST += lexer-test.lisp +## The system definition. +EXTRA_DIST += sod-test.asd.in +CLEANFILES += sod-test.asd +sod-test.asd: sod-test.asd.in Makefile + $(SUBST) $(srcdir)/sod-test.asd.in >$@.new $(SUBSTITUTIONS) && \ + mv $@.new $@ + ## Running the Lisp tests. -check-local: - $(V_TEST)true_srcdir=$$(cd $(srcdir); pwd); \ - ASDF_OUTPUT_TRANSLATIONS=$$true_srcdir:$(abs_builddir): \ - $(CL_LAUNCH) -l $(LISPSYS) -s sod-test +I -S $$true_srcdir/: \ - -i '(handler-case ;\ - (progn ;\ - (setf sod-test:*build-version* "$(VERSION)") ;\ - (asdf:test-system "sod")) ;\ +check-local: sod sod-test.asd + $(V_TEST)$(CL_LAUNCH) -l $(LISPSYS) -s sod-test +I \ + -i '(handler-case (asdf:test-system "sod") ;\ (error (cond) ;\ (format *error-output* "ERR: ~A~%" cond) ;\ (cl-launch:quit 1)))' @@ -148,9 +166,9 @@ check-local: ## don't have spaces in them; but that's generally a bad idea in Makefiles ## anyway. install-data-local: - $(MKDIR_P) $(DESTDIR)$(lispsysdir) + $(MKDIR_P) $(DESTDIR)$(lispsysdir) $(DESTDIR)$(pkglispsrcdir) @set -e; \ - from=$(lispsysdir) to=$(pkglispsrcdir)/sod.asd; \ + from=$(lispsysdir) to=$(pkglispsrcdir); \ set -- $$(echo $$from | tr "/" " "); fwd=$$*; \ set -- $$(echo $$to | tr "/" " "); twd=$$*; \ while :; do \ @@ -163,8 +181,21 @@ install-data-local: done; \ dots=$$(echo $$fwd | sed 's/[^ ][^ ]*/../g'); \ rel=$$(echo $$dots $$twd | tr " " "/"); \ - echo >&2 "ln -s $$rel $$to"; \ - ln -s $$rel $(DESTDIR)$$from/sod.asd.new; \ - mv $(DESTDIR)$$from/sod.asd.new $(DESTDIR)$$from/sod.asd + for i in sod.asd sod-frontend.asd; do \ + echo >&2 "CREATE $$to/$$i"; \ + sed -e '/#|@-auto-@|#/ { r auto.lisp' -e ' d; }' \ + -e '/#|@-path-@|#/ d' \ + $(srcdir)/$$i.in >$(DESTDIR)$(pkglispsrcdir)/$$i.new; \ + mv $(DESTDIR)$(pkglispsrcdir)/$$i.new \ + $(DESTDIR)$(pkglispsrcdir)/$$i; \ + echo >&2 "LINK $$rel/$$i $$to/$$i"; \ + ln -s $$rel/$$i $(DESTDIR)$$from/$$i.new; \ + mv $(DESTDIR)$$from/$$i.new $(DESTDIR)$$from/$$i; \ + done + +uninstall-local: + for i in sod.asd sod-frontend.asd; do \ + rm -f $(DESTDIR)$(pkglispsrcdir)/$$i $(DESTDIR)$(lispsysdir)/$$i; \ + done ###----- That's all, folks -------------------------------------------------- diff --git a/src/auto.lisp.in b/src/auto.lisp.in new file mode 100644 index 0000000..758ef23 --- /dev/null +++ b/src/auto.lisp.in @@ -0,0 +1,7 @@ +;;; -*-lisp-*- + +(defparameter *version* "@VERSION@" + "The official Sod revision number.") + +(defparameter *sysdef-version* "@ASDF_VERSION@" + "The Sod revision number, forced into ASDF's limited format.") diff --git a/src/package.lisp b/src/package.lisp index a6b9785..d6e47f4 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -31,7 +31,7 @@ (cl:in-package #:sod) (export '*sod-version*) -(defvar *sod-version* (asdf:component-version (asdf:find-system "sod")) +(defparameter *sod-version* sod-sysdef:*version* "The version of the SOD translator system, as a string.") ;;;----- That's all, folks -------------------------------------------------- diff --git a/src/sod-frontend.asd b/src/sod-frontend.asd.in similarity index 95% rename from src/sod-frontend.asd rename to src/sod-frontend.asd.in index 6ba17cd..b81fd2d 100644 --- a/src/sod-frontend.asd +++ b/src/sod-frontend.asd.in @@ -28,15 +28,18 @@ (cl:in-package #:sod-sysdef) +#|@-auto-@|# (load "auto.lisp") + ;;;-------------------------------------------------------------------------- ;;; Definition. (defsystem sod-frontend ;; Boring copyright stuff. - :version "1.0.0" + :version #.*sysdef-version* :author "Mark Wooding" :license "GNU General Public License, version 2 or later" + #|@-path-@|# :pathname "@srcdir@" ;; Documentation. :description "A Sensible Object Design for C, command-line frontend." diff --git a/src/sod-test.asd b/src/sod-test.asd.in similarity index 93% rename from src/sod-test.asd rename to src/sod-test.asd.in index b3024dc..6b2a83b 100644 --- a/src/sod-test.asd +++ b/src/sod-test.asd.in @@ -23,10 +23,12 @@ ;;; along with SOD; if not, write to the Free Software Foundation, ;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -(cl:defpackage #:sod-test-sysdef +(cl:defpackage #:sod-sysdef (:use #:common-lisp #:asdf)) -(cl:in-package #:sod-test-sysdef) +(cl:in-package #:sod-sysdef) + +#|@-auto-@|# (load "auto.lisp") ;;;-------------------------------------------------------------------------- ;;; Definition. @@ -34,9 +36,10 @@ (defsystem sod-test ;; Boring copyright stuff. - :version "1.0.0" + :version #:*sysdef-version* :author "Mark Wooding" :license "GNU General Public License, version 2 or later" + #|@-path-@|# :pathname "@srcdir@" ;; Documentation. :description "Tests for the Sensible Object Design translator." diff --git a/src/sod.asd b/src/sod.asd.in similarity index 97% rename from src/sod.asd rename to src/sod.asd.in index f207df0..d710fb1 100644 --- a/src/sod.asd +++ b/src/sod.asd.in @@ -24,19 +24,23 @@ ;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. (cl:defpackage #:sod-sysdef - (:use #:common-lisp #:asdf)) + (:use #:common-lisp #:asdf) + (:export #:*version*)) (cl:in-package #:sod-sysdef) +#|@-auto-@|# (load "auto.lisp") + ;;;-------------------------------------------------------------------------- ;;; Definition. (defsystem sod ;; Boring copyright stuff. - :version "0.2.0" + :version #.*sysdef-version* :author "Mark Wooding" :license "GNU General Public License, version 2 or later" + #|@-path-@|# :pathname "@srcdir@" ;; Documentation. :description "A Sensible Object Design for C." diff --git a/src/test-base.lisp b/src/test-base.lisp index f7210ab..203f918 100644 --- a/src/test-base.lisp +++ b/src/test-base.lisp @@ -55,17 +55,6 @@ (defclass base-test (test-case) ()) (add-test *sod-test-suite* (get-suite base-test)) -(export '*build-version*) -(defvar *build-version* nil) - -(def-test-method check-version ((test base-test) :run nil) - (unless (or (null *build-version*) - (and (>= (length *build-version*) (length *sod-version*)) - (string= *build-version* *sod-version* - :end1 (length *sod-version*)))) - (failure "Build version ~A doesn't match package version ~A." - *build-version* *sod-version*))) - (defun run-tests (&optional which) (textui-test-run (acond ((null which) *sod-test-suite*) diff --git a/vars.am b/vars.am index 1b360ee..7e7406c 100644 --- a/vars.am +++ b/vars.am @@ -66,7 +66,8 @@ SUBSTITUTIONS = \ prefix=$(prefix) exec_prefix=$(exec_prefix) \ libdir=$(libdir) includedir=$(includedir) \ bindir=$(bindir) sbindir=$(sbindir) \ - PACKAGE=$(PACKAGE) VERSION=$(VERSION) + srcdir=$(srcdir) \ + PACKAGE=$(PACKAGE) VERSION=$(VERSION) ASDF_VERSION=$(ASDF_VERSION) V_SUBST = $(V_SUBST_$(V)) V_SUBST_ = $(V_SUBST_$(AM_DEFAULT_VERBOSITY)) -- 2.11.0