Newer
Older
Francois-Rene Rideau
committed
===========================
Common Lisp Source Registry
===========================
Francois-Rene Rideau
committed
This file specifies how build systems such as ASDF and XCVB
may be configured with respect to filesystem paths
where to search for Common Lisp source code.
Francois-Rene Rideau
committed
Configurations
==============
Francois-Rene Rideau
committed
Configurations specify paths where to find system files.
Francois-Rene Rideau
committed
1- An application may explicitly initialize the source-registry
configuration using the `Configuration API`_ below,
in which case this takes precedence.
It may itself compute this configuration from the command-line,
from a script, from its own configuration file, etc.
Francois-Rene Rideau
committed
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
2- The source registry will be configured from
the environment variable ``CL_SOURCE_REGISTRY`` if it exists.
3- The source registry will be configured from
user configuration file
``~/.config/common-lisp/source-registry.conf``
if it exists.
4- The source registry will be configured from
system configuration file
``/etc/common-lisp/source-registry.conf``
if it exists.
5- The source registry will be configured from a default configuration,
which allows for implementation-specific software to be searched.
(See below `Backward Compatibility`_).
Each of these configuration is specified as a SEXP
in a trival domain-specific language (defined below).
Additionally, a more shell-friendly syntax is available
for the environment variable (defined yet below).
Backward Compatibility
======================
For backward compatibility, ASDF will fall back to its old ways
if it fails to find a configuration for the source registry, or
if it fails to find a requested system in the configured source registry.
This new mechanism will therefore not affect you if you don't use it,
but will take precedence over the old mechanism if you do use it.
For the record, with the old mechanism, ASDF will first look
(on SBCL only) for a matching system in the implementation-specific
``contrib`` directory. Then (on all implementations) it will look
at your ``asdf:*central-registry*`` and search in the directories
specified there.
Configuration DSL
=================
Francois-Rene Rideau
committed
Here is the grammar of the SEXP DSL for source-registry configuration:
;; A configuration is single SEXP starting with keyword :source-registry
;; followed by a list of directives.
CONFIGURATION := (:source-registry DIRECTIVE ...)
;; A directive is one of the following:
DIRECTIVE :=
;; add a single directory to be scanned (no recursion)
(:directory DIRECTORY-PATHNAME-DESIGNATOR) |
;; add a directory hierarchy, recursing but excluding specified patterns
Francois-Rene Rideau
committed
(:tree DIRECTORY-PATHNAME-DESIGNATOR) |
;; override the default defaults for exclusion patterns
Francois-Rene Rideau
committed
(:exclude PATTERN ...) |
;; splice the parsed contents of another config file
Francois-Rene Rideau
committed
(:include REGULAR-FILE-PATHNAME-DESIGNATOR) |
Francois-Rene Rideau
committed
;; Your configuration expression MUST contain exactly one of either of these:
(:inherit-configuration) | ; splices contents of inherited configuration
(:ignore-inherited-configuration) ; drop contents of inherited configuration
;; This directive specifies that some default must be spliced.
(:default-registry)
PATTERN := a string without wildcards, that will be matched exactly
Francois-Rene Rideau
committed
against the name of a any subdirectory in the directory component of a path.
e.g. "_darcs" will match #p"/foo/bar/_darcs/src/bar.asd"
Francois-Rene Rideau
committed
Shell-friendly syntax for configuration
=======================================
Francois-Rene Rideau
committed
When considering environment variable ``CL_SOURCE_REGISTRY``
ASDF will skip to next configuration if it's an empty string.
It will ``READ`` the string as a SEXP in the DSL
if it begins with a paren ``(``
and it will be interpreted much like ``TEXINPUTS``
as ``:`` (colon) separated list of paths, where
* each entry is a directory to add to the search path.
* if the entry ends with a double slash ``//``
then it instead indicates a tree in the subdirectories of which to recurse.
* if the entry is the empty string (which may only appear once),
then it indicates that the inherited configuration should be spliced there.
Search Algorithm
================
Francois-Rene Rideau
committed
In case that isn't clear, the semantics of the configuration is that
when searching for a system of a given name, directives are processed in order.
Francois-Rene Rideau
committed
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
When looking in a directory, if the system is found, the search succeeds,
otherwise it continues.
When looking in a tree, if one system is found, the search succeeds.
If multiple systems are found, the consequences are unspecified:
the search may succeed with any of the found systems,
or an error may be raised.
ASDF currently returns the first system found,
XCVB currently raised an error.
If none is found, the search continues.
Exclude statements specify patterns of subdirectories the systems of which
to ignore. Typically you don't want to use copies of files kept by such
version control systems as Darcs.
Include statements cause the search to recurse with the path specifications
from the file specified.
An inherit-configuration statement cause the search to recurse with the path
specifications from the next configuration (see section Configurations_ above).
Caching Results
===============
The implementation is allowed to either eagerly compute the information
from the configurations and file system, or to lazily re-compute it every time,
or to cache any part of it as it goes.
To explicitly flush any information cached by the system, use the API below.
Configuration API
=================
Francois-Rene Rideau
committed
The specified functions are exported from your build system's package.
Thus for ASDF the corresponding functions are in package ASDF,
and for XCVB the corresponding functions are in package XCVB.
(initialize-source-registry)
Francois-Rene Rideau
committed
will read the configuration and initialize all internal variables.
(clear-source-registry)
Francois-Rene Rideau
committed
undoes any source registry configuration
and clears any cache for the search algorithm.
You might want to call that before you
dump an image that would be resumed with a different configuration,
and return an empty configuration.
Francois-Rene Rideau
committed
Note that this does not include clearing information about systems defined
in the current image, only about where to look for systems not yet defined.
(ensure-source-registry)
Francois-Rene Rideau
committed
checks whether a source registry has been initialized.
If not, initialize it.
This function will be called before any attempt to find a system
in the source registry.
If your application wants to override the provided defaults,
it will have to use the below function process-source-registry.
(process-source-registry X &key inherit collect)
If X is a CONS, parse it as a SEXP in the configuration DSL,
and extend or override inheritted configuration.
Francois-Rene Rideau
committed
If X is a STRING, first parse it into a SEXP as for the CL_SOURCE_REGISTRY
environment variable (see above) then process it.
If X is a PATHNAME, read the file as a single SEXP and process it.
The inheritted configuration is provided in keyword argument inherit,
itself a list of functions that take inherit and collect keyword arguments
and defaulting to a list of functions that implements the default behavior.
Francois-Rene Rideau
committed
Future
======
Francois-Rene Rideau
committed
If this mechanism is successful, in the future, we may declare
``asdf:*central-registry*`` obsolete and eventually remove it.
Any hook into implementation-specific search mechanisms will by then
have been integrated in the ``:default-configuration`` which everyone
should either explicitly use or implicit inherit. Some shell syntax
for it should probably be added somehow.
Francois-Rene Rideau
committed
But we're not there yet. For now, let's see how practical this new
source-registry is.
Francois-Rene Rideau
committed
Rejected ideas
==============
Francois-Rene Rideau
committed
Alternatives I considered and rejected included:
Francois-Rene Rideau
committed
1- Keep asdf:*central-registry* as the master with its current semantics,
and somehow the configuration parser expands the new configuration
language into a expanded series of directories of subdirectories to
lookup, pre-recursing through specified hierarchies. This is kludgy,
and leaves little space of future cleanups and extensions.
Francois-Rene Rideau
committed
2- Keep asdf:*central-registry* remains the master but extend its semantics
in completely new ways, so that new kinds of entries may be implemented
as a recursive search, etc. This seems somewhat backwards.
Francois-Rene Rideau
committed
3- Completely remove asdf:*central-registry* and break backwards compatibility.
Hopefully this will happen in a few years after everyone migrate to
a better ASDF and/or to XCVB, but it would be very bad to do it now.
Francois-Rene Rideau
committed
4- Replace asdf:*central-registry* by a symbol-macro with appropriate magic
when you dereference it or setf it. Only the new variable with new
semantics is handled by the new search procedure.
I've been suggested the below features, but have rejected them,
for the sake of keeping ASDF no more complex than strictly necessary.
* More syntactic sugar: synonyms for the configuration directives, such as
(:add-directory X) for (:directory X), or (:add-directory-hierarchy X)
or (:add-directory X :recurse t) for (:tree X).
* The possibility to register individual files instead of directories.
* Integrate Xach Beane's tilde expander into the parser,
or something similar that is shell-friendly or shell-compatible.
I'd rather keep ASDF minimal. But maybe this precisely keeps it
minimal by removing the need for evaluated entries that ASDF has?
i.e. uses of USER-HOMEDIR-PATHNAME and $SBCL_HOME
Hopefully, these are already superseded by the :default-registry
Francois-Rene Rideau
committed
* Using the shell-unfriendly syntax /** instead of // to specify recursion
down a filesystem tree in the environment variable.
It isn't that Lisp friendly either.
Francois-Rene Rideau
committed
Credits
=======
Thanks a lot to Stelian Ionescu for the initial idea.
Thanks to Rommel Martinez for the initial implementation attempt.
Francois-Rene Rideau
committed
All bad design ideas and implementation bugs are to mine, not theirs.
But so are good design ideas and elegant implementation tricks.
Francois-Rene Rideau
committed
-- Francois-Rene Rideau <fare@tunes.org>, Mon, 18 Jan 2010 14:12:57 -0500