From 81c8b35752235aeb26058c0baadd0ea58046f640 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Thu, 3 Mar 2016 18:18:55 +0100 Subject: [PATCH] Append effective version to GUILE_LOAD[_COMPILED]_PATH elements. * libguile/load.c (scm_path_append_effective_version): New function (scm_init_load_path): Use it. * am/guilec (moddir,ccachedir): Use GUILE_EFFECTIVE_VERSION as prefix. --- am/guilec | 4 ++-- libguile/load.c | 27 ++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/am/guilec b/am/guilec index 5ef07fa..fa2b5ba 100644 --- a/am/guilec +++ b/am/guilec @@ -3,9 +3,9 @@ GOBJECTS = $(SOURCES:%.scm=%.go) $(ELISP_SOURCES:%.el=%.go) GUILE_WARNINGS = -Wunbound-variable -Warity-mismatch -Wformat -moddir = $(pkgdatadir)/$(GUILE_EFFECTIVE_VERSION)/$(modpath) +moddir = $(pkgdatadir)/$(modpath)/$(GUILE_EFFECTIVE_VERSION) nobase_mod_DATA = $(SOURCES) $(ELISP_SOURCES) $(NOCOMP_SOURCES) -ccachedir = $(pkglibdir)/$(GUILE_EFFECTIVE_VERSION)/ccache/$(modpath) +ccachedir = $(pkglibdir)/ccache/$(GUILE_EFFECTIVE_VERSION)/$(modpath) nobase_ccache_DATA = $(GOBJECTS) EXTRA_DIST = $(SOURCES) $(ELISP_SOURCES) $(NOCOMP_SOURCES) ETAGS_ARGS = $(SOURCES) $(ELISP_SOURCES) $(NOCOMP_SOURCES) diff --git a/libguile/load.c b/libguile/load.c index d26f9fc..055f3c4 100644 --- a/libguile/load.c +++ b/libguile/load.c @@ -1,5 +1,6 @@ /* Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2004, 2006, 2008, - * 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc. + * 2009, 2010, 2011, 2012, 2013, 2014, 2016 Free Software Foundation, + * Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -312,6 +313,28 @@ scm_i_mirror_backslashes (char *path) return path; } +/* Append effective_version to each element in PATH. This allows using + one single heterogeneous path for different effective versions of + Guile, i.e., running different versions of guile alongside each other + from one shell, without juggling GUILE_LOAD_COMPILED_PATH. */ +static SCM +scm_path_append_effective_version (SCM path) +{ + SCM vpath = SCM_EOL; + SCM version = scm_effective_version (); + SCM slash = scm_from_utf8_string ("/"); + for (path = scm_reverse (path); scm_is_pair (path); + path = SCM_CDR (path)) + { + SCM dir = SCM_CAR (path); + SCM vdir = scm_string_append (scm_list_3 (dir, slash, version)); + /* keep non-M.M suffixed dir as fallback for compatibility. */ + vpath = scm_cons (dir, vpath); + vpath = scm_cons (vdir, vpath); + } + return vpath; +} + /* Initialize the global variable %load-path, given the value of the SCM_SITE_DIR and SCM_LIBRARY_DIR preprocessor symbols and the GUILE_LOAD_PATH environment variable. */ @@ -393,7 +416,9 @@ scm_init_load_path () if (env) cpath = scm_parse_path_with_ellipsis (scm_from_locale_string (env), cpath); + path = scm_path_append_effective_version (path); *scm_loc_load_path = path; + cpath = scm_path_append_effective_version (cpath); *scm_loc_load_compiled_path = cpath; } -- 2.6.3