[asdf-devel] Three queries ..

Nikodemus Siivola nikodemus at random-state.net
Wed Aug 5 10:00:10 UTC 2009

2009/8/5 Greg Bennett <gwbennett at sentex.ca>:

> As far as I can see, :pathname in asdf plays the role of :source-pathname.
> In  looking for examples, I found the following in the mcclim.asd file:
> .. ((:module "Tests"
>        :pathname #.(make-pathname :directory '(:relative "Drei" "Tests"))
>   :components
> ..
> And indeed there is a subdirectory Tests of the directory Drei which is
> in the right place
> relative to the opening directory of the .asd file for :relative to make
> sense.
> Q1: Is it possible/permitted to say things like:
>  '(:relative "One" "Two" "Three")
>  to have asdf look two subdirectories down the tree ?

Yes. :FILE components default to directory .asd is in. Subcomponents
of :MODULE components default to the directory named by the module.
:PATHNAME can be used to alter these -- note how above the pathname is
constructed using #.(MAKE-PATHNAME ...). Unless you are _very_
concerned about portability, using #P syntax should works too. (I'm
not sure which implementations pathname parsing McCLIM is guarding
against, but I assume that is why they don't use #P.)

 (:file "foo" :pathname #p"extensions/hax/foo.lisp")

 (:module "quux" :pathname #p"old/2008/09/QUUX/"
          :components ((:file "quux1")
                       (:file "quux2)))

etc are all all legal and expected to work.

> I have been unable to find examples of the use of :output-files in asdf.
> This option
> seems to provide the role of :binary-pathname in mk-defsystem.
> Currently, all tour project's binary files are stored in their own tree
> with its own root but with the structure of the source tree maintained.

There is no :OUTPUT-FILES option: instead the generic function
OUTPUT-FILES is called to determine where to put things.

For example - untested - this should put fasls under build/ directory
in the same place where the .asd file is, with same subdirectory
structure as the sources have:

(defpackage :x-system
  (:use :cl :asdf))

(in-package :x-system)

(defclass x-file (cl-source-file) ())

(defmethod output-files ((op compile-op) (com x-file))
  (let* ((system (component-system com))
         (source-root (pathname-directory (system-source-directory system)))
         (pathname (component-pathname com))
         ;; Splice in "build" beneath the source root.
         (fasl-dir (append source-root
                           (list "build")
                           (subseq (pathname-directory pathname)
                                   (length source-root)))))
    (list (make-pathname :directory fasl-dir
                         :defaults (compile-file-pathname pathname)))))

(defsystem :x
  :components ((:x-file "foo")
               (:module "bar
                        :components ((:x-file "quux)))))

That is, given


the expected result is


> Q2: Does the syntax of :output-files permit this sort of thing ?
>     I would seem to need a statement of the form
>     #.(make-pathname :directory '(:absolute "Whatever"))
>     since this is a separately rooted tree. Unless I find a positive
> answer to Q1, in which
>     case, presumably the syntax of :output-files will be similar and I
> can locate the driving
>     .asd file high enough up in the whole project for everything to be
> relative.

As said, there is no :OUTPUT-FILES -- but you can put things in a
separately rooted tree if you wish. I assume that this is some sort of
internal application, or distributed as binary -- in which case a
separate tree is a non-issue.

ASDF's default assumption is that it is being used with library code
is being distributed to users (or other developers) as source, which
is why putting things in a separately rooted trees is generally
frowned upon. But as said, if you're not distributing the code as
source this is a non-issue.

You may also wish to look at


>  From the code (above) I cut from mcclim.asd it seems that mixed case
> pathnames are
> allowed.
> Q3: Have I misunderstood the on-line manual here ? In discussing
> components it seems
>     insistent on lower case, which I had assumed asdf would 'demand'
> everywhere.

Yes, mixed case _strings_ as component names are expected to work, as
are mixed case pathnames -- barring near-extinct operating systems.


 -- Nikodemus

More information about the asdf-devel mailing list