From: Neil Jerram <neil@ossau.uklinux.net>
Subject: Modified load-path proposal
Date: Thu, 13 Oct 2005 19:21:13 +0100 [thread overview]
Message-ID: <878xwx5ld2.fsf@ossau.uklinux.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 92 bytes --]
I think this meets everyone's desires ... please let me know what you
think!
Neil
[-- Attachment #2: load-path.txt --]
[-- Type: text/plain, Size: 5413 bytes --]
-*- scheme -*-
;; 1. Format and example contents of
;; $sysconfdir/guile/$EFFECTIVE_VERSION/config.scm
;;
;; The format is a single alist expression which Guile reads.
;; (config.scm is not a file which Guile loads, and which could
;; therefore contain arbitrary code, because (i) it is used before
;; boot-9.scm is loaded, which means that bits of Scheme are not
;; available yet, and (ii) the specification of a standard format
;; allows us to use automated tools for updating the contents of the
;; file.)
;;
;; Each element of the alist is (INFO-TYPE . INFO), where the only
;; currently supported INFO-TYPE is load-path. The alist format
;; allows us to extend the use of the config.scm in future, but in a
;; way that should not require existing code and tools (if well
;; written) to be updated.
;;
;; When INFO-TYPE is load-path, the form of INFO is (DEFAULT-TAG (TAG
;; DIRECTORY DESCRIPTION) ...), where:
;;
;; - DEFAULT-TAG is the tag of the default install location for Guile
;; packages. In other words, it identifies the location that
;; GUILE_SCHEME_DIR will return if a package's ./configure is run
;; without a --with-guile-scheme-dir option.
;;
;; - TAG is an arbitrary symbol which can be used to uniquely identify
;; each load path directory.
;;
;; - DIRECTORY is a load path directory (as a string).
;;
;; - DESCRIPTION is a string describing the use of that load path
;; directory.
((load-path
local
(guile-1.6
"/usr/share/guile/1.6"
"Install location for Guile 1.6's own Scheme files")
(site
"/usr/share/guile/site"
"Install location for site-specific Scheme files")
(gnome
"/opt/gnome/guile"
"Install location for GNOME-related Scheme files")
(local
"/usr/local/share/guile"
"Version-independent non-distribution-managed Scheme files")
(local-1.6
"/usr/local/share/guile/1.6"
"1.6-dependent non-distribution-managed Scheme files")))
;; 2. Guile's startup logic
;;
;; Normal location of config.scm is hardcoded into Guile, based on the
;; setting of $sysconfdir at ./configure time.
;;
;; This location can be overridden at runtime by a --config=FILE
;; option (which we need to add). This will be needed by
;; pre-inst-guile (during a Guile build), for example.
;;
;; Guile will abort if config.scm is not found, or cannot be read, or
;; there are any errors in the format of the information in it.
;;
;; Otherwise, Guile sets %load-path to:
;;
;; (map cadr (cddr (assq 'load-path config)))
;;
;; (but in C code, not in Scheme).
;;
;; Thereafter %load-path is used as presently for the loading of
;; boot-9.scm, init.scm and so on.
;; 3. Code for guile-config add-load-path TAG DIRECTORY DESCRIPTION
;;
;; (To be integrated into guile-config, and will in practice need
;; error handling.)
(define (add-load-path tag directory description)
(let* ((config (with-input-from-file %sys-config-file read))
(load-path-info (assq 'load-path config)))
(set-cdr! load-path-info
(append! (cdr load-path-info)
(list (list tag
directory
description))))
(with-output-to-file %sys-config-file
(lambda ()
(pretty-print config)))))
;; 4. Code for guile-config get-load-path ARG
;;
;; Where ARG is the string that was given to --with-guile-scheme-dir,
;; or an empty string if --with-guile-scheme-dir was not used.
;;
;; (To be integrated into guile-config, and will in practice need
;; error handling.)
(define (get-load-path arg)
;; If ARG begins with "/", use it directly.
(if (and (>= (string-length arg) 1)
(char=? (string-ref arg 0) #\/))
arg
;; Otherwise we need to read config.
(let* ((config (with-input-from-file %sys-config-file read))
(load-path-info (assq 'load-path config))
(tag (if (zero? (string-length arg))
;; Use the default tag.
(cadr load-path-info)
;; ARG should be a tag.
(string->symbol arg))))
;; Return the directory for the chosen tag.
(cadr (assq tag (cddr load-path-info))))))
;; 5. Code for GUILE_SCHEME_DIR autoconf macro
;;
;; To be written, with these features/requirements:
;;
;; - Will check for a --with-guile-scheme-dir=ARG option.
;;
;; - Will use `guile-config get-load-path ARG` to get the appropriate
;; install directory.
;;
;; - Will NOT take a default-tag argument (in configure.in) as I
;; suggested before, because there is no way for the package author to
;; know what tags will be available on the distribution(s) where the
;; package is built.
;;
;; - Should fall back to other sensible mechanisms if `guile-config
;; get-load-path ARG` is not available.
;;
;; + Recent Guile distributions have the GUILE_SITE_DIR macro. In
;; my view this is better than nothing, but it feels wrong for Guile
;; package code to go under .../site. So my preference if using
;; GUILE_SITE_DIR would be to install to ${GUILE_SITE_DIR}/..
;;
;; + One could run Guile to discover its %load-path, and decide
;; heuristically which of those directories to install under.
;;
;; + Note that there's no point in falling back to
;; $prefix/share/guile, because if the package author wanted that
;; they could have specified that directly instead of using
;; GUILE_SCHEME_DIR.
[-- Attachment #3: Type: text/plain, Size: 140 bytes --]
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
next reply other threads:[~2005-10-13 18:21 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-13 18:21 Neil Jerram [this message]
2005-10-13 18:40 ` Modified load-path proposal Greg Troxel
2005-10-13 22:08 ` Neil Jerram
2005-10-14 0:37 ` Greg Troxel
2005-10-14 1:28 ` Andreas Rottmann
2005-10-15 11:17 ` Neil Jerram
2005-10-15 15:03 ` Greg Troxel
2005-10-15 17:53 ` Neil Jerram
2005-10-22 23:16 ` Kevin Ryde
2005-10-28 17:45 ` Neil Jerram
2005-10-30 18:04 ` Neil Jerram
2005-10-30 18:15 ` Tomas Zerolo
2005-10-30 20:37 ` Thien-Thi Nguyen
2005-10-30 22:59 ` Neil Jerram
2005-10-31 10:55 ` Thien-Thi Nguyen
2005-10-31 19:22 ` Neil Jerram
2005-11-08 12:37 ` Thien-Thi Nguyen
2005-10-31 13:17 ` Tomas Zerolo
2005-10-30 23:48 ` Kevin Ryde
2005-10-31 13:20 ` Tomas Zerolo
2005-10-31 19:20 ` Neil Jerram
2005-10-31 23:54 ` Kevin Ryde
2005-11-12 9:47 ` Neil Jerram
2005-11-01 23:31 ` Vorfeed Canal
2005-11-12 17:54 ` Neil Jerram
2005-11-02 8:44 ` Ludovic Courtès
2005-12-03 13:05 ` Neil Jerram
2005-12-13 8:38 ` Ludovic Courtès
2005-12-16 0:16 ` Neil Jerram
2005-12-16 1:00 ` Neil Jerram
2005-12-16 9:55 ` Ludovic Courtès
2006-01-07 13:37 ` Neil Jerram
2006-01-11 4:49 ` steve tell
2006-01-12 18:01 ` Neil Jerram
2005-10-15 11:24 ` Neil Jerram
2005-10-15 15:01 ` Greg Troxel
2005-10-15 17:49 ` Neil Jerram
2005-10-14 7:24 ` Ludovic Courtès
2005-10-15 11:55 ` Neil Jerram
2005-10-15 15:40 ` Greg Troxel
2005-10-17 8:04 ` Ludovic Courtès
2005-10-17 17:52 ` Greg Troxel
2005-10-18 8:23 ` Search path for C libraries Ludovic Courtès
2005-10-18 10:12 ` Vorfeed Canal
2005-10-17 17:54 ` Modified load-path proposal Neil Jerram
2005-10-18 7:57 ` Ludovic Courtès
2005-10-19 22:30 ` Neil Jerram
2005-10-20 7:56 ` Vorfeed Canal
2005-10-20 8:05 ` Ludovic Courtès
2005-10-20 22:23 ` Neil Jerram
2005-10-21 7:59 ` Ludovic Courtès
2005-10-17 18:10 ` Neil Jerram
2005-10-18 16:16 ` Greg Troxel
2005-10-18 21:24 ` Vorfeed Canal
2005-10-19 22:29 ` Neil Jerram
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878xwx5ld2.fsf@ossau.uklinux.net \
--to=neil@ossau.uklinux.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).