chickadee » system

Outdated egg!

This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.

If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.

system

Description

Load and optionally compile groups of files.

Author

felix winkelmann

Requirements

coops, shell

Documentation

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

(define-system NAME COMPONENT ...)syntax

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

load-system SYSTEM #!key quiet forceprocedure

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

compile-system SYSTEM #!key quiet forceprocedure

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

clean-system SYSTEMprocedure

Clears the state of all files in SYSTEM, so a following load-system or compile-system will reload/compile everything.

build-system

build-system SYSTEMprocedure

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

File-constructors create components that are used inside a system definition or when specifying dependencies or included files.

file NAME #!key depends includes pathprocedure
scheme-file NAME #!key depends includes path optionsprocedure
compiled-scheme-file NAME #!key depends includes path optionsprocedure

Construct instances of <file>, <scheme-file> and compiled-scheme-file, respectively.

depends may be a list of files or strings holding filenames.

includes refers to a single file or filenames that will be included by the component (and thus create a dependency).

path overrides the actual path of the source file, which defaults to NAME.scm.

options specifies a list of strings that should be passed to csc when the file is compiled.

Toplevel commands

The following toplevel commands are defined when this extension is loaded into csi:

 ,sys EXPRESSION

Evaluates EXPRESSION and sets an internal parameter, marking this as the current system.

 ,ls

Loads the current system, using load-system.

 ,cs

Compiles the currents system, using compile-system.

Programming interface

This extension exposes various classes and generic functions that allow customization and subclassing of components and systems. For more information, consult the source code.

Examples

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 ...

History

License

 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.

Contents »