From 1cc4d947524b4780f0055e62e152083982bbf186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Fri, 4 Mar 2022 01:50:46 +0100 Subject: Allow explicit GUILE environment, document it. The environment variable GUILE can now be set to override the guile version, which allows us to test the code with multiple versions/implementations. Also updates README to note these variables. --- .gitignore | 1 + Makefile | 27 ++++++++++++++++++--------- README | 32 +++++++++++++++++++------------- README.in | 19 +++++++++++-------- env | 17 ++++++++++------- main | 3 +-- production-main | 3 ++- tests/run-tests.scm | 16 +++++----------- 8 files changed, 67 insertions(+), 51 deletions(-) diff --git a/.gitignore b/.gitignore index b27c1c89..4f433a8c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.x /html coverage +obj-* diff --git a/Makefile b/Makefile index 5144c888..93dd6b6c 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,19 @@ .PHONY: all clean test \ - static coverage + static coverage \ + go_files -GUILE_SITE_DIR=$(shell guile -c "(display (%site-dir))") -GUILE_CCACHE_DIR=$(shell guile -c "(display (%site-ccache-dir))") +GUILE := guile +export GUILE + +GUILD := guild + +GUILE_VERSION=$(shell $(GUILE) -c '(display (version))') + +GUILE_SITE_DIR=$(shell $(GUILE) -c "(display (%site-dir))") +GUILE_CCACHE_DIR=$(shell $(GUILE) -c "(display (%site-ccache-dir))") SCM_FILES = $(shell find module/ -type f -name \*.scm) -GO_FILES = $(SCM_FILES:module/%.scm=obj/%.go) +GO_FILES = $(SCM_FILES:module/%.scm=obj-$(GUILE_VERSION)/%.go) GUILE_C_FLAGS = -Lmodule \ -Wunused-toplevel \ @@ -18,16 +26,17 @@ all: go_files README static static: $(MAKE) -C static -obj/%.go: module/%.scm - @mkdir -p obj - @echo guild compile $< - @guild compile $(GUILE_C_FLAGS) -o $@ $< +obj-$(GUILE_VERSION)/%.go: module/%.scm + @echo $(GUILD) compile $< + @$(GUILD) compile $(GUILE_C_FLAGS) -o $@ $< +# Phony target used by test/run-tests.scm and main to +# automatically compile everything before they run. go_files: $(GO_FILES) clean: -$(MAKE) -C static clean - -rm -r obj + -rm -r obj-* install: all install -d $(DESTDIR)$(GUILE_SITE_DIR) $(DESTDIR)$(GUILE_CCACHE_DIR) diff --git a/README b/README index ef1cb239..23643d42 100644 --- a/README +++ b/README @@ -1,6 +1,9 @@ +make[1]: Entering directory '/home/hugo/code/calp' +make[1]: Nothing to be done for 'go_files'. +make[1]: Leaving directory '/home/hugo/code/calp' CALP Hugo Hörnquist - 2020-08-03 + 2022-03-04 Calp is primarily a program for loading calendar files (.ics's) from drendering them in different formats. The goal is however to also @@ -39,19 +42,22 @@ Standards and specifications - RFC 7265 (jCal) - Vdir Storage Format [VDIR] -Building --------- - ./configure - ./main -No explicit compilation is required for general usage, since Guile -compiles -files as they are needed. You do however have to run `./configure` -before the first startup to set up some local variables and download -the timezone db. +Building & Running +------------------ +Everything can be directly loaded due to Guile's auto-compilation. +However, two entry points are provided. +- `main', which sets up its own environment, and explicitly builds +all libraries before starting, and +- `production-main', which assumes that the environment already is +fine, and is the version which should be installed. -To actually compile the files, and render the documentation (at the -time of writing only the README), run - make all +The code can also be explicitly manually built, see the makefile. + +The environment/make variable GUILE can be set to another guile +binary, such as `guile3'. +Guild by defaults also uses this, but if a separate guild version is +explicitly required then the env/make var GUILD can be set (but this +shouldn't be needed). Techical Details ---------------- diff --git a/README.in b/README.in index 1d293d34..d0abb27e 100644 --- a/README.in +++ b/README.in @@ -24,17 +24,20 @@ Standards and specifications ---------------------------- - RFC 5545 (iCalendar) - RFC 6321 (xCal) +- RFC 7265 (jCal) - Vdir Storage Format [VDIR] -Building --------- - ./configure - ./main -No explicit compilation is required for general usage, since Guile compiles -files as they are needed. You do however have to run `./configure` before the first startup to set up some local variables and download the timezone db. +Building & Running +------------------ +Everything can be directly loaded due to Guile's auto-compilation. +However, two entry points are provided. +- `main', which sets up its own environment, and explicitly builds all libraries before starting, and +- `production-main', which assumes that the environment already is fine, and is the version which should be installed. -To actually compile the files, and render the documentation (at the time of writing only the README), run - make all +The code can also be explicitly manually built, see the makefile. + +The environment/make variable GUILE can be set to another guile binary, such as `guile3'. +Guild by defaults also uses this, but if a separate guild version is explicitly required then the env/make var GUILD can be set (but this shouldn't be needed). Techical Details ---------------- diff --git a/env b/env index 99b3f84d..cc4fc222 100755 --- a/env +++ b/env @@ -1,15 +1,18 @@ # -*- mode: sh -*- -root=$(dirname $(realpath $BASH_SOURCE)) +_here=$(dirname "$(realpath "${BASH_SOURCE[0]}")") -GUILE_LOAD_PATH="$root/module:$GUILE_LOAD_PATH" -#GUILE_LOAD_COMPILED_PATH="$root/obj/module:$GUILE_LOAD_COMPILED_PATH" -#LD_LIBRARY_PATH="$root/lib:$LD_LIBRARY_PATH" +export GUILE=${GUILE:-guile} +guile_version=$($GUILE -c '(display (version))') -XDG_DATA_HOME=$root -LIBEXEC=$root/scripts/ +export GUILE_LOAD_COMPILED_PATH=${_here}/obj-${guile_version}:${GUILE_LOAD_COMPILED_PATH} +export GUILE_LOAD_PATH=${_here}/module:${GUILE_LOAD_PATH} +export GUILE_AUTO_COMPILE=0 + +# TODO why are these set? +export XDG_DATA_HOME=$_here +export LIBEXEC=${_here}/scripts/ -export GUILE_LOAD_PATH GUILE_LOAD_COMPILED_PATH LD_LIBRARY_PATH XDG_DATA_HOME LIBEXEC #export GUILE_AUTO_COMPILE=0 # exec "$@" diff --git a/main b/main index 67e30973..5820b1cd 100755 --- a/main +++ b/main @@ -3,7 +3,6 @@ here=$(dirname $(realpath $0)) . $here/env -GUILE=${GUILE:-$(which guile)} -# GUILE_LOAD_PATH=$here/module +make GUILE="$GUILE" go_files exec $GUILE -c '((@ (calp main) main) (command-line))' "$@" diff --git a/production-main b/production-main index 44db76e5..69f1bc06 100644 --- a/production-main +++ b/production-main @@ -1,2 +1,3 @@ #!/bin/bash -exec $(which guile) -c '((@ (calp main) main) (command-line))' "$@" +GUILE=${GUILE:-guile} +exec "$GUILE" -c '((@ (calp main) main) (command-line))' "$@" diff --git a/tests/run-tests.scm b/tests/run-tests.scm index dbe6dede..43f3ccf8 100755 --- a/tests/run-tests.scm +++ b/tests/run-tests.scm @@ -1,13 +1,12 @@ #!/usr/bin/bash here=$(dirname $(realpath $0)) -export GUILE_LOAD_PATH=$(dirname $here)/module -export GUILE_LOAD_COMPILED_PATH=$(dirname $here)/obj -export GUILE_AUTO_COMPILE=0 -make -C $(dirname $here) go_files +. "$(dirname "$here")/env" -exec guile --debug -s "$0" "$@" +make -C $(dirname $here) GUILE="$GUILE" go_files + +exec $GUILE --debug -s "$0" "$@" !# ;;; Commentary: @@ -43,11 +42,6 @@ exec guile --debug -s "$0" "$@" (eval-when (compile load eval) (define here (dirname (current-filename)))) -(add-to-load-path (format #f "~a/module" (dirname here))) -(set! %load-compiled-path (cons (format #f "~a/obj" (dirname here)) - %load-compiled-path)) - - (use-modules (srfi srfi-64)) (define (µs x) @@ -105,6 +99,7 @@ exec guile --debug -s "$0" "$@" ;; after everything else is done (test-runner-on-final! runner (lambda (runner) + (format #t "Guile version ~a~%~%" (version)) (format #t "pass: ~a~%" (test-runner-pass-count runner)) (format #t "fail: ~a~%" (test-runner-fail-count runner)) (format #t "xpass: ~a~%" (test-runner-xpass-count runner)) @@ -218,4 +213,3 @@ exec guile --debug -s "$0" "$@" (lambda (port) (coverage-data->lcov data port))))) (test-end "tests") - -- cgit v1.2.3