mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 11:40:18 +02:00
separate the load-compiled path from the load path
* libguile/Makefile.am (libpath.h): Add definitions for SCM_CCACHE_DIR and SCM_EFFECTIVE_VERSION. These are private, the header is not installed. Add ccachedir to build-info. Rework some other build-info definitions. * libguile/load.c (scm_loc_load_compiled_path): New global, corresponding to the new environment variable, GUILE_LOAD_COMPILED_PATH. Compiled files will now be searched for in this path, and only in this path. (scm_init_load_path): Init the load-compiled path too. We initialize it with $pkglibdir/guile/$effective_version/ccache, and also with $HOME/.guile-ccache/$effective_version/. This will respect the libdir/datadir difference, and it is a preparation for automatic compilation support. (scm_primitive_load_path): Search only the GUILE_LOAD_COMPILED_PATH for compiled files. (scm_init_load): Cache scm_loc_load_compiled_path.
This commit is contained in:
parent
2f9ae9b104
commit
5b197db838
2 changed files with 52 additions and 5 deletions
|
@ -286,6 +286,8 @@ libpath.h: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||||
@echo '#define SCM_PKGDATA_DIR "$(pkgdatadir)"' >> libpath.tmp
|
@echo '#define SCM_PKGDATA_DIR "$(pkgdatadir)"' >> libpath.tmp
|
||||||
@echo '#define SCM_LIBRARY_DIR "$(pkgdatadir)/$(GUILE_EFFECTIVE_VERSION)"'>>libpath.tmp
|
@echo '#define SCM_LIBRARY_DIR "$(pkgdatadir)/$(GUILE_EFFECTIVE_VERSION)"'>>libpath.tmp
|
||||||
@echo '#define SCM_SITE_DIR "$(pkgdatadir)/site"' >> libpath.tmp
|
@echo '#define SCM_SITE_DIR "$(pkgdatadir)/site"' >> libpath.tmp
|
||||||
|
@echo '#define SCM_CCACHE_DIR "$(pkglibdir)/$(GUILE_EFFECTIVE_VERSION)/ccache"' >> libpath.tmp
|
||||||
|
@echo '#define SCM_EFFECTIVE_VERSION "$(GUILE_EFFECTIVE_VERSION)"' >> libpath.tmp
|
||||||
@echo '#define SCM_BUILD_INFO { \' >> libpath.tmp
|
@echo '#define SCM_BUILD_INFO { \' >> libpath.tmp
|
||||||
@echo ' { "srcdir", "'"`cd @srcdir@; pwd`"'" }, \' >> libpath.tmp
|
@echo ' { "srcdir", "'"`cd @srcdir@; pwd`"'" }, \' >> libpath.tmp
|
||||||
@echo ' { "top_srcdir", "@top_srcdir_absolute@" }, \' >> libpath.tmp
|
@echo ' { "top_srcdir", "@top_srcdir_absolute@" }, \' >> libpath.tmp
|
||||||
|
@ -299,12 +301,13 @@ libpath.h: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||||
@echo ' { "sharedstatedir", "@sharedstatedir@" }, \' >> libpath.tmp
|
@echo ' { "sharedstatedir", "@sharedstatedir@" }, \' >> libpath.tmp
|
||||||
@echo ' { "localstatedir", "@localstatedir@" }, \' >> libpath.tmp
|
@echo ' { "localstatedir", "@localstatedir@" }, \' >> libpath.tmp
|
||||||
@echo ' { "libdir", "@libdir@" }, \' >> libpath.tmp
|
@echo ' { "libdir", "@libdir@" }, \' >> libpath.tmp
|
||||||
|
@echo ' { "ccachedir", SCM_CCACHE_DIR }, \' >> libpath.tmp
|
||||||
@echo ' { "infodir", "@infodir@" }, \' >> libpath.tmp
|
@echo ' { "infodir", "@infodir@" }, \' >> libpath.tmp
|
||||||
@echo ' { "mandir", "@mandir@" }, \' >> libpath.tmp
|
@echo ' { "mandir", "@mandir@" }, \' >> libpath.tmp
|
||||||
@echo ' { "includedir", "@includedir@" }, \' >> libpath.tmp
|
@echo ' { "includedir", "@includedir@" }, \' >> libpath.tmp
|
||||||
@echo ' { "pkgdatadir", "$(datadir)/@PACKAGE@" }, \' >> libpath.tmp
|
@echo ' { "pkgdatadir", "@pkgdatadir@" }, \' >> libpath.tmp
|
||||||
@echo ' { "pkglibdir", "$(libdir)/@PACKAGE@" }, \' >> libpath.tmp
|
@echo ' { "pkglibdir", "@pkglibdir@" }, \' >> libpath.tmp
|
||||||
@echo ' { "pkgincludedir", "$(includedir)/@PACKAGE@" }, \' \
|
@echo ' { "pkgincludedir", "@pkgincludedir@" }, \' \
|
||||||
>> libpath.tmp
|
>> libpath.tmp
|
||||||
@echo ' { "guileversion", "@GUILE_VERSION@" }, \' >> libpath.tmp
|
@echo ' { "guileversion", "@GUILE_VERSION@" }, \' >> libpath.tmp
|
||||||
@echo ' { "libguileinterface", "@LIBGUILE_INTERFACE@" }, \' \
|
@echo ' { "libguileinterface", "@LIBGUILE_INTERFACE@" }, \' \
|
||||||
|
|
|
@ -53,6 +53,10 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif /* HAVE_UNISTD_H */
|
#endif /* HAVE_UNISTD_H */
|
||||||
|
|
||||||
|
#ifdef HAVE_PWD_H
|
||||||
|
#include <pwd.h>
|
||||||
|
#endif /* HAVE_PWD_H */
|
||||||
|
|
||||||
#ifndef R_OK
|
#ifndef R_OK
|
||||||
#define R_OK 4
|
#define R_OK 4
|
||||||
#endif
|
#endif
|
||||||
|
@ -174,7 +178,8 @@ static SCM *scm_loc_load_path;
|
||||||
/* List of extensions we try adding to the filenames. */
|
/* List of extensions we try adding to the filenames. */
|
||||||
static SCM *scm_loc_load_extensions;
|
static SCM *scm_loc_load_extensions;
|
||||||
|
|
||||||
/* Like %load-extensions, but for compiled files. */
|
/* Like %load-path and %load-extensions, but for compiled files. */
|
||||||
|
static SCM *scm_loc_load_compiled_path;
|
||||||
static SCM *scm_loc_load_compiled_extensions;
|
static SCM *scm_loc_load_compiled_extensions;
|
||||||
|
|
||||||
|
|
||||||
|
@ -209,6 +214,7 @@ scm_init_load_path ()
|
||||||
{
|
{
|
||||||
char *env;
|
char *env;
|
||||||
SCM path = SCM_EOL;
|
SCM path = SCM_EOL;
|
||||||
|
SCM cpath = SCM_EOL;
|
||||||
|
|
||||||
#ifdef SCM_LIBRARY_DIR
|
#ifdef SCM_LIBRARY_DIR
|
||||||
env = getenv ("GUILE_SYSTEM_PATH");
|
env = getenv ("GUILE_SYSTEM_PATH");
|
||||||
|
@ -222,13 +228,48 @@ scm_init_load_path ()
|
||||||
path = scm_list_3 (scm_from_locale_string (SCM_SITE_DIR),
|
path = scm_list_3 (scm_from_locale_string (SCM_SITE_DIR),
|
||||||
scm_from_locale_string (SCM_LIBRARY_DIR),
|
scm_from_locale_string (SCM_LIBRARY_DIR),
|
||||||
scm_from_locale_string (SCM_PKGDATA_DIR));
|
scm_from_locale_string (SCM_PKGDATA_DIR));
|
||||||
|
|
||||||
|
env = getenv ("GUILE_SYSTEM_COMPILED_PATH");
|
||||||
|
if (env && strcmp (env, "") == 0)
|
||||||
|
/* like above */
|
||||||
|
;
|
||||||
|
else if (env)
|
||||||
|
cpath = scm_parse_path (scm_from_locale_string (env), cpath);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char *home;
|
||||||
|
|
||||||
|
home = getenv ("HOME");
|
||||||
|
#ifdef HAVE_GETPWENT
|
||||||
|
if (!home)
|
||||||
|
{
|
||||||
|
struct passwd *pwd;
|
||||||
|
pwd = getpwuid (getuid ());
|
||||||
|
if (pwd)
|
||||||
|
home = pwd->pw_dir;
|
||||||
|
}
|
||||||
|
#endif /* HAVE_GETPWENT */
|
||||||
|
if (home)
|
||||||
|
{ char buf[1024];
|
||||||
|
snprintf (buf, sizeof(buf),
|
||||||
|
"%s/.guile-ccache/" SCM_EFFECTIVE_VERSION, home);
|
||||||
|
cpath = scm_cons (scm_from_locale_string (buf), cpath);
|
||||||
|
}
|
||||||
|
|
||||||
|
cpath = scm_cons (scm_from_locale_string (SCM_CCACHE_DIR), cpath);
|
||||||
|
}
|
||||||
#endif /* SCM_LIBRARY_DIR */
|
#endif /* SCM_LIBRARY_DIR */
|
||||||
|
|
||||||
env = getenv ("GUILE_LOAD_PATH");
|
env = getenv ("GUILE_LOAD_PATH");
|
||||||
if (env)
|
if (env)
|
||||||
path = scm_parse_path (scm_from_locale_string (env), path);
|
path = scm_parse_path (scm_from_locale_string (env), path);
|
||||||
|
|
||||||
|
env = getenv ("GUILE_LOAD_COMPILED_PATH");
|
||||||
|
if (env)
|
||||||
|
cpath = scm_parse_path (scm_from_locale_string (env), cpath);
|
||||||
|
|
||||||
*scm_loc_load_path = path;
|
*scm_loc_load_path = path;
|
||||||
|
*scm_loc_load_compiled_path = cpath;
|
||||||
}
|
}
|
||||||
|
|
||||||
SCM scm_listofnullstr;
|
SCM scm_listofnullstr;
|
||||||
|
@ -519,7 +560,7 @@ SCM_DEFINE (scm_primitive_load_path, "primitive-load-path", 1, 0, 0,
|
||||||
SCM full_filename, compiled_filename;
|
SCM full_filename, compiled_filename;
|
||||||
|
|
||||||
full_filename = scm_sys_search_load_path (filename);
|
full_filename = scm_sys_search_load_path (filename);
|
||||||
compiled_filename = scm_search_path (*scm_loc_load_path,
|
compiled_filename = scm_search_path (*scm_loc_load_compiled_path,
|
||||||
filename,
|
filename,
|
||||||
*scm_loc_load_compiled_extensions,
|
*scm_loc_load_compiled_extensions,
|
||||||
SCM_BOOL_T);
|
SCM_BOOL_T);
|
||||||
|
@ -529,6 +570,7 @@ SCM_DEFINE (scm_primitive_load_path, "primitive-load-path", 1, 0, 0,
|
||||||
scm_list_1 (filename));
|
scm_list_1 (filename));
|
||||||
|
|
||||||
if (scm_is_false (compiled_filename))
|
if (scm_is_false (compiled_filename))
|
||||||
|
/* FIXME: autocompile here */
|
||||||
return scm_primitive_load (full_filename);
|
return scm_primitive_load (full_filename);
|
||||||
|
|
||||||
if (scm_is_false (full_filename))
|
if (scm_is_false (full_filename))
|
||||||
|
@ -600,6 +642,8 @@ scm_init_load ()
|
||||||
= SCM_VARIABLE_LOC (scm_c_define ("%load-extensions",
|
= SCM_VARIABLE_LOC (scm_c_define ("%load-extensions",
|
||||||
scm_list_2 (scm_from_locale_string (".scm"),
|
scm_list_2 (scm_from_locale_string (".scm"),
|
||||||
scm_nullstr)));
|
scm_nullstr)));
|
||||||
|
scm_loc_load_compiled_path
|
||||||
|
= SCM_VARIABLE_LOC (scm_c_define ("%load-compiled-path", SCM_EOL));
|
||||||
scm_loc_load_compiled_extensions
|
scm_loc_load_compiled_extensions
|
||||||
= SCM_VARIABLE_LOC (scm_c_define ("%load-compiled-extensions",
|
= SCM_VARIABLE_LOC (scm_c_define ("%load-compiled-extensions",
|
||||||
scm_list_1 (scm_from_locale_string (".go"))));
|
scm_list_1 (scm_from_locale_string (".go"))));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue