You are looking at historical revision 21727 of this page. It may differ significantly from its current revision.
Load and optionally compile groups of files.
A /system/ is a group of files, loaded and/or compiled together, possibly with interdependencies between particular files. This facility is heavily inspired by the Common Lisp DEFSYSTEM macro.
A /component/ is part of a system, usually a source-file.
Systems can be loaded into the interpreter or a compiled application. Re-loading will automatically track dependencies and source-file timestamps to compile and reload only files that have been modified, or which depend on other files that have been modified.
define-system[syntax] (define-system NAME COMPONENT ...)
Defines a system with the given name and components. This form expands roughly into:
(define NAME (make <system> ...))
NAME should be a symbol, COMPONENT should either be an instance of <file> (or one of its subclasses) or a string or symbol, which is an abbreviation of (scheme-file COMPONENT).
load-system[procedure] (load-system SYSTEM #!key quiet force)
Loads changed components in SYSTEM. If the system hasn't been loaded before, all components will be loaded, in the order given in the define-system form, possibly modified by interdependencies between components. By default components of class <scheme-file> will not be compiled, only loaded. Components of class <compiled-scheme-file> will always be compiled and loaded, if necessary. Components of class <file> will be ignored.
compile-system[procedure] (compile-system SYSTEM #!key quiet force)
Compiles components of SYSTEM that are components of class <scheme-file> or one of its subclasses using compile-file and loads them after successfull compilation unless a compiled version of the component is already loaded and none of its dependencies or included files have changed.
clean-system[procedure] (clean-system SYSTEM)
Clears the state of all files in SYSTEM, so a following load-system or compile-system will reload/compile everything.
build-system[procedure] (build-system SYSTEM)
Compiles components that are subclasses of <scheme-file> to dynamically loadable object files (using csc -s ...). Note that these files are ignored by load-system or compile-system, since these are not re-loadable on all supported platforms.
Use this operation for building compiled code that is installed as an extension or explicitly loaded by an application or Scheme script. In such a situation, build-system is similar to the make(1) tool or the make macro provided by the setup-api module.
File-constructors create components that are used inside a system definition or when specifying dependencies or included files.[procedure] (file NAME #!key depends includes path)
[procedure] (scheme-file NAME #!key depends includes path)
[procedure] (compiled-scheme-file NAME #!key depends includes path)
Construct instances of <file>, <scheme-file> and compiled-scheme-file, respectively.
The following toplevel commands are defined when this extension is loaded into csi:
Evaluates EXPRESSION and sets an internal parameter, marking this as the current system.
Loads the current system, using load-system.
Compiles the currents system, using compile-system.
This extension exposes various classes and generic functions that allow customization and subclassing of components and systems. For more information, consult the source code.
Provided we have this system definition in xyz.system:
;;;; xyz.system (define-system xyz (file "z") (scheme-file "y" includes: '("z")) (compiled-scheme-file "x" depends: '("y")))
Using the system in csi:
> (use system posix) > (load "xyz.system") > (load-system xyz) ; xyz: file "y" needs to be reloaded because it hasn't been loaded yet ; loading y.scm ... ; including z.scm ... ; xyz: dependency of "x" changed ; compiling x.scm ... ; loading /tmp/temp317d.so ... > (load-system xyz) ; xyz: nothing to do. > (define (touch . files) (for-each (lambda (f) (set! (file-modification-time f) (current-seconds))) files)) > (sleep 2) > (touch "z.scm") > (load-system xyz) ; xyz: file "y" needs to be reloaded because included file has changed ; loading y.scm ... ; including z.scm ... ; xyz: dependency of "x" changed ; compiling x.scm ... ; loading /tmp/tempcaf8.so ... > (load-system xyz) ; xyz: nothing to do. > (load-system xyz force: #t) ; xyz: file "y" needs to be reloaded because it hasn't been loaded yet ; loading y.scm ... ; including z.scm ... ; xyz: dependency of "x" changed ; compiling x.scm ... ; loading /tmp/temp8a25.so ...
- 0.5 Added shell dependency
- 0.4 ,ls and ,cs toplevel commands ask for system expression if none has been previously defined with ,sys
- 0.3 Fixed bug in handling of changed in dependencies
- 0.2 Added build-system and documented file-constructors
- 0.1 Initial release
Copyright (c) 2010, Felix L. Winkelmann All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.