Warm tip: This article is reproduced from stackoverflow.com, please click
common-lisp asdf

(ASDF 3) Is it possible to recursively load systems in subdirectories?

发布于 2020-04-10 16:15:02

I know about using :modules, but what about when systems get nested? Suppose I have the following structure, relative to some unknown user directory:

foo/
-foo.asd
-bar/
--bar.asd

This could arise, for example, when using Git submodules. How shall I configure the (defsystem) call in foo.asd to load bar as a dependency, without modifying a config file outside of foo/ or demanding particular placement for the foo/ tree itself? Feels like it should be simple.

3 Feb. 2020: From @Svante's answer, it sounds like my question is really 'How do I dynamically ensure that foo/ and bar/ both get into the *source-registry*?' The ASDF manual makes me think this should do the trick:

(asdf:initialize-source-registry 
  '(:source-registry 
    (:tree "«absolute-path-to-foo»/")
    :inherit-configuration))

though I have not seen an example of that usage.

26 Mar. 2020: The technique above seems to work fine, so I'm closing this question. ASDF 3 is excellent.

Questioner
Dumaiu
Viewed
41
Svante 2020-02-02 19:27

ASDF doesn't care about relative locations of .asd files. ASDF systems and their dependencies are completely orthogonal to file/directory structure and oblivious to any source version control.

It just looks in several locations for .asd files. Each such file then may contain definitions for systems. It will generally recurse into the configured folders, so any .asd file in a git submodule would usually also be found.

The definitions, e. g. of components, inside of an .asd file then work relatively from the location of that file.

In your example, if you give a :depends-on ("bar") option to the "foo" system, it would just work, no matter where bar.asd resides (as long as it is somewhere where ASDF finds it).

A bit more awareness would be required if you have several versions of a library. This might happen if you work on "foo" and "bar" at the same time, while a stable version of "bar" is also available, e. g. in a quicklisp dist. Then the lookup order comes into play, but usually your “personal” directories have precedence over “system” directories, so again, it would just work. For more control, you might want to look into qlot.