I tried to specify a build-time dependency for ASDF system, and failed.
The defsystem option
:depends-on systems
makes “systems” both build-time and runtime dependencies of a system being defined. I'm interested in specifying a dependency that is required at build time only.
I attempted
(defsystem "test-toplevel-in-order-deps" :in-order-to ((compile-op (load-op "some-macros"))) :components ((:file "a") (:file "b")))
but this way, some-macros is loaded too late:
(let ((system (find-system "test-toplevel-in-order-deps"))) (plan-actions (make-plan 'sequential-plan 'compile-op system))) ;; =>
((#<PREPARE-OP > . #<SYSTEM "test-toplevel-in-order-deps">) (#<PREPARE-OP > . #<CL-SOURCE-FILE "test-toplevel-in-order-deps" "a">) (#<COMPILE-OP > . #<CL-SOURCE-FILE "test-toplevel-in-order-deps" "a">) (#<PREPARE-OP > . #<CL-SOURCE-FILE "test-toplevel-in-order-deps" "b">) (#<COMPILE-OP > . #<CL-SOURCE-FILE "test-toplevel-in-order-deps" "b">) (#<PREPARE-OP > . #<SYSTEM "some-macros">) ... (#<LOAD-OP > . #<SYSTEM "some-macros">) (#<COMPILE-OP > . #<SYSTEM "test-toplevel-in-order-deps">))
I'm not requesting a feature but still, it's unfortunate that a seemingly basic task of specifying build-time dependency is unachievable in ASDF.
My hypothesis is, if (compile-op . parent) depends on “actions”, then compiling children of parent should depend on “actions” as well, and similarly for all instances of downward-operation. I'm not sure what's the best way to implement this but I wonder if you find this reasonable in the first place.
This problem is happening because of a (common) misunderstanding about what it means to apply an operator to a parent component.
If you have a parent component, P, and serial children C1, C2, C3, then a simple downward-operation O will generate this plan:
``` (O . C1) (O . C2) (O . C3) (O . P) ```
So ASDF does a *postorder* traversal of the component tree which gives the results which you report (and which you do not like).
To get the macros loaded at the proper time, you could do the following:
:in-order-to ((prepare-op (load-op "some-macros")))
But this will not do what you want because it will *always* load `some-macros` rather than skipping the load when the compile-op is already done.
I don't believe that what you ask for can easily be done because if you try to load a system, ASDF will *always* put the `compile-op` into the plan -- but it will notice that the `compile-op` is `already-done-p`, and not `perform` the operation.
If you really want to do this, you should probably set up your own compile-op like operation that will be done in a separate phase, and for which you can make your own rules (like the way one can translate protobuf specifications with an external compiler).
On 21 Jun 2021, at 7:57, akater wrote:
I tried to specify a build-time dependency for ASDF system, and failed.
The defsystem option
:depends-on systems
makes “systems” both build-time and runtime dependencies of a system being defined. I'm interested in specifying a dependency that is required at build time only.
I attempted
(defsystem "test-toplevel-in-order-deps" :in-order-to ((compile-op (load-op "some-macros"))) :components ((:file "a") (:file "b")))
but this way, some-macros is loaded too late:
(let ((system (find-system "test-toplevel-in-order-deps"))) (plan-actions (make-plan 'sequential-plan 'compile-op system))) ;; =>
((#<PREPARE-OP > . #<SYSTEM "test-toplevel-in-order-deps">) (#<PREPARE-OP > . #<CL-SOURCE-FILE "test-toplevel-in-order-deps" "a">) (#<COMPILE-OP > . #<CL-SOURCE-FILE "test-toplevel-in-order-deps" "a">) (#<PREPARE-OP > . #<CL-SOURCE-FILE "test-toplevel-in-order-deps" "b">) (#<COMPILE-OP > . #<CL-SOURCE-FILE "test-toplevel-in-order-deps" "b">) (#<PREPARE-OP > . #<SYSTEM "some-macros">) ... (#<LOAD-OP > . #<SYSTEM "some-macros">) (#<COMPILE-OP > . #<SYSTEM "test-toplevel-in-order-deps">))
I'm not requesting a feature but still, it's unfortunate that a seemingly basic task of specifying build-time dependency is unachievable in ASDF.
My hypothesis is, if (compile-op . parent) depends on “actions”, then compiling children of parent should depend on “actions” as well, and similarly for all instances of downward-operation. I'm not sure what's the best way to implement this but I wonder if you find this reasonable in the first place.
Robert P. Goldman Research Fellow Smart Information Flow Technologies (d/b/a SIFT, LLC)
319 N. First Ave., Suite 400 Minneapolis, MN 55401
Voice: (612) 326-3934 Email: rpgoldman@SIFT.net