Let's suppose the following files tree:
foo -+- foo.lisp
|- dir - bar.lisp
I want to make a foo.asd file and make it useable through asdf.
(defsystem foo
:name foo
:components ((:file "foo")
(:module dir
:components ((:file "bar")))))
I know how to specify dependencies for files in the same module or
dependencies accross modules, but how to specify the dir/bar.lisp
depends on foo.lisp file ?
-Nicolas
Nicolas EDEL <············@gmail.com> writes:
> Let's suppose the following files tree:
>
> foo -+- foo.lisp
> |- dir - bar.lisp
>
>
> I want to make a foo.asd file and make it useable through asdf.
>
> (defsystem foo
> :name foo
> :components ((:file "foo")
> (:module dir
> :components ((:file "bar")))))
>
> I know how to specify dependencies for files in the same module or
> dependencies accross modules, but how to specify the dir/bar.lisp
> depends on foo.lisp file ?
By default, dependencies in ASDF are scoped to the parent module that
contains the component. It happens that the mechanism for resolving
dependencies is a generic function that's exported from ASDF, so in
theory the dependency resolution mechanism is customizable.
Below is a lightly-tested, hasty implementation of a way to get a flat
component namespace for dependency resolution. It seems to do what I
want it to do, but it might also do things I don't want it to do; and in
any case you might want different things anyhow.
Good luck,
Richard
(defpackage #:foo-system (:use #:cl #:asdf))
(in-package #:foo-system)
(defclass flat-namespace-module (module) ()
(:documentation "A module in which all descendant components share one
namespace."))
(defmethod find-component ((module flat-namespace-module) name
&optional version)
(labels ((depth-first-find-component (module name)
(loop for component in (module-components module)
if (equal name (component-name component))
return component
if (typep component 'module)
when (depth-first-find-component component name)
return it)))
(if (typep (component-parent module) 'flat-namespace-module)
(find-component (component-parent module) name version)
(let ((component (depth-first-find-component module name)))
(if (and component
(asdf::version-satisfies component version))
component)))))
(defclass flat-namespace-system (flat-namespace-module system) ())
;; Create two files, "foo.lisp" and "bar/baz.lisp" beside this .asd
;; file, for testing. Then do a compile-op, munge foo.lisp, and another
;; compile-op should recompile both foo and bar/baz.
(defsystem foo
:class flat-namespace-system
:components ((:file "foo")
(:flat-namespace-module
"bar"
:components ((:file "baz" :depends-on ("foo"))))))
On Oct 9, 5:56 pm, Richard M Kreuter <·······@progn.net> wrote:
> Nicolas EDEL <············@gmail.com> writes:
> > [...]
>
> By default, dependencies in ASDF are scoped to the parent module that
> contains the component. It happens that the mechanism for resolving
> dependencies is a generic function that's exported from ASDF, so in
> theory the dependency resolution mechanism is customizable.
>
> Below is a lightly-tested, hasty implementation of a way to get a flat
> component namespace for dependency resolution. It seems to do what I
> want it to do, but it might also do things I don't want it to do; and in
> any case you might want different things anyhow.
>
> Good luck,
> Richard
>
> [...]
>
Thanks, I'll have a look at this.
-Nicolas