Consider an example system,
, defined as follows:
(defsystem demo (:package "USER")
:rules ((:in-order-to :compile ("child1" "child2")
(:caused-by (:compile "parent"))
(:requires (:load "parent")))))
This system compiles and loads members into the
package if the members themselves do not specify packages. The system contains three members --
-- which may themselves be either files or other systems. There is only one explicit rule in the example. If
needs to be compiled (for instance, if it has been changed), then this causes
to be compiled as well, irrespective of whether they have themselves changed. In order for them to be compiled,
must first be loaded.
Implicitly, it is always the case that if any member changes, it needs to be compiled when you compile the system. The explicit rule above means that if the changed member happens to be
member gets compiled. If the changed member is not
must at least be loaded before compiling takes place.
The next example shows a system consisting of three files:
:members ("a" "b" "c")
:rules ((:in-order-to :compile ("c")
(:requires (:load "a"))
(:caused-by (:compile "b")))))
What plan is produced when all three files have already been compiled, but the file
has since been changed?
is considered. This file has already been compiled, so no instructions are added to the plan.
is considered. Since this file has changed, the instruction
is added to the plan.
is considered. Although this has already been compiled, the clause
(:caused-by (:compile "b"))
causes the instruction
to be added to the plan. The compilation of
also requires that
is loaded, so the instruction
is added to the plan first. This gives us the following plan:
This last example shows how to make each fasl get loaded immediately after compiling it:
(defsystem my-system ()
:members ("foo" "bar" "baz" "quux")
:rules ((:in-order-to :compile :all
(:requires (:load :previous)))))
(compile-system my-system :load t)