All Manuals > LispWorks User Guide and Reference Manual > 40 The LISPWORKS Package

NextPrevUpTopContentsIndex

defsystem

Macro
Summary

defsystem is used to define systems for use with the LispWorks system tools. A system is a collection of files and other systems that, together with rules expressing the interdependencies of those files and subsystems, make a complete program. The LispWorks system tools support the development and maintenance of large programs. Find a full description at Common Defsystem and ASDF.

Package

lispworks

Signature

defsystem name options &key members rules => system-name

Arguments

name

A string or a symbol, not evaluated.

options

A list of keyword-value pairs.

members

A list of strings or lists.

rules

A list.

Values

system-name

A string.

Description

The name of the system to be made is a string specified by name. If name is a symbol, then its symbol name is used.

options are expressed as a list of keyword-value pairs. The following keywords are recognized:

:package

The default package that files are compiled and loaded in. If not specified, this defaults to the value of *package* at macroexpansion time.

:default-pathname

Used to compute a default pathname in which to find files. defsystem uses current-pathname to compute the pathname. defsystem checks that all the files given as members actually exist.

:default-host

The root pathname of a system is defined to be the :default-host if it is given. Otherwise, it is taken to be the directory containing the defsystem file.

Absolute pathnames are interpreted literally, and relative pathnames are taken relative to the root pathname.

:default-type

This is the default type of the members of the system. This may be :lisp-file, :lsp-file, :c-file, or :system.

The corba module adds :idl-file, :idl-client-definition, :idl-client-definition-only, :idl-server-definition and :idl-server-definition-only.

The com module adds the type :midl-file and the automation module adds :midl-type-library-file.

The default is :lisp-file, which means files with file type (extension) "lisp".

:documentation

This is a string.

:object-pathname

A string or pathname specifying a directory where object files are written.

Note: This option will not work if the names in members represent absolute pathnames.

:optimize

A declaration specifying default compilation qualities within the scope of compile-system. These settings override the current global setting. They can be overridden per member by the :optimize option (for subsystems) or proclaim (in files). The :optimize defsystem option accepts the same optimize qualities as proclaim and which are fully described in Compiler control. See below for examples.

members is a list defining the members of the system. Elements of the list may be a string name representing the name of the physical file or system referred to. Elements of the list may also be a symbol, which is interpreted as its symbol name.

Elements of the members list can also be a list of the form (name {keyword value}*) where name is once again a string or a symbol naming a file or system.

The members of the system name must have unique names, as compared by equalp. For example, if members contains "foo" then there cannot be another member (either a file or a system) named "foo", "FOO" or foo.

The possible keywords and their values are:

:type

The type of this member. Allowed values are as for :default-type. If not specified it defaults to the value of :default-type given as an option.

:root-module

If nil then this member is not loaded unless its loading is specifically requested as a result of a dependency on another module

:source-only

Only the source file for this member is ever loaded

:load-only

The member is never compiled by defsystem, objects are loaded in preference to source files

:load-for-compile-only

The member is only loaded as necessary during compilation and is never loaded independently

:features

The member is only considered during planning if the feature expression is true.

:package

A default package for the member.

:embedded-module

Only allowed when the value for :type is :c-file. The value embedded-module is used to create a FLI embedded module named embedded-module instead of loading the object file. See fli:install-embedded-module in the LispWorks Foreign Language Interface User Guide and Reference Manual for how to load the embedded module.

On Windows, the automation module adds the keyword :com for a member with type :midl-type-library-file. Then a member of the form

("mso97.tlb" :type :midl-type-library-file :com nil)

can be specified when you use only Automation client code, reducing the memory used.

rules is a list of rules of the following format :

({:in-order-to} action
 {:all | ({ member-name
 }* )}
  (:caused-by {(action
 {:previous |{member-name
 }* }) }*)
  (:requires {(action
 {:previous |{ member-name
 }*}) }*)) 

The keyword :all refers to all the members of the system. It provides a shorthand for specifying that a rule should apply to all the system's members. The keyword :previous refers to all the members of the system that are before the member in the list of members. This makes it easy, for example, to specify that in order to compile a file in a system, all the members that come before it must be loaded.

The name of the system is returned.

There are more details about the rules in DEFSYSTEM rules.

Examples
(defsystem defsys-macros
   (:default-pathname "/usr/users/james/scm/defsys/" 
    :default-type :lisp-file
    :package defsystem)
   :members ("new-macros"
             "scm-timemacros"))
(defsystem clos-sys
   (:default-pathname "/usr/users/clc/defsys/"
    :default-type :lsp-file
    :package defsystem)
   :members
     (("defsys-macros" :type :system :root-module nil)
       "class"
       "time-methods"
      ("scm-pathname" :source-only t)
       "execute-plan"
       "file-types"
       "make-system"
       "conv-defsys")
   :rules
     ((:in-order-to :compile ("class" "time-methods")
           (:caused-by (:compile "defsys-macros"))
                       (:requires 
                         (:load "defsys-macros")))
      (:in-order-to :compile 
                       ("time-methods" "execute-plan")
                       (:requires (:load "class")))))
(defsystem dataworks-demo 
   (:default-type :system)
   :members (
     "db-class"
     "planar"
     "dataworks-dep"
     "dataworks-interface-tk"
     "dataworks-interface-tools"
     "drugs-demo"
     ("gen-demo" :type :lisp-file)
     ("load-icon" :type :lisp-file :source-only t)
     )
   :rules ((:in-order-to :compile :all
 (:requires (:load :previous)))))

This example illustrates the use of :optimize.

(defsystem foo (:optimize ((speed 3) (space 3) 
                           (safety 0)))
  :members ("bar"
            "baz")
  :rules ((:compile :all 
           (:requires (:load :previous)))))

This last example illustrates the use of :embedded-module.

(defsystem my-foreign-code ()
  :members
  (("my-c-code.c" :type :c-file
                  :embedded-module my-module)))

Then initialize at runtime with

(fli:install-embedded-module 'my-module)
Notes
  1. Subsystems must be defined before any system of which they are part.
  2. The order of members is important and reflects the order in which operations are carried out on the members of the system, subject to the rules.
See also

load-system
compile-system
concatenate-system
current-pathname
*defsystem-verbose*


LispWorks User Guide and Reference Manual - 13 Feb 2015

NextPrevUpTopContentsIndex