From 898e59dfa3db531542b556648d8ad029535886e3 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Wed, 5 Jan 2022 15:48:54 +0530 Subject: configure: Output version. * configure.scm: Import (rnrs io ports), (srfi srfi-26) and (ice-9 popen). (call-with-input-pipe): New function. (version): New variable. Output version to Makefile.include. --- configure.scm | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/configure.scm b/configure.scm index 07a822a..9c519fc 100644 --- a/configure.scm +++ b/configure.scm @@ -17,9 +17,24 @@ ;;; License along with kolam. If not, see ;;; . -(use-modules (srfi srfi-28) +(use-modules (rnrs io ports) + (srfi srfi-26) + (srfi srfi-28) (srfi srfi-37) - (ice-9 match)) + (ice-9 match) + (ice-9 popen)) + +(define (call-with-input-pipe command proc) + "Call PROC with input pipe to COMMAND. COMMAND is a list of program +arguments." + (match command + ((prog args ...) + (let ((port #f)) + (dynamic-wind + (lambda () + (set! port (apply open-pipe* OPEN_READ prog args))) + (cut proc port) + (cut close-pipe port)))))) (define (check-for-guile-3.0) (display "checking for guile 3.0... ") @@ -75,6 +90,16 @@ (libdir . ,libdir) (datarootdir . ,datarootdir)))))) +(define version + (call-with-input-pipe (list "git" "tag" "--sort=-taggerdate" + "--list" "v*") + (lambda (port) + (let ((line (get-line port))) + (if (eof-object? line) + ;; If there are no tags, assume first version. + "0.1.0" + (substring line (string-length "v"))))))) + (check-for-guile-3.0) (check-for-module '(json)) @@ -83,11 +108,13 @@ (display (format "# This file was automatically generated by configure. project = ~a +version = ~a libdir = ~a datarootdir = ~a guile_effective_version = ~a " (assq-ref processed-args 'project) + version (assq-ref processed-args 'libdir) (assq-ref processed-args 'datarootdir) (effective-version)) -- cgit v1.2.3