[pro] library configuration

Faré fahree at gmail.com
Tue Jun 28 17:52:40 UTC 2011


On 28 June 2011 13:38, Pascal Costanza <pc at p-cos.net> wrote:
>
> On 28 Jun 2011, at 17:49, Zach Beane wrote:
>
>> Faré <fahree at gmail.com> writes:
>>
>>>> I am looking for a portable way to specify configuration for a library
>>>> before/during loading with ASDF2.  It would be sufficient if the user
>>>> could specify an ALIST (or something similar) somewhere and I could read/
>>>> use it when the library is loaded.  Does ASDF2 have a "standard"
>>>> mechanism for library config files (eg where they are, how to handle them
>>>> etc), or should I use something else?  I thought of using *features*, but
>>>> I need actual values instead of merely checking for the presence of
>>>> symbols.
>>>>
>>> ASDF (1 or 2) does not handle C libraries. Extensions to ASDF do.
>>
>> The question is not about C libraries, but how to express and manage
>> configuration options that must be initialized before the library is
>> built.
>>
>> I think the answer for ASDF is "there is no way to express or manage any
>> library configuration decisions."
>>
>> Hunchentoot also has this issue regarding building with SSL, and manages
>> it by checking for :hunchentoot-no-ssl in cl:*features*. For a
>> non-boolean option, that's not a workable approach.
>
> One could use a global variable that stores one's own configuration option, for example as a plist or alist. This would have to be in the common-lisp-user package, and theoretically clashes with other such variables. However, this is not substantially worse than potential clashes of keyword symbols in *features*. Just use a name that is unlikely to be used by others (for example, by using the ASDF/package name with an -OPTIONS suffix, or some such).
>
> boundp is your friend to check whether the variable is actually defined, which could either yield a warning, or assume default options.
>
> Pascal
>
What's so special about Lisp here? How do other languages do it?

If it's about libraries that are shared by everyone using the standard
C ABI, then shouldn't it all "just work", using the LD_LIBRARY_PATH
and other standard configuration files, and/or paths wired into your
object files?

If it's about wrapper libraries created by cffi-grovel, then ASDF will
load them from wherever the fasl cache is defined. This doesn't play
very well with distribution of binaries (as opposed to distribution of
source), but at least it should "do the right thing", and the basic
configuration knobs are there if you want to do better.

Or maybe what you want is some way to specify C compiler flags for
cffi-grovel? This is currently done through the
cffi-grovel::*cc-flags* special variable.

Now, if you want to somehow have per-user configuration, overridable
with an environment variable and/or an explicit programmer parameter,
I recommend that you use the same conventions as currently used by
ASDF 2 and read configuration from a file in the same directory. You
may copy/paste code from ASDF 2, and/or I will happily refactor the
code so that it may be used by ASDF extensions as well as by ASDF
itself.

—♯ƒ • François-René ÐVB Rideau •Reflection&Cybernethics• http://fare.tunes.org




More information about the pro mailing list