source: project/wiki/eggref/4/autocompile @ 27150

Last change on this file since 27150 was 27150, checked in by felix winkelmann, 9 years ago

updated autocompile page for 1.0

File size: 4.7 KB
Line 
1[[tags: egg]]
2[[toc:]]
3
4== autocompile
5
6=== Introduction
7
8This extension provides a simple method of writing scripts that
9are compiled on demand. A program named {{chicken-scheme}} takes
10a Scheme file and a number of arguments and if the script has
11not been compiled before or has changed as compared to the last compiled
12version, compiles it, storing the result in a cache in the user's
13{{$HOME}} directory.
14
15
16=== Requirements
17
18[[/eggref/4/matchable|matchable]]
19
20
21=== Usage
22
23Autocompiled scripts should begin like this:
24
25  #!/usr/bin/env chicken-scheme
26 
27  ... code follows here ...
28
29{{chicken-scheme}} takes the MD5 hash of the source file and looks
30it up in the {{$HOME/.chicken-scheme.cache}} directory. If it is
31found, the cached entry is invoked with the remaingin script
32arguments. Otherwise it will be compiled, with compiler output
33redirected to a temporary file and executed after that.
34
35The {{chicken-scheme}} program accepts a few additional options:
36
37  chicken-scheme -list
38
39Lists the contents of the cache directory
40
41  chicken-scheme -purge
42
43Deletes all files in the cache directory. Compiled programs will
44be collected it here and should be periodically purged. This doesn't
45change the behaviour of existing scripts, they simply have to be
46recompiled, which should happen on first use.
47
48Invoking {{chicken-scheme}} with no arguments will simply start
49{{csi(1)}}, the CHICKEN interpreter.
50
51This extension needs the {{md5sum(1)}} program (or {{md5(1)}} on Mac OS X).
52
53You can add additional command-line options by preceding the code
54with special comments, like this:
55
56  #!/usr/bin/env chicken-scheme
57  ;;; AUTOCOMPILE: -X my-reader-extension -O5
58  ...
59
60{{chicken-scheme}} will detect "AUTOCOMPILE" specifications beginning in
61the second source line of the file, up to the first line that does not
62contain such a specification. Specifically, lines matching the following
63regular expression will be detected:
64
65  ^ *;[ ;]*AUTOCOMPILE:
66
67
68=== Environment variables
69
70A few environment variables allow customization of the autocompilation
71mechanism:
72
73  HOME
74
75Your home directory that will contain the cache (the latter is created
76automatically, if it doesn't exist).
77
78  CHICKEN_SCHEME_DEBUG
79
80If set, show progress information during the compilation.
81
82  CHICKEN_SCHEME_OPTIONS
83
84Options passed to {{csc(1)}}. The default options are {{-O2}}.
85
86  CHICKEN_SCHEME_HOOK
87
88The name of a program to be invoked when compiling a script. When
89a program must be compiled, the hook is invoked as a shell command:
90
91  $CHICKEN_SCHEME_HOOK start SOURCEFILE ERRORFILE
92
93{{ERRORFILE}} will receive compiler output and error-messages.
94
95After the compilation, the hook is called as
96
97  $CHICKEN_SCHEME_HOOK end SOURCEFILE ERRORFILE
98
99When the compilation fails, the hook is invoked as
100
101  $CHICKEN_SCHEME_HOOK fail SOURCEFILE ERRORFILE
102
103
104=== License
105
106 Copyright (c) 2009-2012, Felix L. Winkelmann
107 
108 All rights reserved.
109 
110 Redistribution and use in source and binary forms, with or without
111 modification, are permitted provided that the following conditions
112 are met:
113 
114  Redistributions of source code must retain the above copyright
115    notice, this list of conditions and the following disclaimer.
116  Redistributions in binary form must reproduce the above copyright
117    notice, this list of conditions and the following disclaimer in the
118    documentation and/or other materials provided with the distribution.
119  Neither the name of the author nor the names of its contributors
120    may be used to endorse or promote products derived from this
121    software without specific prior written permission.
122 
123 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
124 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
125 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
126 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
127 HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
128 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
129 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
130 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
131 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
132 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
133 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
134
135
136=== Version history
137
138; 1.0 : added detection of "AUTOCOMPILE:" comment lines in file header
139; 0.9 : fixed NetBSD-specific option to {{md5}} [thanks to Peter Bex]
140; 0.7 : added regex dependency
141; 0.6 : uses {{md5(3)}} program on NetBSD/FreeBSD/OpenBSD/Dragonfly
142; 0.5 : added missing import
143; 0.2 : fixed stupid typo in setup script; hacked around problem with srfi-13 syntax reexport
144; 0.1 : initial release
Note: See TracBrowser for help on using the repository browser.