This extension provides a simple method of writing scripts that are compiled on demand. A program named chicken-scheme takes a Scheme file and a number of arguments and if the script has not been compiled before or has changed as compared to the last compiled version, compiles it, storing the result in a cache in the user's $HOME directory.
Autocompiled scripts should begin like this:
#!/usr/bin/env chicken-scheme ... code follows here ...
chicken-scheme takes the MD5 hash of the source file and looks it up in the $HOME/.chicken-scheme.cache directory. If it is found, the cached entry is invoked with the remaingin script arguments. Otherwise it will be compiled, with compiler output redirected to a temporary file and executed after that.
The chicken-scheme program accepts a few additional options:
Lists the contents of the cache directory
Deletes all files in the cache directory. Compiled programs will be collected it here and should be periodically purged. This doesn't change the behaviour of existing scripts, they simply have to be recompiled, which should happen on first use.
Invoking chicken-scheme with no arguments will simply start csi(1), the CHICKEN interpreter.
This extension needs the md5sum(1) program (or md5(1) on Mac OS X).
You can add additional command-line options by preceding the code with special comments, like this:
#!/usr/bin/env chicken-scheme ;;; AUTOCOMPILE: -X my-reader-extension -O5 ...
chicken-scheme will detect "AUTOCOMPILE" specifications beginning in the second source line of the file, up to the first line that does not contain such a specification. Specifically, lines matching the following regular expression will be detected:
^ *;[ ;]*AUTOCOMPILE:
A few environment variables allow customization of the autocompilation mechanism:
Your home directory that will contain the cache (the latter is created automatically, if it doesn't exist).
If set, show progress information during the compilation.
Options passed to csc(1). The default options are -O2.
The name of a program to be invoked when compiling a script. When a program must be compiled, the hook is invoked as a shell command:
$CHICKEN_SCHEME_HOOK start SOURCEFILE ERRORFILE
ERRORFILE will receive compiler output and error-messages.
After the compilation, the hook is called as
$CHICKEN_SCHEME_HOOK end SOURCEFILE ERRORFILE
When the compilation fails, the hook is invoked as
$CHICKEN_SCHEME_HOOK fail SOURCEFILE ERRORFILE
Copyright (c) 2009-2012, 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.
- ported to CHICKEN 5 (contributed by Vasilij Schneidermann)
- added detection of "AUTOCOMPILE:" comment lines in file header
- fixed NetBSD-specific option to md5 [thanks to Peter Bex]
- added regex dependency
- uses md5(3) program on NetBSD/FreeBSD/OpenBSD/Dragonfly
- added missing import
- fixed stupid typo in setup script; hacked around problem with srfi-13 syntax reexport
- initial release