| 1 |
;;; -*- Mode: Lisp; Package: make -*- |
| 2 |
;;; -*- Mode: CLtL; Syntax: Common-Lisp -*- |
| 3 |
|
| 4 |
;;; DEFSYSTEM 3.6 Interim. |
| 5 |
|
| 6 |
;;; defsystem.lisp -- |
| 7 |
|
| 8 |
;;; **************************************************************** |
| 9 |
;;; MAKE -- A Portable Defsystem Implementation ******************** |
| 10 |
;;; **************************************************************** |
| 11 |
|
| 12 |
;;; This is a portable system definition facility for Common Lisp. |
| 13 |
;;; Though home-grown, the syntax was inspired by fond memories of the |
| 14 |
;;; defsystem facility on Symbolics 3600's. The exhaustive lists of |
| 15 |
;;; filename extensions for various lisps and the idea to have one |
| 16 |
;;; "operate-on-system" function instead of separate "compile-system" |
| 17 |
;;; and "load-system" functions were taken from Xerox Corp.'s PCL |
| 18 |
;;; system. |
| 19 |
|
| 20 |
;;; This system improves on both PCL and Symbolics defsystem utilities |
| 21 |
;;; by performing a topological sort of the graph of file-dependency |
| 22 |
;;; constraints. Thus, the components of the system need not be listed |
| 23 |
;;; in any special order, because the defsystem command reorganizes them |
| 24 |
;;; based on their constraints. It includes all the standard bells and |
| 25 |
;;; whistles, such as not recompiling a binary file that is up to date |
| 26 |
;;; (unless the user specifies that all files should be recompiled). |
| 27 |
|
| 28 |
;;; Originally written by Mark Kantrowitz, School of Computer Science, |
| 29 |
;;; Carnegie Mellon University, October 1989. |
| 30 |
|
| 31 |
;;; MK:DEFSYSTEM 3.6 Interim |
| 32 |
;;; |
| 33 |
;;; Copyright (c) 1989 - 1999 Mark Kantrowitz. All rights reserved. |
| 34 |
;;; 1999 - 2005 Mark Kantrowitz and Marco Antoniotti. All |
| 35 |
;;; rights reserved. |
| 36 |
|
| 37 |
;;; Use, copying, modification, merging, publishing, distribution |
| 38 |
;;; and/or sale of this software, source and/or binary files and |
| 39 |
;;; associated documentation files (the "Software") and of derivative |
| 40 |
;;; works based upon this Software are permitted, as long as the |
| 41 |
;;; following conditions are met: |
| 42 |
|
| 43 |
;;; o this copyright notice is included intact and is prominently |
| 44 |
;;; visible in the Software |
| 45 |
;;; o if modifications have been made to the source code of the |
| 46 |
;;; this package that have not been adopted for inclusion in the |
| 47 |
;;; official version of the Software as maintained by the Copyright |
| 48 |
;;; holders, then the modified package MUST CLEARLY identify that |
| 49 |
;;; such package is a non-standard and non-official version of |
| 50 |
;;; the Software. Furthermore, it is strongly encouraged that any |
| 51 |
;;; modifications made to the Software be sent via e-mail to the |
| 52 |
;;; MK-DEFSYSTEM maintainers for consideration of inclusion in the |
| 53 |
;;; official MK-DEFSYSTEM package. |
| 54 |
|
| 55 |
;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 56 |
;;; EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 57 |
;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. |
| 58 |
;;; IN NO EVENT SHALL M. KANTROWITZ AND M. ANTONIOTTI BE LIABLE FOR ANY |
| 59 |
;;; CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 60 |
;;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 61 |
;;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 62 |
|
| 63 |
;;; Except as contained in this notice, the names of M. Kantrowitz and |
| 64 |
;;; M. Antoniotti shall not be used in advertising or otherwise to promote |
| 65 |
;;; the sale, use or other dealings in this Software without prior written |
| 66 |
;;; authorization from M. Kantrowitz and M. Antoniotti. |
| 67 |
|
| 68 |
|
| 69 |
;;; Please send bug reports, comments and suggestions to <[email protected]>. |
| 70 |
|
| 71 |
;;; ******************************** |
| 72 |
;;; Change Log ********************* |
| 73 |
;;; ******************************** |
| 74 |
;;; |
| 75 |
;;; Note: Several of the fixes from 30-JAN-91 and 31-JAN-91 were done in |
| 76 |
;;; September and October 1990, but not documented until January 1991. |
| 77 |
;;; |
| 78 |
;;; akd = Abdel Kader Diagne <[email protected]> |
| 79 |
;;; as = Andreas Stolcke <[email protected]> |
| 80 |
;;; bha = Brian Anderson <[email protected]> |
| 81 |
;;; brad = Brad Miller <[email protected]> |
| 82 |
;;; bw = Robert Wilhelm <[email protected]> |
| 83 |
;;; djc = Daniel J. Clancy <[email protected]> |
| 84 |
;;; fdmm = Fernando D. Mato Mira <[email protected]> |
| 85 |
;;; gc = Guillaume Cartier <[email protected]> |
| 86 |
;;; gi = Gabriel Inaebnit <[email protected]> |
| 87 |
;;; gpw = George Williams <[email protected]> |
| 88 |
;;; hkt = Rick Taube <[email protected]> |
| 89 |
;;; ik = Ik Su Yoo <[email protected]> |
| 90 |
;;; jk = [email protected] |
| 91 |
;;; kt = Kevin Thompson <[email protected]> |
| 92 |
;;; kc = Kaelin Colclasure <[email protected]> |
| 93 |
;;; kmr = Kevin M. Rosenberg <[email protected]> |
| 94 |
;;; lmh = Liam M. Healy <[email protected]> |
| 95 |
;;; mc = Matthew Cornell <[email protected]> |
| 96 |
;;; oc = Oliver Christ <[email protected]> |
| 97 |
;;; rs = Ralph P. Sobek <[email protected]> |
| 98 |
;;; rs2 = Richard Segal <[email protected]> |
| 99 |
;;; sb = Sean Boisen <[email protected]> |
| 100 |
;;; ss = Steve Strassman <[email protected]> |
| 101 |
;;; tar = Thomas A. Russ <[email protected]> |
| 102 |
;;; toni = Anton Beschta <toni%[email protected]> |
| 103 |
;;; yc = Yang Chen <yangchen%[email protected]> |
| 104 |
;;; |
| 105 |
;;; Thanks to Steve Strassmann <[email protected]> and |
| 106 |
;;; Sean Boisen <[email protected]> for detailed bug reports and |
| 107 |
;;; miscellaneous assistance. Thanks also to Gabriel Inaebnit |
| 108 |
;;; <[email protected]> for help with VAXLisp bugs. |
| 109 |
;;; |
| 110 |
;;; 05-NOV-90 hkt Changed canonicalize-system-name to make system |
| 111 |
;;; names package independent. Interns them in the |
| 112 |
;;; keyword package. Thus either strings or symbols may |
| 113 |
;;; be used to name systems from the user's point of view. |
| 114 |
;;; 05-NOV-90 hkt Added definition FIND-SYSTEM to allow OOS to |
| 115 |
;;; work on systems whose definition hasn't been loaded yet. |
| 116 |
;;; 05-NOV-90 hkt Added definitions COMPILE-SYSTEM and LOAD-SYSTEM |
| 117 |
;;; as alternates to OOS for naive users. |
| 118 |
;;; 05-NOV-90 hkt Shadowing-import of 'defsystem in Allegro CL 3.1 [NeXT] |
| 119 |
;;; into USER package instead of import. |
| 120 |
;;; 15-NOV-90 mk Changed package name to "MAKE", eliminating "DEFSYSTEM" |
| 121 |
;;; to avoid conflicts with allegro, symbolics packages |
| 122 |
;;; named "DEFSYSTEM". |
| 123 |
;;; 30-JAN-91 mk Modified append-directories to work with the |
| 124 |
;;; logical-pathnames system. |
| 125 |
;;; 30-JAN-91 mk Append-directories now works with Sun CL4.0. Also, fixed |
| 126 |
;;; bug wrt Lucid 4.0's pathnames (which changed from lcl3.0 |
| 127 |
;;; -- 4.0 uses a list for the directory slot, whereas |
| 128 |
;;; 3.0 required a string). Possible fix to symbolics bug. |
| 129 |
;;; 30-JAN-91 mk Defined NEW-REQUIRE to make redefinition of REQUIRE |
| 130 |
;;; cleaner. Replaced all calls to REQUIRE in this file with |
| 131 |
;;; calls to NEW-REQUIRE, which should avoid compiler warnings. |
| 132 |
;;; 30-JAN-91 mk In VAXLisp, when we redefine lisp:require, the compiler |
| 133 |
;;; no longer automatically executes require forms when it |
| 134 |
;;; encounters them in a file. The user can always wrap an |
| 135 |
;;; (eval-when (compile load eval) ...) around the require |
| 136 |
;;; form. Alternately, see commented out code near the |
| 137 |
;;; redefinition of lisp:require which redefines it as a |
| 138 |
;;; macro instead. |
| 139 |
;;; 30-JAN-91 mk Added parameter :version to operate-on-system. If it is |
| 140 |
;;; a number, that number is used as part of the binary |
| 141 |
;;; directory name as the place to store and load files. |
| 142 |
;;; If NIL (the default), uses regular binary directory. |
| 143 |
;;; If T, tries to find the most recent version of the |
| 144 |
;;; binary directory. |
| 145 |
;;; 30-JAN-91 mk Added global variable *use-timeouts* (default: t), which |
| 146 |
;;; specifies whether timeouts should be used in |
| 147 |
;;; Y-OR-N-P-WAIT. This is provided for users whose lisps |
| 148 |
;;; don't handle read-char-no-hang properly, so that they |
| 149 |
;;; can set it to NIL to disable the timeouts. Usually the |
| 150 |
;;; reason for this is the lisp is run on top of UNIX, |
| 151 |
;;; which buffers input LINES (and provides input editing). |
| 152 |
;;; To get around this we could always turn CBREAK mode |
| 153 |
;;; on and off, but there's no way to do this in a portable |
| 154 |
;;; manner. |
| 155 |
;;; 30-JAN-91 mk Fixed bug where in :test t mode it was actually providing |
| 156 |
;;; the system, instead of faking it. |
| 157 |
;;; 30-JAN-91 mk Changed storage of system definitions to a hash table. |
| 158 |
;;; Changed canonicalize-system-name to coerce the system |
| 159 |
;;; names to uppercase strings. Since we're no longer using |
| 160 |
;;; get, there's no need to intern the names as symbols, |
| 161 |
;;; and strings don't have packages to cause problems. |
| 162 |
;;; Added UNDEFSYSTEM, DEFINED-SYSTEMS, and DESCRIBE-SYSTEM. |
| 163 |
;;; Added :delete-binaries command. |
| 164 |
;;; 31-JAN-91 mk Franz Allegro CL has a defsystem in the USER package, |
| 165 |
;;; so we need to do a shadowing import to avoid name |
| 166 |
;;; conflicts. |
| 167 |
;;; 31-JAN-91 mk Fixed bug in compile-and-load-operation where it was |
| 168 |
;;; only loading newly compiled files. |
| 169 |
;;; 31-JAN-91 mk Added :load-time slot to components to record the |
| 170 |
;;; file-write-date of the binary/source file that was loaded. |
| 171 |
;;; Now knows "when" (which date version) the file was loaded. |
| 172 |
;;; Added keyword :minimal-load and global *minimal-load* |
| 173 |
;;; to enable defsystem to avoid reloading unmodified files. |
| 174 |
;;; Note that if B depends on A, but A is up to date and |
| 175 |
;;; loaded and the user specified :minimal-load T, then A |
| 176 |
;;; will not be loaded even if B needs to be compiled. So |
| 177 |
;;; if A is an initializations file, say, then the user should |
| 178 |
;;; not specify :minimal-load T. |
| 179 |
;;; 31-JAN-91 mk Added :load-only slot to components. If this slot is |
| 180 |
;;; specified as non-NIL, skips over any attempts to compile |
| 181 |
;;; the files in the component. (Loading the file satisfies |
| 182 |
;;; the need to recompile.) |
| 183 |
;;; 31-JAN-91 mk Eliminated use of set-alist-lookup and alist-lookup, |
| 184 |
;;; replacing it with hash tables. It was too much bother, |
| 185 |
;;; and rather brittle too. |
| 186 |
;;; 31-JAN-91 mk Defined #@ macro character for use with AFS @sys |
| 187 |
;;; feature simulator. #@"directory" is then synonymous |
| 188 |
;;; with (afs-binary-directory "directory"). |
| 189 |
;;; 31-JAN-91 mk Added :private-file type of module. It is similar to |
| 190 |
;;; :file, but has an absolute pathname. This allows you |
| 191 |
;;; to specify a different version of a file in a system |
| 192 |
;;; (e.g., if you're working on the file in your home |
| 193 |
;;; directory) without completely rewriting the system |
| 194 |
;;; definition. |
| 195 |
;;; 31-JAN-91 mk Operations on systems, such as :compile and :load, |
| 196 |
;;; now propagate to subsystems the system depends on |
| 197 |
;;; if *operations-propagate-to-subsystems* is T (the default) |
| 198 |
;;; and the systems were defined using either defsystem |
| 199 |
;;; or as a :system component of another system. Thus if |
| 200 |
;;; a system depends on another, it can now recompile the |
| 201 |
;;; other. |
| 202 |
;;; 01-FEB-91 mk Added default definitions of PROVIDE/REQUIRE/*MODULES* |
| 203 |
;;; for lisps that have thrown away these definitions in |
| 204 |
;;; accordance with CLtL2. |
| 205 |
;;; 01-FEB-91 mk Added :compile-only slot to components. Analogous to |
| 206 |
;;; :load-only. If :compile-only is T, will not load the |
| 207 |
;;; file on operation :compile. Either compiles or loads |
| 208 |
;;; the file, but not both. In other words, compiling the |
| 209 |
;;; file satisfies the demand to load it. This is useful |
| 210 |
;;; for PCL defmethod and defclass definitions, which wrap |
| 211 |
;;; an (eval-when (compile load eval) ...) around the body |
| 212 |
;;; of the definition -- we save time by not loading the |
| 213 |
;;; compiled code, since the eval-when forces it to be |
| 214 |
;;; loaded. Note that this may not be entirely safe, since |
| 215 |
;;; CLtL2 has added a :load keyword to compile-file, and |
| 216 |
;;; some lisps may maintain a separate environment for |
| 217 |
;;; the compiler. This feature is for the person who asked |
| 218 |
;;; that a :COMPILE-SATISFIES-LOAD keyword be added to |
| 219 |
;;; modules. It's named :COMPILE-ONLY instead to match |
| 220 |
;;; :LOAD-ONLY. |
| 221 |
;;; 11-FEB-91 mk Now adds :mk-defsystem to features list, to allow |
| 222 |
;;; special cased loading of defsystem if not already |
| 223 |
;;; present. |
| 224 |
;;; 19-FEB-91 duff Added filename extension for hp9000/300's running Lucid. |
| 225 |
;;; 26-FEB-91 mk Distinguish between toplevel systems (defined with |
| 226 |
;;; defsystem) and systems defined as a :system module |
| 227 |
;;; of a defsystem. The former can depend only on systems, |
| 228 |
;;; while the latter can depend on anything at the same |
| 229 |
;;; level. |
| 230 |
;;; 12-MAR-91 mk Added :subsystem component type to be a system with |
| 231 |
;;; pathnames relative to its parent component. |
| 232 |
;;; 12-MAR-91 mk Uncommented :device :absolute for CMU pathnames, so |
| 233 |
;;; that the leading slash is included. |
| 234 |
;;; 12-MAR-91 brad Patches for Allegro 4.0.1 on Sparc. |
| 235 |
;;; 12-MAR-91 mk Changed definition of format-justified-string so that |
| 236 |
;;; it no longer depends on the ~<~> format directives, |
| 237 |
;;; because Allegro 4.0.1 has a bug which doesn't support |
| 238 |
;;; them. Anyway, the new definition is twice as fast |
| 239 |
;;; and conses half as much as FORMAT. |
| 240 |
;;; 12-MAR-91 toni Remove nils from list in expand-component-components. |
| 241 |
;;; 12-MAR-91 bw If the default-package and system have the same name, |
| 242 |
;;; and the package is not loaded, this could lead to |
| 243 |
;;; infinite loops, so we bomb out with an error. |
| 244 |
;;; Fixed bug in default packages. |
| 245 |
;;; 13-MAR-91 mk Added global *providing-blocks-load-propagation* to |
| 246 |
;;; control whether system dependencies are loaded if they |
| 247 |
;;; have already been provided. |
| 248 |
;;; 13-MAR-91 brad In-package is a macro in CLtL2 lisps, so we change |
| 249 |
;;; the package manually in operate-on-component. |
| 250 |
;;; 15-MAR-91 mk Modified *central-registry* to be either a single |
| 251 |
;;; directory pathname, or a list of directory pathnames |
| 252 |
;;; to be checked in order. |
| 253 |
;;; 15-MAR-91 rs Added afs-source-directory to handle versions when |
| 254 |
;;; compiling C code under lisp. Other minor changes to |
| 255 |
;;; translate-version and operate-on-system. |
| 256 |
;;; 21-MAR-91 gi Fixed bug in defined-systems. |
| 257 |
;;; 22-MAR-91 mk Replaced append-directories with new version that works |
| 258 |
;;; by actually appending the directories, after massaging |
| 259 |
;;; them into the proper format. This should work for all |
| 260 |
;;; CLtL2-compliant lisps. |
| 261 |
;;; 09-APR-91 djc Missing package prefix for lp:pathname-host-type. |
| 262 |
;;; Modified component-full-pathname to work for logical |
| 263 |
;;; pathnames. |
| 264 |
;;; 09-APR-91 mk Added *dont-redefine-require* to control whether |
| 265 |
;;; REQUIRE is redefined. Fixed minor bugs in redefinition |
| 266 |
;;; of require. |
| 267 |
;;; 12-APR-91 mk (pathname-host nil) causes an error in MCL 2.0b1 |
| 268 |
;;; 12-APR-91 mc Ported to MCL2.0b1. |
| 269 |
;;; 16-APR-91 mk Fixed bug in needs-loading where load-time and |
| 270 |
;;; file-write-date got swapped. |
| 271 |
;;; 16-APR-91 mk If the component is load-only, defsystem shouldn't |
| 272 |
;;; tell you that there is no binary and ask you if you |
| 273 |
;;; want to load the source. |
| 274 |
;;; 17-APR-91 mc Two additional operations for MCL. |
| 275 |
;;; 21-APR-91 mk Added feature requested by ik. *files-missing-is-an-error* |
| 276 |
;;; new global variable which controls whether files (source |
| 277 |
;;; and binary) missing cause a continuable error or just a |
| 278 |
;;; warning. |
| 279 |
;;; 21-APR-91 mk Modified load-file-operation to allow compilation of source |
| 280 |
;;; files during load if the binary files are old or |
| 281 |
;;; non-existent. This adds a :compile-during-load keyword to |
| 282 |
;;; oos, and load-system. Global *compile-during-load* sets |
| 283 |
;;; the default (currently :query). |
| 284 |
;;; 21-APR-91 mk Modified find-system so that there is a preference for |
| 285 |
;;; loading system files from disk, even if the system is |
| 286 |
;;; already defined in the environment. |
| 287 |
;;; 25-APR-91 mk Removed load-time slot from component defstruct and added |
| 288 |
;;; function COMPONENT-LOAD-TIME to store the load times in a |
| 289 |
;;; hash table. This is safer than the old definition because |
| 290 |
;;; it doesn't wipe out load times every time the system is |
| 291 |
;;; redefined. |
| 292 |
;;; 25-APR-91 mk Completely rewrote load-file-operation. Fixed some bugs |
| 293 |
;;; in :compile-during-load and in the behavior of defsystem |
| 294 |
;;; when multiple users are compiling and loading a system |
| 295 |
;;; instead of just a single user. |
| 296 |
;;; 16-MAY-91 mk Modified FIND-SYSTEM to do the right thing if the system |
| 297 |
;;; definition file cannot be found. |
| 298 |
;;; 16-MAY-91 mk Added globals *source-pathname-default* and |
| 299 |
;;; *binary-pathname-default* to contain default values for |
| 300 |
;;; :source-pathname and :binary-pathname. For example, set |
| 301 |
;;; *source-pathname-default* to "" to avoid having to type |
| 302 |
;;; :source-pathname "" all the time. |
| 303 |
;;; 27-MAY-91 mk Fixed bug in new-append-directories where directory |
| 304 |
;;; components of the form "foo4.0" would appear as "foo4", |
| 305 |
;;; since pathname-name truncates the type. Changed |
| 306 |
;;; pathname-name to file-namestring. |
| 307 |
;;; 3-JUN-91 gc Small bug in new-append-directories; replace (when |
| 308 |
;;; abs-name) with (when (not (null-string abs-name))) |
| 309 |
;;; 4-JUN-91 mk Additional small change to new-append-directories for |
| 310 |
;;; getting the device from the relative pname if the abs |
| 311 |
;;; pname is "". This is to fix a small behavior in CMU CL old |
| 312 |
;;; compiler. Also changed (when (not (null-string abs-name))) |
| 313 |
;;; to have an (and abs-name) in there. |
| 314 |
;;; 8-JAN-92 sb Added filename extension for defsystem under Lucid Common |
| 315 |
;;; Lisp/SGO 3.0.1+. |
| 316 |
;;; 8-JAN-92 mk Changed the definition of prompt-string to work around an |
| 317 |
;;; AKCL bug. Essentially, AKCL doesn't default the colinc to |
| 318 |
;;; 1 if the colnum is provided, so we hard code it. |
| 319 |
;;; 8-JAN-92 rs (pathname-directory (pathname "")) returns '(:relative) in |
| 320 |
;;; Lucid, instead of NIL. Changed new-append-directories and |
| 321 |
;;; test-new-append-directories to reflect this. |
| 322 |
;;; 8-JAN-92 mk Fixed problem related to *load-source-if-no-binary*. |
| 323 |
;;; compile-and-load-source-if-no-binary wasn't checking for |
| 324 |
;;; the existence of the binary if this variable was true, |
| 325 |
;;; causing the file to not be compiled. |
| 326 |
;;; 8-JAN-92 mk Fixed problem with null-string being called on a pathname |
| 327 |
;;; by returning NIL if the argument isn't a string. |
| 328 |
;;; 3-NOV-93 mk In Allegro 4.2, pathname device is :unspecific by default. |
| 329 |
;;; 11-NOV-93 fdmm Fixed package definition lock problem when redefining |
| 330 |
;;; REQUIRE on ACL. |
| 331 |
;;; 11-NOV-93 fdmm Added machine and software types for SGI and IRIX. It is |
| 332 |
;;; important to distinguish the OS version and CPU type in |
| 333 |
;;; SGI+ACL, since ACL 4.1 on IRIX 4.x and ACL 4.2 on IRIX 5.x |
| 334 |
;;; have incompatible .fasl files. |
| 335 |
;;; 01-APR-94 fdmm Fixed warning problem when redefining REQUIRE on LispWorks. |
| 336 |
;;; 01-NOV-94 fdmm Replaced (software-type) call in ACL by code extracting |
| 337 |
;;; the interesting parts from (software-version) [deleted |
| 338 |
;;; machine name and id]. |
| 339 |
;;; 03-NOV-94 fdmm Added a hook (*compile-file-function*), that is funcalled |
| 340 |
;;; by compile-file-operation, so as to support other languages |
| 341 |
;;; running on top of Common Lisp. |
| 342 |
;;; The default is to compile Common Lisp. |
| 343 |
;;; 03-NOV-94 fdmm Added SCHEME-COMPILE-FILE, so that defsystem can now |
| 344 |
;;; compile Pseudoscheme files. |
| 345 |
;;; 04-NOV-94 fdmm Added the exported generic function SET-LANGUAGE, to |
| 346 |
;;; have a clean, easy to extend interface for telling |
| 347 |
;;; defsystem which language to assume for compilation. |
| 348 |
;;; Currently supported arguments: :common-lisp, :scheme. |
| 349 |
;;; 11-NOV-94 kc Ported to Allegro CL for Windows 2.0 (ACLPC) and CLISP. |
| 350 |
;;; 18-NOV-94 fdmm Changed the entry *filename-extensions* for LispWorks |
| 351 |
;;; to support any platform. |
| 352 |
;;; Added entries for :mcl and :clisp too. |
| 353 |
;;; 16-DEC-94 fdmm Added and entry for CMU CL on SGI to *filename-extensions*. |
| 354 |
;;; 16-DEC-94 fdmm Added OS version identification for CMU CL on SGI. |
| 355 |
;;; 16-DEC-94 fdmm For CMU CL 17 : Bypassed make-pathnames call fix |
| 356 |
;;; in NEW-APPEND-DIRECTORIES. |
| 357 |
;;; 16-DEC-94 fdmm Added HOME-SUBDIRECTORY to fix CMU's ignorance about `~' |
| 358 |
;;; when specifying registries. |
| 359 |
;;; 16-DEC-94 fdmm For CMU CL 17 : Bypassed :device fix in make-pathnames call |
| 360 |
;;; in COMPONENT-FULL-PATHNAME. This fix was also reported |
| 361 |
;;; by kc on 12-NOV-94. CMU CL 17 now supports CLtL2 pathnames. |
| 362 |
;;; 16-DEC-94 fdmm Removed a quote before the call to read in the readmacro |
| 363 |
;;; #@. This fixes a really annoying misfeature (couldn't do |
| 364 |
;;; #@(concatenate 'string "foo/" "bar"), for example). |
| 365 |
;;; 03-JAN-95 fdmm Do not include :pcl in *features* if :clos is there. |
| 366 |
;;; 2-MAR-95 mk Modified fdmm's *central-registry* change to use |
| 367 |
;;; user-homedir-pathname and to be a bit more generic in the |
| 368 |
;;; pathnames. |
| 369 |
;;; 2-MAR-95 mk Modified fdmm's updates to *filename-extensions* to handle |
| 370 |
;;; any CMU CL binary extensions. |
| 371 |
;;; 2-MAR-95 mk Make kc's port to ACLPC a little more generic. |
| 372 |
;;; 2-MAR-95 mk djc reported a bug, in which GET-SYSTEM was not returning |
| 373 |
;;; a system despite the system's just having been loaded. |
| 374 |
;;; The system name specified in the :depends-on was a |
| 375 |
;;; lowercase string. I am assuming that the system name |
| 376 |
;;; in the defsystem form was a symbol (I haven't verified |
| 377 |
;;; that this was the case with djc, but it is the only |
| 378 |
;;; reasonable conclusion). So, CANONICALIZE-SYSTEM-NAME |
| 379 |
;;; was storing the system in the hash table as an |
| 380 |
;;; uppercase string, but attempting to retrieve it as a |
| 381 |
;;; lowercase string. This behavior actually isn't a bug, |
| 382 |
;;; but a user error. It was intended as a feature to |
| 383 |
;;; allow users to use strings for system names when |
| 384 |
;;; they wanted to distinguish between two different systems |
| 385 |
;;; named "foo.system" and "Foo.system". However, this |
| 386 |
;;; user error indicates that this was a bad design decision. |
| 387 |
;;; Accordingly, CANONICALIZE-SYSTEM-NAME now uppercases |
| 388 |
;;; even strings for retrieving systems, and the comparison |
| 389 |
;;; in *modules* is now case-insensitive. The result of |
| 390 |
;;; this change is if the user cannot have distinct |
| 391 |
;;; systems in "Foo.system" and "foo.system" named "Foo" and |
| 392 |
;;; "foo", because they will clobber each other. There is |
| 393 |
;;; still case-sensitivity on the filenames (i.e., if the |
| 394 |
;;; system file is named "Foo.system" and you use "foo" in |
| 395 |
;;; the :depends-on, it won't find it). We didn't take the |
| 396 |
;;; further step of requiring system filenames to be lowercase |
| 397 |
;;; because we actually find this kind of case-sensitivity |
| 398 |
;;; to be useful, when maintaining two different versions |
| 399 |
;;; of the same system. |
| 400 |
;;; 7-MAR-95 mk Added simplistic handling of logical pathnames. Also |
| 401 |
;;; modified new-append-directories so that it'll try to |
| 402 |
;;; split up pathname directories that are strings into a |
| 403 |
;;; list of the directory components. Such directories aren't |
| 404 |
;;; ANSI CL, but some non-conforming implementations do it. |
| 405 |
;;; 7-MAR-95 mk Added :proclamations to defsystem form, which can be used |
| 406 |
;;; to set the compiler optimization level before compilation. |
| 407 |
;;; For example, |
| 408 |
;;; :proclamations '(optimize (safety 3) (speed 3) (space 0)) |
| 409 |
;;; 7-MAR-95 mk Defsystem now tells the user when it reloads the system |
| 410 |
;;; definition. |
| 411 |
;;; 7-MAR-95 mk Fixed problem pointed out by yc. If |
| 412 |
;;; *source-pathname-default* is "" and there is no explicit |
| 413 |
;;; :source-pathname specified for a file, the file could |
| 414 |
;;; wind up with an empty file name. In other words, this |
| 415 |
;;; global default shouldn't apply to :file components. Added |
| 416 |
;;; explicit test for null strings, and when present replaced |
| 417 |
;;; them with NIL (for binary as well as source, and also for |
| 418 |
;;; :private-file components). |
| 419 |
;;; 7-MAR-95 tar Fixed defsystem to work on TI Explorers (TI CL). |
| 420 |
;;; 7-MAR-95 jk Added machine-type-translation for Decstation 5000/200 |
| 421 |
;;; under Allegro 3.1 |
| 422 |
;;; 7-MAR-95 as Fixed bug in AKCL-1-615 in which defsystem added a |
| 423 |
;;; subdirectory "RELATIVE" to all filenames. |
| 424 |
;;; 7-MAR-95 mk Added new test to test-new-append-directories to catch the |
| 425 |
;;; error fixed by as. Essentially, this error occurs when the |
| 426 |
;;; absolute-pathname has no directory (i.e., it has a single |
| 427 |
;;; pathname component as in "foo" and not "foo/bar"). If |
| 428 |
;;; RELATIVE ever shows up in the Result, we now know to |
| 429 |
;;; add an extra conditionalization to prevent abs-keyword |
| 430 |
;;; from being set to :relative. |
| 431 |
;;; 7-MAR-95 ss Miscellaneous fixes for MCL 2.0 final. |
| 432 |
;;; *compile-file-verbose* not in MCL, *version variables |
| 433 |
;;; need to occur before AFS-SOURCE-DIRECTORY definition, |
| 434 |
;;; and certain code needed to be in the CCL: package. |
| 435 |
;;; 8-MAR-95 mk Y-OR-N-P-WAIT uses a busy-waiting. On Lisp systems where |
| 436 |
;;; the time functions cons, such as CMU CL, this can cause a |
| 437 |
;;; lot of ugly garbage collection messages. Modified the |
| 438 |
;;; waiting to include calls to SLEEP, which should reduce |
| 439 |
;;; some of the consing. |
| 440 |
;;; 8-MAR-95 mk Replaced fdmm's SET-LANGUAGE enhancement with a more |
| 441 |
;;; general extension, along the lines suggested by akd. |
| 442 |
;;; Defsystem now allows components to specify a :language |
| 443 |
;;; slot, such as :language :lisp, :language :scheme. This |
| 444 |
;;; slot is inherited (with the default being :lisp), and is |
| 445 |
;;; used to obtain compilation and loading functions for |
| 446 |
;;; components, as well as source and binary extensions. The |
| 447 |
;;; compilation and loading functions can be overridden by |
| 448 |
;;; specifying a :compiler or :loader in the system |
| 449 |
;;; definition. Also added :documentation slot to the system |
| 450 |
;;; definition. |
| 451 |
;;; Where this comes in real handy is if one has a |
| 452 |
;;; compiler-compiler implemented in Lisp, and wants the |
| 453 |
;;; system to use the compiler-compiler to create a parser |
| 454 |
;;; from a grammar and then compile parser. To do this one |
| 455 |
;;; would create a module with components that looked |
| 456 |
;;; something like this: |
| 457 |
;;; ((:module cc :components ("compiler-compiler")) |
| 458 |
;;; (:module gr :compiler 'cc :loader #'ignore |
| 459 |
;;; :source-extension "gra" |
| 460 |
;;; :binary-extension "lisp" |
| 461 |
;;; :depends-on (cc) |
| 462 |
;;; :components ("sample-grammar")) |
| 463 |
;;; (:module parser :depends-on (gr) |
| 464 |
;;; :components ("sample-grammar"))) |
| 465 |
;;; Defsystem would then compile and load the compiler, use |
| 466 |
;;; it (the function cc) to compile the grammar into a parser, |
| 467 |
;;; and then compile the parser. The only tricky part is |
| 468 |
;;; cc is defined by the system, and one can't include #'cc |
| 469 |
;;; in the system definition. However, one could include |
| 470 |
;;; a call to mk:define-language in the compiler-compiler file, |
| 471 |
;;; and define :cc as a language. This is the prefered method. |
| 472 |
;;; 8-MAR-95 mk New definition of topological-sort suggested by rs2. This |
| 473 |
;;; version avoids the call to SORT, but in practice isn't |
| 474 |
;;; much faster. However, it avoids the need to maintain a |
| 475 |
;;; TIME slot in the topsort-node structure. |
| 476 |
;;; 8-MAR-95 mk rs2 also pointed out that the calls to MAKE-PATHNAME and |
| 477 |
;;; NAMESTRING in COMPONENT-FULL-PATHNAME are a major reason |
| 478 |
;;; why defsystem is slow. Accordingly, I've changed |
| 479 |
;;; COMPONENT-FULL-PATHNAME to include a call to NAMESTRING |
| 480 |
;;; (and removed all other calls to NAMESTRING), and also made |
| 481 |
;;; a few changes to minimize the number of calls to |
| 482 |
;;; COMPONENT-FULL-PATHNAME, such as memoizing it. See To Do |
| 483 |
;;; below for other related comments. |
| 484 |
;;; 8-MAR-95 mk Added special hack requested by Steve Strassman, which |
| 485 |
;;; allows one to specify absolute pathnames in the shorthand |
| 486 |
;;; for a list of components, and have defsystem recognize |
| 487 |
;;; which are absolute and which are relative. |
| 488 |
;;; I actually think this would be a good idea, but I haven't |
| 489 |
;;; tested it, so it is disabled by default. Search for |
| 490 |
;;; *enable-straz-absolute-string-hack* to enable it. |
| 491 |
;;; 8-MAR-95 kt Fixed problem with EXPORT in AKCL 1.603, in which it wasn't |
| 492 |
;;; properly exporting the value of the global export |
| 493 |
;;; variables. |
| 494 |
;;; 8-MAR-95 mk Added UNMUNGE-LUCID to fix nasty problem with COMPILE-FILE |
| 495 |
;;; in Lucid. Lucid apparently tries to merge the :output-file |
| 496 |
;;; with the source file when the :output-file is a relative |
| 497 |
;;; pathname. Wierd, and definitely non-standard. |
| 498 |
;;; 9-MAR-95 mk Changed ALLEGRO-MAKE-SYSTEM-FASL to also include the files |
| 499 |
;;; in any systems the system depends on, as per a |
| 500 |
;;; request of oc. |
| 501 |
;;; 9-MAR-95 mk Some version of CMU CL couldn't hack a call to |
| 502 |
;;; MAKE-PATHNAME with :host NIL. I'm not sure which version |
| 503 |
;;; it is, but the current version doesn't have this problem. |
| 504 |
;;; If given :host nil, it defaults the host to |
| 505 |
;;; COMMON-LISP::*UNIX-HOST*. So I haven't "fixed" this |
| 506 |
;;; problem. |
| 507 |
;;; 9-MAR-95 mk Integrated top-level commands for Allegro designed by bha |
| 508 |
;;; into the code, with slight modifications. |
| 509 |
;;; 9-MAR-95 mk Instead of having COMPUTE-SYSTEM-PATH check the current |
| 510 |
;;; directory in a hard-coded fashion, include the current |
| 511 |
;;; directory in the *central-registry*, as suggested by |
| 512 |
;;; bha and others. |
| 513 |
;;; 9-MAR-95 bha Support for Logical Pathnames in Allegro. |
| 514 |
;;; 9-MAR-95 mk Added modified version of bha's DEFSYSPATH idea. |
| 515 |
;;; 13-MAR-95 mk Added a macro for the simple serial case, where a system |
| 516 |
;;; (or module) is simple a list of files, each of which |
| 517 |
;;; depends on the previous one. If the value of :components |
| 518 |
;;; is a list beginning with :serial, it expands each |
| 519 |
;;; component and makes it depend on the previous component. |
| 520 |
;;; For example, (:serial "foo" "bar" "baz") would create a |
| 521 |
;;; set of components where "baz" depended on "bar" and "bar" |
| 522 |
;;; on "foo". |
| 523 |
;;; 13-MAR-95 mk *** Now version 3.0. This version is a interim bug-fix and |
| 524 |
;;; update, since I do not have the time right now to complete |
| 525 |
;;; the complete overhaul and redesign. |
| 526 |
;;; Major changes in 3.0 include CMU CL 17, CLISP, ACLPC, TI, |
| 527 |
;;; LispWorks and ACL(SGI) support, bug fixes for ACL 4.1/4.2. |
| 528 |
;;; 14-MAR-95 fdmm Finally added the bit of code to discriminate cleanly |
| 529 |
;;; among different lisps without relying on (software-version) |
| 530 |
;;; idiosyncracies. |
| 531 |
;;; You can now customize COMPILER-TYPE-TRANSLATION so that |
| 532 |
;;; AFS-BINARY-DIRECTORY can return a different value for |
| 533 |
;;; different lisps on the same platform. |
| 534 |
;;; If you use only one compiler, do not care about supporting |
| 535 |
;;; code for multiple versions of it, and want less verbose |
| 536 |
;;; directory names, just set *MULTIPLE-LISP-SUPPORT* to nil. |
| 537 |
;;; 17-MAR-95 lmh Added EVAL-WHEN for one of the MAKE-PACKAGE calls. |
| 538 |
;;; CMU CL's RUN-PROGRAM is in the extensions package. |
| 539 |
;;; ABSOLUTE-FILE-NAMESTRING-P was missing :test keyword |
| 540 |
;;; Rearranged conditionalization in DIRECTORY-TO-LIST to |
| 541 |
;;; suppress compiler warnings in CMU CL. |
| 542 |
;;; 17-MAR-95 mk Added conditionalizations to avoid certain CMU CL compiler |
| 543 |
;;; warnings reported by lmh. |
| 544 |
;;; 19990610 ma Added shadowing of 'HARDCOPY-SYSTEM' for LW Personal Ed. |
| 545 |
|
| 546 |
;;; 19991211 ma NEW VERSION 4.0 started. |
| 547 |
;;; 19991211 ma Merged in changes requested by T. Russ of |
| 548 |
;;; ISI. Please refer to the special "ISI" comments to |
| 549 |
;;; understand these changes |
| 550 |
;;; 20000228 ma The symbols FIND-SYSTEM, LOAD-SYSTEM, DEFSYSTEM, |
| 551 |
;;; COMPILE-SYSTEM and HARDCOPY-SYSTEM are no longer |
| 552 |
;;; imported in the COMMON-LISP-USER package. |
| 553 |
;;; Cfr. the definitions of *EXPORTS* and |
| 554 |
;;; *SPECIAL-EXPORTS*. |
| 555 |
;;; 2000-07-21 rlt Add COMPILER-OPTIONS to defstruct to allow user to |
| 556 |
;;; specify special compiler options for a particular |
| 557 |
;;; component. |
| 558 |
;;; 2002-01-08 kmr Changed allegro symbols to lowercase to support |
| 559 |
;;; case-sensitive images |
| 560 |
|
| 561 |
;;;--------------------------------------------------------------------------- |
| 562 |
;;; ISI Comments |
| 563 |
;;; |
| 564 |
;;; 19991211 Marco Antoniotti |
| 565 |
;;; These comments come from the "ISI Branch". I believe I did |
| 566 |
;;; include the :load-always extension correctly. The other commets |
| 567 |
;;; seem superseded by other changes made to the system in the |
| 568 |
;;; following years. Some others are now useless with newer systems |
| 569 |
;;; (e.g. filename truncation for new Windows based CL |
| 570 |
;;; implementations.) |
| 571 |
|
| 572 |
;;; 1-OCT-92 tar Fixed problem with TI Lisp machines and append-directory. |
| 573 |
;;; 1-OCT-92 tar Made major modifications to compile-file-operation and |
| 574 |
;;; load-file-operation to reduce the number of probe-file |
| 575 |
;;; and write-date inquiries. This makes the system run much |
| 576 |
;;; faster through slow network connections. |
| 577 |
;;; 13-OCT-92 tar Added :load-always slot to components. If this slot is |
| 578 |
;;; specified as non-NIL, always loads the component. |
| 579 |
;;; This does not trigger dependent compilation. |
| 580 |
;;; (This can be useful when macro definitions needed |
| 581 |
;;; during compilation are changed by later files. In |
| 582 |
;;; this case, not reloading up-to-date files can |
| 583 |
;;; cause different results.) |
| 584 |
;;; 28-OCT-93 tar Allegro 4.2 causes an error on (pathname-device nil) |
| 585 |
;;; 14-SEP-94 tar Disable importing of symbols into (CL-)USER package |
| 586 |
;;; to minimize conflicts with other defsystem utilities. |
| 587 |
;;; 10-NOV-94 tar Added filename truncation code to support Franz Allegro |
| 588 |
;;; PC with it's 8 character filename limitation. |
| 589 |
;;; 15-MAY-98 tar Changed host attribute for pathnames to support LispWorks |
| 590 |
;;; (Windows) pathnames which reference other Drives. Also |
| 591 |
;;; updated file name convention. |
| 592 |
;;; 9-NOV-98 tar Updated new-append-directories for Lucid 5.0 |
| 593 |
;;; |
| 594 |
|
| 595 |
|
| 596 |
;;; ******************************** |
| 597 |
;;; Ports ************************** |
| 598 |
;;; ******************************** |
| 599 |
;;; |
| 600 |
;;; DEFSYSTEM has been tested (successfully) in the following lisps: |
| 601 |
;;; CMU Common Lisp (M2.9 15-Aug-90, Compiler M1.8 15-Aug-90) |
| 602 |
;;; CMU Common Lisp (14-Dec-90 beta, Python Compiler 0.0 PMAX/Mach) |
| 603 |
;;; CMU Common Lisp 17f (Python 1.0) |
| 604 |
;;; Franz Allegro Common Lisp 3.1.12 (ExCL 3/30/90) |
| 605 |
;;; Franz Allegro Common Lisp 4.0/4.1/4.2 |
| 606 |
;;; Franz Allegro Common Lisp for Windows (2.0) |
| 607 |
;;; Lucid Common Lisp (Version 2.1 6-DEC-87) |
| 608 |
;;; Lucid Common Lisp (3.0 [SPARC,SUN3]) |
| 609 |
;;; Lucid Common Lisp (4.0 [SPARC,SUN3]) |
| 610 |
;;; VAXLisp (v2.2) [VAX/VMS] |
| 611 |
;;; VAXLisp (v3.1) |
| 612 |
;;; Harlequin LispWorks |
| 613 |
;;; CLISP (CLISP3 [SPARC]) |
| 614 |
;;; Symbolics XL12000 (Genera 8.3) |
| 615 |
;;; Scieneer Common Lisp (SCL) 1.1 |
| 616 |
;;; Macintosh Common Lisp |
| 617 |
;;; ECL |
| 618 |
;;; |
| 619 |
;;; DEFSYSTEM needs to be tested in the following lisps: |
| 620 |
;;; OpenMCL |
| 621 |
;;; Symbolics Common Lisp (8.0) |
| 622 |
;;; KCL (June 3, 1987 or later) |
| 623 |
;;; AKCL (1.86, June 30, 1987 or later) |
| 624 |
;;; TI (Release 4.1 or later) |
| 625 |
;;; Ibuki Common Lisp (01/01, October 15, 1987) |
| 626 |
;;; Golden Common Lisp (3.1 IBM-PC) |
| 627 |
;;; HP Common Lisp (same as Lucid?) |
| 628 |
;;; Procyon Common Lisp |
| 629 |
|
| 630 |
;;; ******************************** |
| 631 |
;;; To Do ************************** |
| 632 |
;;; ******************************** |
| 633 |
;;; |
| 634 |
;;; COMPONENT-FULL-PATHNAME is a major source of slowness in the system |
| 635 |
;;; because of all the calls to the expensive operations MAKE-PATHNAME |
| 636 |
;;; and NAMESTRING. To improve performance, DEFSYSTEM should be reworked |
| 637 |
;;; to avoid any need to call MAKE-PATHNAME and NAMESTRING, as the logical |
| 638 |
;;; pathnames package does. Unfortunately, I don't have the time to do this |
| 639 |
;;; right now. Instead, I installed a temporary improvement by memoizing |
| 640 |
;;; COMPONENT-FULL-PATHNAME to cache previous calls to the function on |
| 641 |
;;; a component by component and type by type basis. The cache is |
| 642 |
;;; cleared before each call to OOS, in case filename extensions change. |
| 643 |
;;; But DEFSYSTEM should really be reworked to avoid this problem and |
| 644 |
;;; ensure greater portability and to also handle logical pathnames. |
| 645 |
;;; |
| 646 |
;;; Also, PROBE-FILE and FILE-WRITE-DATE are other sources of slowness. |
| 647 |
;;; Perhaps by also memoizing FILE-WRITE-DATE and reimplementing PROBE-FILE |
| 648 |
;;; in terms of FILE-WRITE-DATE, can achieve a further speed-up. This was |
| 649 |
;;; suggested by Steven Feist ([email protected]). |
| 650 |
;;; |
| 651 |
;;; True CLtL2 logical pathnames support -- can't do it, because CLtL2 |
| 652 |
;;; doesn't have all the necessary primitives, and even in Allegro CL 4.2 |
| 653 |
;;; (namestring #l"foo:bar;baz.lisp") |
| 654 |
;;; does not work properly. |
| 655 |
;;; |
| 656 |
;;; Create separate stand-alone documentation for defsystem, and also |
| 657 |
;;; a test suite. |
| 658 |
;;; |
| 659 |
;;; Change SYSTEM to be a class instead of a struct, and make it a little |
| 660 |
;;; more generic, so that it permits alternate system definitions. |
| 661 |
;;; Replace OPERATE-ON-SYSTEM with MAP-SYSTEM (args: function, system-name, |
| 662 |
;;; &rest options) |
| 663 |
;;; |
| 664 |
;;; Add a patch directory mechanism. Perhaps have several directories |
| 665 |
;;; with code in them, and the first one with the specified file wins? |
| 666 |
;;; LOAD-PATCHES function. |
| 667 |
;;; |
| 668 |
;;; Need way to load old binaries even if source is newer. |
| 669 |
;;; |
| 670 |
;;; Allow defpackage forms/package definitions in the defsystem? If |
| 671 |
;;; a package not defined, look for and load a file named package.pkg? |
| 672 |
;;; |
| 673 |
;;; need to port for GNU CL (ala kcl)? |
| 674 |
;;; |
| 675 |
;;; Someone asked whether one can have :file components at top-level. I believe |
| 676 |
;;; this is the case, but should double-check that it is possible (and if |
| 677 |
;;; not, make it so). |
| 678 |
;;; |
| 679 |
;;; A common error/misconception seems to involve assuming that :system |
| 680 |
;;; components should include the name of the system file, and that |
| 681 |
;;; defsystem will automatically load the file containing the system |
| 682 |
;;; definition and propagate operations to it. Perhaps this would be a |
| 683 |
;;; nice feature to add. |
| 684 |
;;; |
| 685 |
;;; If a module is :load-only t, then it should not execute its :finally-do |
| 686 |
;;; and :initially-do clauses during compilation operations, unless the |
| 687 |
;;; module's files happen to be loaded during the operation. |
| 688 |
;;; |
| 689 |
;;; System Class. Customizable delimiters. |
| 690 |
;;; |
| 691 |
;;; Load a system (while not loading anything already loaded) |
| 692 |
;;; and inform the user of out of date fasls with the choice |
| 693 |
;;; to load the old fasl or recompile and then load the new |
| 694 |
;;; fasl? |
| 695 |
;;; |
| 696 |
;;; modify compile-file-operation to handle a query keyword.... |
| 697 |
;;; |
| 698 |
;;; Perhaps systems should keep around the file-write-date of the system |
| 699 |
;;; definition file, to prevent excessive reloading of the system definition? |
| 700 |
;;; |
| 701 |
;;; load-file-operation needs to be completely reworked to simplify the |
| 702 |
;;; logic of when files get loaded or not. |
| 703 |
;;; |
| 704 |
;;; Need to revamp output: Nesting and indenting verbose output doesn't |
| 705 |
;;; seem cool, especially when output overflows the 80-column margins. |
| 706 |
;;; |
| 707 |
;;; Document various ways of writing a system. simple (short) form |
| 708 |
;;; (where :components is just a list of filenames) in addition to verbose. |
| 709 |
;;; Put documentation strings in code. |
| 710 |
;;; |
| 711 |
;;; :load-time for modules and systems -- maybe record the time the system |
| 712 |
;;; was loaded/compiled here and print it in describe-system? |
| 713 |
;;; |
| 714 |
;;; Make it easy to define new functions that operate on a system. For |
| 715 |
;;; example, a function that prints out a list of files that have changed, |
| 716 |
;;; hardcopy-system, edit-system, etc. |
| 717 |
;;; |
| 718 |
;;; If a user wants to have identical systems for different lisps, do we |
| 719 |
;;; force the user to use logical pathnames? Or maybe we should write a |
| 720 |
;;; generic-pathnames package that parses any pathname format into a |
| 721 |
;;; uniform underlying format (i.e., pull the relevant code out of |
| 722 |
;;; logical-pathnames.lisp and clean it up a bit). |
| 723 |
;;; |
| 724 |
;;; Verify that Mac pathnames now work with append-directories. |
| 725 |
;;; |
| 726 |
;;; A common human error is to violate the modularization by making a file |
| 727 |
;;; in one module depend on a file in another module, instead of making |
| 728 |
;;; one module depend on the other. This is caught because the dependency |
| 729 |
;;; isn't found. However, is there any way to provide a more informative |
| 730 |
;;; error message? Probably not, especially if the system has multiple |
| 731 |
;;; files of the same name. |
| 732 |
;;; |
| 733 |
;;; For a module none of whose files needed to be compiled, have it print out |
| 734 |
;;; "no files need recompilation". |
| 735 |
;;; |
| 736 |
;;; Write a system date/time to a file? (version information) I.e., if the |
| 737 |
;;; filesystem supports file version numbers, write an auxiliary file to |
| 738 |
;;; the system definition file that specifies versions of the system and |
| 739 |
;;; the version numbers of the associated files. |
| 740 |
;;; |
| 741 |
;;; Add idea of a patch directory. |
| 742 |
;;; |
| 743 |
;;; In verbose printout, have it log a date/time at start and end of |
| 744 |
;;; compilation: |
| 745 |
;;; Compiling system "test" on 31-Jan-91 21:46:47 |
| 746 |
;;; by Defsystem version v2.0 01-FEB-91. |
| 747 |
;;; |
| 748 |
;;; Define other :force options: |
| 749 |
;;; :query allows user to specify that a file not normally compiled |
| 750 |
;;; should be. OR |
| 751 |
;;; :confirm allows user to specify that a file normally compiled |
| 752 |
;;; shouldn't be. AND |
| 753 |
;;; |
| 754 |
;;; We currently assume that compilation-load dependencies and if-changed |
| 755 |
;;; dependencies are identical. However, in some cases this might not be |
| 756 |
;;; true. For example, if we change a macro we have to recompile functions |
| 757 |
;;; that depend on it (except in lisps that automatically do this, such |
| 758 |
;;; as the new CMU Common Lisp), but not if we change a function. Splitting |
| 759 |
;;; these apart (with appropriate defaulting) would be nice, but not worth |
| 760 |
;;; doing immediately since it may save only a couple of file recompilations, |
| 761 |
;;; while making defsystem much more complex than it already is. |
| 762 |
;;; |
| 763 |
;;; Current dependencies are limited to siblings. Maybe we should allow |
| 764 |
;;; nephews and uncles? So long as it is still a DAG, we can sort it. |
| 765 |
;;; Answer: No. The current setup enforces a structure on the modularity. |
| 766 |
;;; Otherwise, why should we have modules if we're going to ignore it? |
| 767 |
;;; |
| 768 |
;;; Currently a file is recompiled more or less if the source is newer |
| 769 |
;;; than the binary or if the file depends on a file that has changed |
| 770 |
;;; (i.e., was recompiled in this session of a system operation). |
| 771 |
;;; Neil Goldman <[email protected]> has pointed out that whether a file |
| 772 |
;;; needs recompilation is really independent of the current session of |
| 773 |
;;; a system operation, and depends only on the file-write-dates of the |
| 774 |
;;; source and binary files for a system. Thus a file should require |
| 775 |
;;; recompilation in the following circumstances: |
| 776 |
;;; 1. If a file's source is newer than its binary, or |
| 777 |
;;; 2. If a file's source is not newer than its binary, but the file |
| 778 |
;;; depends directly or indirectly on a module (or file) that is newer. |
| 779 |
;;; For a regular file use the file-write-date (FWD) of the source or |
| 780 |
;;; binary, whichever is more recent. For a load-only file, use the only |
| 781 |
;;; available FWD. For a module, use the most recent (max) FWD of any of |
| 782 |
;;; its components. |
| 783 |
;;; The impact of this is that instead of using a boolean CHANGED variable |
| 784 |
;;; throughout the code, we need to allow CHANGED to be NIL/T/<FWD> or |
| 785 |
;;; maybe just the FWD timestamp, and to use the value of CHANGED in |
| 786 |
;;; needs-compilation decisions. (Use of NIL/T as values is an optimization. |
| 787 |
;;; The FWD timestamp which indicates the most recent time of any changes |
| 788 |
;;; should be sufficient.) This will affect not just the |
| 789 |
;;; compile-file-operation, but also the load-file-operation because of |
| 790 |
;;; compilation during load. Also, since FWDs will be used more prevalently, |
| 791 |
;;; we probably should couple this change with the inclusion of load-times |
| 792 |
;;; in the component defstruct. This is a tricky and involved change, and |
| 793 |
;;; requires more thought, since there are subtle cases where it might not |
| 794 |
;;; be correct. For now, the change will have to wait until the DEFSYSTEM |
| 795 |
;;; redesign. |
| 796 |
|
| 797 |
;;; ******************************************************************** |
| 798 |
;;; How to Use this System ********************************************* |
| 799 |
;;; ******************************************************************** |
| 800 |
|
| 801 |
;;; To use this system, |
| 802 |
;;; 1. If you want to have a central registry of system definitions, |
| 803 |
;;; modify the value of the variable *central-registry* below. |
| 804 |
;;; 2. Load this file (defsystem.lisp) in either source or compiled form, |
| 805 |
;;; 3. Load the file containing the "defsystem" definition of your system, |
| 806 |
;;; 4. Use the function "operate-on-system" to do things to your system. |
| 807 |
|
| 808 |
;;; For more information, see the documentation and examples in |
| 809 |
;;; lisp-utilities.ps. |
| 810 |
|
| 811 |
;;; ******************************** |
| 812 |
;;; Usage Comments ***************** |
| 813 |
;;; ******************************** |
| 814 |
|
| 815 |
;;; If you use symbols in the system definition file, they get interned in |
| 816 |
;;; the COMMON-LISP-USER package, which can lead to name conflicts when |
| 817 |
;;; the system itself seeks to export the same symbol to the COMMON-LISP-USER |
| 818 |
;;; package. The workaround is to use strings instead of symbols for the |
| 819 |
;;; names of components in the system definition file. In the major overhaul, |
| 820 |
;;; perhaps the user should be precluded from using symbols for such |
| 821 |
;;; identifiers. |
| 822 |
;;; |
| 823 |
;;; If you include a tilde in the :source-pathname in Allegro, as in "~/lisp", |
| 824 |
;;; file name expansion is much slower than if you use the full pathname, |
| 825 |
;;; as in "/user/USERID/lisp". |
| 826 |
;;; |
| 827 |
|
| 828 |
|
| 829 |
;;; **************************************************************** |
| 830 |
;;; Lisp Code ****************************************************** |
| 831 |
;;; **************************************************************** |
| 832 |
|
| 833 |
;;; ******************************** |
| 834 |
;;; Massage CLtL2 onto *features* ** |
| 835 |
;;; ******************************** |
| 836 |
;;; Let's be smart about CLtL2 compatible Lisps: |
| 837 |
(eval-when (compile load eval) |
| 838 |
#+(or (and allegro-version>= (version>= 4 0)) :mcl :sbcl) |
| 839 |
(pushnew :cltl2 *features*)) |
| 840 |
|
| 841 |
;;; ******************************** |
| 842 |
;;; Provide/Require/*modules* ****** |
| 843 |
;;; ******************************** |
| 844 |
|
| 845 |
;;; Since CLtL2 has dropped require and provide from the language, some |
| 846 |
;;; lisps may not have the functions PROVIDE and REQUIRE and the |
| 847 |
;;; global *MODULES*. So if lisp::provide and user::provide are not |
| 848 |
;;; defined, we define our own. |
| 849 |
|
| 850 |
;;; Hmmm. CMU CL old compiler gives bogus warnings here about functions |
| 851 |
;;; and variables not being declared or bound, apparently because it |
| 852 |
;;; sees that (or (fboundp 'lisp::require) (fboundp 'user::require)) returns |
| 853 |
;;; T, so it doesn't really bother when compiling the body of the unless. |
| 854 |
;;; The new compiler does this properly, so I'm not going to bother |
| 855 |
;;; working around this. |
| 856 |
|
| 857 |
;;; Some Lisp implementations return bogus warnings about assuming |
| 858 |
;;; *MODULE-FILES* and *LIBRARY* to be special, and CANONICALIZE-MODULE-NAME |
| 859 |
;;; and MODULE-FILES being undefined. Don't worry about them. |
| 860 |
|
| 861 |
;;; Now that ANSI CL includes PROVIDE and REQUIRE again, is this code |
| 862 |
;;; necessary? |
| 863 |
|
| 864 |
#-(or :CMU |
| 865 |
:vms |
| 866 |
:mcl |
| 867 |
:lispworks |
| 868 |
:clisp |
| 869 |
:gcl |
| 870 |
:sbcl |
| 871 |
:cormanlisp |
| 872 |
:scl |
| 873 |
:ecl |
| 874 |
(and allegro-version>= (version>= 4 1))) |
| 875 |
(eval-when #-(or :lucid) |
| 876 |
(:compile-toplevel :load-toplevel :execute) |
| 877 |
#+(or :lucid) |
| 878 |
(compile load eval) |
| 879 |
|
| 880 |
(unless (or (fboundp 'common-lisp::require) |
| 881 |
(fboundp 'common-lisp-user::require) |
| 882 |
|
| 883 |
#+(and :excl (and allegro-version>= (version>= 4 0))) |
| 884 |
(fboundp 'cltl1::require) |
| 885 |
|
| 886 |
#+:lispworks |
| 887 |
(fboundp 'system::require)) |
| 888 |
|
| 889 |
#-:lispworks |
| 890 |
(in-package "COMMON-LISP") |
| 891 |
#+:lispworks |
| 892 |
(in-package "SYSTEM") |
| 893 |
|
| 894 |
(export '(*modules* provide require)) |
| 895 |
|
| 896 |
;; Documentation strings taken almost literally from CLtL1. |
| 897 |
|
| 898 |
(defvar *modules* () |
| 899 |
"List of names of the modules that have been loaded into Lisp so far. |
| 900 |
It is used by PROVIDE and REQUIRE.") |
| 901 |
|
| 902 |
;; We provide two different ways to define modules. The default way |
| 903 |
;; is to put either a source or binary file with the same name |
| 904 |
;; as the module in the library directory. The other way is to define |
| 905 |
;; the list of files in the module with defmodule. |
| 906 |
|
| 907 |
;; The directory listed in *library* is implementation dependent, |
| 908 |
;; and is intended to be used by Lisp manufacturers as a place to |
| 909 |
;; store their implementation dependent packages. |
| 910 |
;; Lisp users should use systems and *central-registry* to store |
| 911 |
;; their packages -- it is intended that *central-registry* is |
| 912 |
;; set by the user, while *library* is set by the lisp. |
| 913 |
|
| 914 |
(defvar *library* nil ; "/usr/local/lisp/Modules/" |
| 915 |
"Directory within the file system containing files, where the name |
| 916 |
of a file is the same as the name of the module it contains.") |
| 917 |
|
| 918 |
(defvar *module-files* (make-hash-table :test #'equal) |
| 919 |
"Hash table mapping from module names to list of files for the |
| 920 |
module. REQUIRE loads these files in order.") |
| 921 |
|
| 922 |
(defun canonicalize-module-name (name) |
| 923 |
;; if symbol, string-downcase the printrep to make nicer filenames. |
| 924 |
(if (stringp name) name (string-downcase (string name)))) |
| 925 |
|
| 926 |
(defmacro defmodule (name &rest files) |
| 927 |
"Defines a module NAME to load the specified FILES in order." |
| 928 |
`(setf (gethash (canonicalize-module-name ,name) *module-files*) |
| 929 |
',files)) |
| 930 |
(defun module-files (name) |
| 931 |
(gethash name *module-files*)) |
| 932 |
|
| 933 |
(defun provide (name) |
| 934 |
"Adds a new module name to the list of modules maintained in the |
| 935 |
variable *modules*, thereby indicating that the module has been |
| 936 |
loaded. Name may be a string or symbol -- strings are case-senstive, |
| 937 |
while symbols are treated like lowercase strings. Returns T if |
| 938 |
NAME was not already present, NIL otherwise." |
| 939 |
(let ((module (canonicalize-module-name name))) |
| 940 |
(unless (find module *modules* :test #'string=) |
| 941 |
;; Module not present. Add it and return T to signify that it |
| 942 |
;; was added. |
| 943 |
(push module *modules*) |
| 944 |
t))) |
| 945 |
|
| 946 |
(defun require (name &optional pathname) |
| 947 |
"Tests whether a module is already present. If the module is not |
| 948 |
present, loads the appropriate file or set of files. The pathname |
| 949 |
argument, if present, is a single pathname or list of pathnames |
| 950 |
whose files are to be loaded in order, left to right. If the |
| 951 |
pathname is nil, the system first checks if a module was defined |
| 952 |
using defmodule and uses the pathnames so defined. If that fails, |
| 953 |
it looks in the library directory for a file with name the same |
| 954 |
as that of the module. Returns T if it loads the module." |
| 955 |
(let ((module (canonicalize-module-name name))) |
| 956 |
(unless (find module *modules* :test #'string=) |
| 957 |
;; Module is not already present. |
| 958 |
(when (and pathname (not (listp pathname))) |
| 959 |
;; If there's a pathname or pathnames, ensure that it's a list. |
| 960 |
(setf pathname (list pathname))) |
| 961 |
(unless pathname |
| 962 |
;; If there's no pathname, try for a defmodule definition. |
| 963 |
(setf pathname (module-files module))) |
| 964 |
(unless pathname |
| 965 |
;; If there's still no pathname, try the library directory. |
| 966 |
(when *library* |
| 967 |
(setf pathname (concatenate 'string *library* module)) |
| 968 |
;; Test if the file exists. |
| 969 |
;; We assume that the lisp will default the file type |
| 970 |
;; appropriately. If it doesn't, use #+".fasl" or some |
| 971 |
;; such in the concatenate form above. |
| 972 |
(if (probe-file pathname) |
| 973 |
;; If it exists, ensure we've got a list |
| 974 |
(setf pathname (list pathname)) |
| 975 |
;; If the library file doesn't exist, we don't want |
| 976 |
;; a load error. |
| 977 |
(setf pathname nil)))) |
| 978 |
;; Now that we've got the list of pathnames, let's load them. |
| 979 |
(dolist (pname pathname t) |
| 980 |
(load pname :verbose nil)))))) |
| 981 |
) ; eval-when |
| 982 |
|
| 983 |
;;; ******************************** |
| 984 |
;;; Set up Package ***************** |
| 985 |
;;; ******************************** |
| 986 |
|
| 987 |
|
| 988 |
;;; Unfortunately, lots of lisps have their own defsystems, some more |
| 989 |
;;; primitive than others, all uncompatible, and all in the DEFSYSTEM |
| 990 |
;;; package. To avoid name conflicts, we've decided to name this the |
| 991 |
;;; MAKE package. A nice side-effect is that the short nickname |
| 992 |
;;; MK is my initials. |
| 993 |
|
| 994 |
#+(or clisp cormanlisp ecl (and gcl defpackage) sbcl) |
| 995 |
(defpackage "MAKE" (:use "COMMON-LISP") (:nicknames "MK")) |
| 996 |
|
| 997 |
#-(or :sbcl :cltl2 :lispworks :ecl :scl) |
| 998 |
(in-package "MAKE" :nicknames '("MK")) |
| 999 |
|
| 1000 |
;;; For CLtL2 compatible lisps... |
| 1001 |
#+(and :excl :allegro-v4.0 :cltl2) |
| 1002 |
(defpackage "MAKE" (:nicknames "MK" "make" "mk") (:use :common-lisp) |
| 1003 |
(:import-from cltl1 *modules* provide require)) |
| 1004 |
|
| 1005 |
;;; *** Marco Antoniotti <[email protected]> 19970105 |
| 1006 |
;;; In Allegro 4.1, 'provide' and 'require' are not external in |
| 1007 |
;;; 'CLTL1'. However they are in 'COMMON-LISP'. Hence the change. |
| 1008 |
#+(and :excl :allegro-v4.1 :cltl2) |
| 1009 |
(defpackage "MAKE" (:nicknames "MK" "make" "mk") (:use :common-lisp) ) |
| 1010 |
|
| 1011 |
#+(and :excl :allegro-version>= (version>= 4 2)) |
| 1012 |
(defpackage "MAKE" (:nicknames "MK" "make" "mk") (:use :common-lisp)) |
| 1013 |
|
| 1014 |
#+:lispworks |
| 1015 |
(defpackage "MAKE" (:nicknames "MK") (:use "COMMON-LISP") |
| 1016 |
(:import-from system *modules* provide require) |
| 1017 |
(:export "DEFSYSTEM" "COMPILE-SYSTEM" "LOAD-SYSTEM" |
| 1018 |
"DEFINE-LANGUAGE" "*MULTIPLE-LISP-SUPPORT*")) |
| 1019 |
|
| 1020 |
#+:mcl |
| 1021 |
(defpackage "MAKE" (:nicknames "MK") (:use "COMMON-LISP") |
| 1022 |
(:import-from ccl *modules* provide require)) |
| 1023 |
|
| 1024 |
;;; *** Marco Antoniotti <[email protected]> 19951012 |
| 1025 |
;;; The code below, is originally executed also for CMUCL. However I |
| 1026 |
;;; believe this is wrong, since CMUCL comes with its own defpackage. |
| 1027 |
;;; I added the extra :CMU in the 'or'. |
| 1028 |
#+(and :cltl2 (not (or :cmu :clisp :sbcl |
| 1029 |
(and :excl (or :allegro-v4.0 :allegro-v4.1)) |
| 1030 |
:mcl))) |
| 1031 |
(eval-when (compile load eval) |
| 1032 |
(unless (find-package "MAKE") |
| 1033 |
(make-package "MAKE" :nicknames '("MK") :use '("COMMON-LISP")))) |
| 1034 |
|
| 1035 |
;;; *** Marco Antoniotti <[email protected]> 19951012 |
| 1036 |
;;; Here I add the proper defpackage for CMU |
| 1037 |
#+:CMU |
| 1038 |
(defpackage "MAKE" (:use "COMMON-LISP" "CONDITIONS") |
| 1039 |
(:nicknames "MK")) |
| 1040 |
|
| 1041 |
#+:sbcl |
| 1042 |
(defpackage "MAKE" (:use "COMMON-LISP") |
| 1043 |
(:nicknames "MK")) |
| 1044 |
|
| 1045 |
#+:scl |
| 1046 |
(defpackage :make (:use :common-lisp) |
| 1047 |
(:nicknames :mk)) |
| 1048 |
|
| 1049 |
#+(or :cltl2 :lispworks :scl) |
| 1050 |
(eval-when (compile load eval) |
| 1051 |
(in-package "MAKE")) |
| 1052 |
|
| 1053 |
#+ecl |
| 1054 |
(in-package "MAKE") |
| 1055 |
|
| 1056 |
;;; *** Marco Antoniotti <[email protected]> 19970105 |
| 1057 |
;;; 'provide' is not esternal in 'CLTL1' in Allegro v 4.1 |
| 1058 |
#+(and :excl :allegro-v4.0 :cltl2) |
| 1059 |
(cltl1:provide 'make) |
| 1060 |
#+(and :excl :allegro-v4.0 :cltl2) |
| 1061 |
(provide 'make) |
| 1062 |
|
| 1063 |
#+:openmcl |
| 1064 |
(cl:provide 'make) |
| 1065 |
|
| 1066 |
#+(and :mcl (not :openmcl)) |
| 1067 |
(ccl:provide 'make) |
| 1068 |
|
| 1069 |
#+(and :cltl2 (not (or (and :excl (or :allegro-v4.0 :allegro-v4.1)) :mcl))) |
| 1070 |
(provide 'make) |
| 1071 |
|
| 1072 |
#+:lispworks |
| 1073 |
(provide 'make) |
| 1074 |
|
| 1075 |
#-(or :cltl2 :lispworks) |
| 1076 |
(provide 'make) |
| 1077 |
|
| 1078 |
(pushnew :mk-defsystem *features*) |
| 1079 |
|
| 1080 |
;;; Some compatibility issues. Mostly for CormanLisp. |
| 1081 |
;;; 2002-02-20 Marco Antoniotti |
| 1082 |
|
| 1083 |
#+cormanlisp |
| 1084 |
(defun compile-file-pathname (pathname-designator) |
| 1085 |
(merge-pathnames (make-pathname :type "fasl") |
| 1086 |
(etypecase pathname-designator |
| 1087 |
(pathname pathname-designator) |
| 1088 |
(string (parse-namestring pathname-designator)) |
| 1089 |
;; We need FILE-STREAM here as well. |
| 1090 |
))) |
| 1091 |
|
| 1092 |
#+cormanlisp |
| 1093 |
(defun file-namestring (pathname-designator) |
| 1094 |
(let ((p (etypecase pathname-designator |
| 1095 |
(pathname pathname-designator) |
| 1096 |
(string (parse-namestring pathname-designator)) |
| 1097 |
;; We need FILE-STREAM here as well. |
| 1098 |
))) |
| 1099 |
(namestring (make-pathname :directory () |
| 1100 |
:name (pathname-name p) |
| 1101 |
:type (pathname-type p) |
| 1102 |
:version (pathname-version p))))) |
| 1103 |
|
| 1104 |
;;; The external interface consists of *exports* and *other-exports*. |
| 1105 |
|
| 1106 |
;;; AKCL (at least 1.603) grabs all the (export) forms and puts them up top in |
| 1107 |
;;; the compile form, so that you can't use a defvar with a default value and |
| 1108 |
;;; then a succeeding export as well. |
| 1109 |
|
| 1110 |
(eval-when (compile load eval) |
| 1111 |
(defvar *special-exports* nil) |
| 1112 |
(defvar *exports* nil) |
| 1113 |
(defvar *other-exports* nil) |
| 1114 |
|
| 1115 |
(export (setq *exports* |
| 1116 |
'(operate-on-system |
| 1117 |
oos |
| 1118 |
afs-binary-directory afs-source-directory |
| 1119 |
files-in-system))) |
| 1120 |
(export (setq *special-exports* |
| 1121 |
'())) |
| 1122 |
(export (setq *other-exports* |
| 1123 |
'(*central-registry* |
| 1124 |
*bin-subdir* |
| 1125 |
|
| 1126 |
add-registry-location |
| 1127 |
list-central-registry-directories |
| 1128 |
print-central-registry-directories |
| 1129 |
find-system |
| 1130 |
defsystem compile-system load-system hardcopy-system |
| 1131 |
|
| 1132 |
system-definition-pathname |
| 1133 |
|
| 1134 |
missing-component |
| 1135 |
missing-component-name |
| 1136 |
missing-component-component |
| 1137 |
missing-module |
| 1138 |
missing-system |
| 1139 |
|
| 1140 |
register-foreign-system |
| 1141 |
|
| 1142 |
machine-type-translation |
| 1143 |
software-type-translation |
| 1144 |
compiler-type-translation |
| 1145 |
;; require |
| 1146 |
define-language |
| 1147 |
allegro-make-system-fasl |
| 1148 |
files-which-need-compilation |
| 1149 |
undefsystem |
| 1150 |
defined-systems |
| 1151 |
describe-system clean-system edit-system ;hardcopy-system |
| 1152 |
system-source-size make-system-tag-table |
| 1153 |
*defsystem-version* |
| 1154 |
*compile-during-load* |
| 1155 |
*minimal-load* |
| 1156 |
*dont-redefine-require* |
| 1157 |
*files-missing-is-an-error* |
| 1158 |
*reload-systems-from-disk* |
| 1159 |
*source-pathname-default* |
| 1160 |
*binary-pathname-default* |
| 1161 |
*multiple-lisp-support* |
| 1162 |
|
| 1163 |
run-unix-program |
| 1164 |
*default-shell* |
| 1165 |
run-shell-command |
| 1166 |
))) |
| 1167 |
) |
| 1168 |
|
| 1169 |
|
| 1170 |
;;; We import these symbols into the USER package to make them |
| 1171 |
;;; easier to use. Since some lisps have already defined defsystem |
| 1172 |
;;; in the user package, we may have to shadowing-import it. |
| 1173 |
#| |
| 1174 |
#-(or :sbcl :cmu :ccl :allegro :excl :lispworks :symbolics) |
| 1175 |
(eval-when (compile load eval) |
| 1176 |
(import *exports* #-(or :cltl2 :lispworks) "CL-USER" |
| 1177 |
#+(or :cltl2 :lispworks) "COMMON-LISP-USER") |
| 1178 |
(import *special-exports* #-(or :cltl2 :lispworks) "CL-USER" |
| 1179 |
#+(or :cltl2 :lispworks) "COMMON-LISP-USER")) |
| 1180 |
#+(or :sbcl :cmu :ccl :allegro :excl :lispworks :symbolics) |
| 1181 |
(eval-when (compile load eval) |
| 1182 |
(import *exports* #-(or :cltl2 :lispworks) "CL-USER" |
| 1183 |
#+(or :cltl2 :lispworks) "COMMON-LISP-USER") |
| 1184 |
(shadowing-import *special-exports* |
| 1185 |
#-(or :cltl2 :lispworks) "CL-USER" |
| 1186 |
#+(or :cltl2 :lispworks) "COMMON-LISP-USER")) |
| 1187 |
|# |
| 1188 |
|
| 1189 |
#-(or :PCL :CLOS :scl) |
| 1190 |
(when (find-package "PCL") |
| 1191 |
(pushnew :pcl *modules*) |
| 1192 |
(pushnew :pcl *features*)) |
| 1193 |
|
| 1194 |
|
| 1195 |
;;; ******************************** |
| 1196 |
;;; Defsystem Version ************** |
| 1197 |
;;; ******************************** |
| 1198 |
(defparameter *defsystem-version* "3.6 Interim, 2005-09-01" |
| 1199 |
"Current version number/date for MK:DEFSYSTEM.") |
| 1200 |
|
| 1201 |
|
| 1202 |
;;; ******************************** |
| 1203 |
;;; Customizable System Parameters * |
| 1204 |
;;; ******************************** |
| 1205 |
|
| 1206 |
(defvar *dont-redefine-require* |
| 1207 |
#+cmu (if (find-symbol "*MODULE-PROVIDER-FUNCTIONS*" "EXT") t nil) |
| 1208 |
#+(or clisp sbcl) t |
| 1209 |
#+allegro t |
| 1210 |
#-(or cmu sbcl clisp allegro) nil |
| 1211 |
"If T, prevents the redefinition of REQUIRE. |
| 1212 |
This is useful for lisps that treat REQUIRE specially in the compiler.") |
| 1213 |
|
| 1214 |
|
| 1215 |
(defvar *multiple-lisp-support* t |
| 1216 |
"If T, afs-binary-directory will try to return a name dependent |
| 1217 |
on the particular lisp compiler version being used.") |
| 1218 |
|
| 1219 |
|
| 1220 |
;;; home-subdirectory -- |
| 1221 |
;;; HOME-SUBDIRECTORY is used only in *central-registry* below. |
| 1222 |
;;; Note that CMU CL 17e does not understand the ~/ shorthand for home |
| 1223 |
;;; directories. |
| 1224 |
;;; |
| 1225 |
;;; Note: |
| 1226 |
;;; 20020220 Marco Antoniotti |
| 1227 |
;;; The #-cormanlisp version is the original one, which is broken anyway, since |
| 1228 |
;;; it is UNIX dependent. |
| 1229 |
;;; I added the kludgy #+cormalisp (v 1.5) one, since it is missing |
| 1230 |
;;; the ANSI USER-HOMEDIR-PATHNAME function. |
| 1231 |
|
| 1232 |
#-cormanlisp |
| 1233 |
(defun home-subdirectory (directory) |
| 1234 |
(concatenate 'string |
| 1235 |
#+(or :sbcl :cmu :scl) |
| 1236 |
"home:" |
| 1237 |
#-(or :sbcl :cmu :scl) |
| 1238 |
(let ((homedir (user-homedir-pathname))) |
| 1239 |
(or (and homedir (namestring homedir)) |
| 1240 |
"~/")) |
| 1241 |
directory)) |
| 1242 |
|
| 1243 |
|
| 1244 |
#+cormanlisp |
| 1245 |
(defun home-subdirectory (directory) |
| 1246 |
(declare (type string directory)) |
| 1247 |
(concatenate 'string "C:\\" directory)) |
| 1248 |
|
| 1249 |
|
| 1250 |
;;; The following function is available for users to add |
| 1251 |
;;; (setq mk:*central-registry* (defsys-env-search-path)) |
| 1252 |
;;; to Lisp init files in order to use the value of the DEFSYSPATH |
| 1253 |
;;; instead of directly coding it in the file. |
| 1254 |
|
| 1255 |
#+:allegro |
| 1256 |
(defun defsys-env-search-path () |
| 1257 |
"This function grabs the value of the DEFSYSPATH environment variable |
| 1258 |
and breaks the search path into a list of paths." |
| 1259 |
(remove-duplicates (split-string (sys:getenv "DEFSYSPATH") :item #\:) |
| 1260 |
:test #'string-equal)) |
| 1261 |
|
| 1262 |
|
| 1263 |
;;; Change this variable to set up the location of a central |
| 1264 |
;;; repository for system definitions if you want one. |
| 1265 |
;;; This is a defvar to allow users to change the value in their |
| 1266 |
;;; lisp init files without worrying about it reverting if they |
| 1267 |
;;; reload defsystem for some reason. |
| 1268 |
|
| 1269 |
;;; Note that if a form is included in the registry list, it will be evaluated |
| 1270 |
;;; in COMPUTE-SYSTEM-PATH to return the appropriate directory to check. |
| 1271 |
|
| 1272 |
(defvar *central-registry* |
| 1273 |
`(;; Current directory |
| 1274 |
"./" |
| 1275 |
#+:LUCID (working-directory) |
| 1276 |
#+ACLPC (current-directory) |
| 1277 |
#+:allegro (excl:current-directory) |
| 1278 |
#+:clisp (ext:default-directory) |
| 1279 |
#+:sbcl (progn *default-pathname-defaults*) |
| 1280 |
#+(or :cmu :scl) (ext:default-directory) |
| 1281 |
;; *** Marco Antoniotti <[email protected]> |
| 1282 |
;; Somehow it is better to qualify default-directory in CMU with |
| 1283 |
;; the appropriate package (i.e. "EXTENSIONS".) |
| 1284 |
;; Same for Allegro. |
| 1285 |
#+(and :lispworks (not :lispworks4)) |
| 1286 |
,(multiple-value-bind (major minor) |
| 1287 |
#-:lispworks-personal-edition |
| 1288 |
(system::lispworks-version) |
| 1289 |
#+:lispworks-personal-edition |
| 1290 |
(values system::*major-version-number* |
| 1291 |
system::*minor-version-number*) |
| 1292 |
(if (or (> major 3) |
| 1293 |
(and (= major 3) (> minor 2)) |
| 1294 |
(and (= major 3) (= minor 2) |
| 1295 |
(equal (lisp-implementation-version) "3.2.1"))) |
| 1296 |
`(make-pathname :directory |
| 1297 |
,(find-symbol "*CURRENT-WORKING-DIRECTORY*" |
| 1298 |
(find-package "SYSTEM"))) |
| 1299 |
(find-symbol "*CURRENT-WORKING-DIRECTORY*" |
| 1300 |
(find-package "LW")))) |
| 1301 |
#+:lispworks4 |
| 1302 |
(hcl:get-working-directory) |
| 1303 |
;; Home directory |
| 1304 |
#-sbcl |
| 1305 |
(mk::home-subdirectory "lisp/systems/") |
| 1306 |
|
| 1307 |
;; Global registry |
| 1308 |
#+unix (pathname "/usr/local/lisp/Registry/") |
| 1309 |
) |
| 1310 |
"Central directory of system definitions. |
| 1311 |
May be either a single directory pathname, or a list of directory |
| 1312 |
pathnames to be checked after the local directory.") |
| 1313 |
|
| 1314 |
|
| 1315 |
(defun add-registry-location (pathname) |
| 1316 |
"Adds a path to the central registry." |
| 1317 |
(pushnew pathname *central-registry* :test #'equal)) |
| 1318 |
|
| 1319 |
|
| 1320 |
(defun registry-pathname (registry) |
| 1321 |
"Return the pathname represented by the element of *CENTRAL-REGISTRY*." |
| 1322 |
(typecase registry |
| 1323 |
(string (pathname registry)) |
| 1324 |
(pathname registry) |
| 1325 |
(otherwise (pathname (eval registry))))) |
| 1326 |
|
| 1327 |
|
| 1328 |
(defun print-central-registry-directories (&optional (stream *standard-output*)) |
| 1329 |
(dolist (registry *central-registry*) |
| 1330 |
(print (registry-pathname registry) stream))) |
| 1331 |
|
| 1332 |
|
| 1333 |
(defun list-central-registry-directories () |
| 1334 |
(mapcar #'registry-pathname *central-registry*)) |
| 1335 |
|
| 1336 |
|
| 1337 |
(defvar *bin-subdir* ".bin/" |
| 1338 |
"The subdirectory of an AFS directory where the binaries are really kept.") |
| 1339 |
|
| 1340 |
|
| 1341 |
;;; These variables set up defaults for operate-on-system, and are used |
| 1342 |
;;; for communication in lieu of parameter passing. Yes, this is bad, |
| 1343 |
;;; but it keeps the interface small. Also, in the case of the -if-no-binary |
| 1344 |
;;; variables, parameter passing would require multiple value returns |
| 1345 |
;;; from some functions. Why make life complicated? |
| 1346 |
|
| 1347 |
(defvar *tell-user-when-done* nil |
| 1348 |
"If T, system will print ...DONE at the end of an operation") |
| 1349 |
|
| 1350 |
(defvar *oos-verbose* nil |
| 1351 |
"Operate on System Verbose Mode") |
| 1352 |
|
| 1353 |
(defvar *oos-test* nil |
| 1354 |
"Operate on System Test Mode") |
| 1355 |
|
| 1356 |
(defvar *load-source-if-no-binary* nil |
| 1357 |
"If T, system will try loading the source if the binary is missing") |
| 1358 |
|
| 1359 |
(defvar *bother-user-if-no-binary* t |
| 1360 |
"If T, the system will ask the user whether to load the source if |
| 1361 |
the binary is missing") |
| 1362 |
|
| 1363 |
(defvar *load-source-instead-of-binary* nil |
| 1364 |
"If T, the system will load the source file instead of the binary.") |
| 1365 |
|
| 1366 |
(defvar *compile-during-load* :query |
| 1367 |
"If T, the system will compile source files during load if the |
| 1368 |
binary file is missing. If :query, it will ask the user for |
| 1369 |
permission first.") |
| 1370 |
|
| 1371 |
(defvar *minimal-load* nil |
| 1372 |
"If T, the system tries to avoid reloading files that were already loaded |
| 1373 |
and up to date.") |
| 1374 |
|
| 1375 |
(defvar *files-missing-is-an-error* t |
| 1376 |
"If both the source and binary files are missing, signal a continuable |
| 1377 |
error instead of just a warning.") |
| 1378 |
|
| 1379 |
(defvar *operations-propagate-to-subsystems* t |
| 1380 |
"If T, operations like :COMPILE and :LOAD propagate to subsystems |
| 1381 |
of a system that are defined either using a component-type of :system |
| 1382 |
or by another defsystem form.") |
| 1383 |
|
| 1384 |
;;; Particular to CMULisp |
| 1385 |
|
| 1386 |
(defvar *compile-error-file-type* "err" |
| 1387 |
"File type of compilation error file in cmulisp") |
| 1388 |
|
| 1389 |
(defvar *cmu-errors-to-terminal* t |
| 1390 |
"Argument to :errors-to-terminal in compile-file in cmulisp") |
| 1391 |
|
| 1392 |
(defvar *cmu-errors-to-file* t |
| 1393 |
"If T, cmulisp will write an error file during compilation") |
| 1394 |
|
| 1395 |
|
| 1396 |
;;; ******************************** |
| 1397 |
;;; Global Variables *************** |
| 1398 |
;;; ******************************** |
| 1399 |
|
| 1400 |
;;; Massage people's *features* into better shape. |
| 1401 |
(eval-when (compile load eval) |
| 1402 |
(dolist (feature *features*) |
| 1403 |
(when (and (symbolp feature) ; 3600 |
| 1404 |
(equal (symbol-name feature) "CMU")) |
| 1405 |
(pushnew :CMU *features*))) |
| 1406 |
|
| 1407 |
#+Lucid |
| 1408 |
(when (search "IBM RT PC" (machine-type)) |
| 1409 |
(pushnew :ibm-rt-pc *features*)) |
| 1410 |
) |
| 1411 |
|
| 1412 |
|
| 1413 |
;;; *filename-extensions* is a cons of the source and binary extensions. |
| 1414 |
(defvar *filename-extensions* |
| 1415 |
(car `(#+(and Symbolics Lispm) ("lisp" . "bin") |
| 1416 |
#+(and dec common vax (not ultrix)) ("LSP" . "FAS") |
| 1417 |
#+(and dec common vax ultrix) ("lsp" . "fas") |
| 1418 |
#+ACLPC ("lsp" . "fsl") |
| 1419 |
#+CLISP ("lisp" . "fas") |
| 1420 |
#+KCL ("lsp" . "o") |
| 1421 |
#+ECL ("lsp" . "fas") |
| 1422 |
#+IBCL ("lsp" . "o") |
| 1423 |
#+Xerox ("lisp" . "dfasl") |
| 1424 |
;; Lucid on Silicon Graphics |
| 1425 |
#+(and Lucid MIPS) ("lisp" . "mbin") |
| 1426 |
;; the entry for (and lucid hp300) must precede |
| 1427 |
;; that of (and lucid mc68000) for hp9000/300's running lucid, |
| 1428 |
;; since *features* on hp9000/300's also include the :mc68000 |
| 1429 |
;; feature. |
| 1430 |
#+(and lucid hp300) ("lisp" . "6bin") |
| 1431 |
#+(and Lucid MC68000) ("lisp" . "lbin") |
| 1432 |
#+(and Lucid Vax) ("lisp" . "vbin") |
| 1433 |
#+(and Lucid Prime) ("lisp" . "pbin") |
| 1434 |
#+(and Lucid SUNRise) ("lisp" . "sbin") |
| 1435 |
#+(and Lucid SPARC) ("lisp" . "sbin") |
| 1436 |
#+(and Lucid :IBM-RT-PC) ("lisp" . "bbin") |
| 1437 |
;; PA is Precision Architecture, HP's 9000/800 RISC cpu |
| 1438 |
#+(and Lucid PA) ("lisp" . "hbin") |
| 1439 |
#+excl ("cl" . ,(pathname-type (compile-file-pathname "foo.cl"))) |
| 1440 |
#+(or :cmu :scl) ("lisp" . ,(or (c:backend-fasl-file-type c:*backend*) "fasl")) |
| 1441 |
; #+(and :CMU (not (or :sgi :sparc))) ("lisp" . "fasl") |
| 1442 |
; #+(and :CMU :sgi) ("lisp" . "sgif") |
| 1443 |
; #+(and :CMU :sparc) ("lisp" . "sparcf") |
| 1444 |
#+PRIME ("lisp" . "pbin") |
| 1445 |
#+HP ("l" . "b") |
| 1446 |
#+TI ("lisp" . #.(string (si::local-binary-file-type))) |
| 1447 |
#+:gclisp ("LSP" . "F2S") |
| 1448 |
#+pyramid ("clisp" . "o") |
| 1449 |
|
| 1450 |
;; Harlequin LispWorks |
| 1451 |
#+:lispworks ("lisp" . ,COMPILER:*FASL-EXTENSION-STRING*) |
| 1452 |
; #+(and :sun4 :lispworks) ("lisp" . "wfasl") |
| 1453 |
; #+(and :mips :lispworks) ("lisp" . "mfasl") |
| 1454 |
#+:mcl ("lisp" . ,(pathname-type (compile-file-pathname "foo.lisp"))) |
| 1455 |
#+:coral ("lisp" . "fasl") |
| 1456 |
|
| 1457 |
;; Otherwise, |
| 1458 |
("lisp" . ,(pathname-type (compile-file-pathname "foo.lisp"))))) |
| 1459 |
"Filename extensions for Common Lisp. |
| 1460 |
A cons of the form (Source-Extension . Binary-Extension). If the |
| 1461 |
system is unknown (as in *features* not known), defaults to lisp and |
| 1462 |
fasl.") |
| 1463 |
|
| 1464 |
(defvar *system-extension* |
| 1465 |
;; MS-DOS systems can only handle three character extensions. |
| 1466 |
#-ACLPC "system" |
| 1467 |
#+ACLPC "sys" |
| 1468 |
"The filename extension to use with systems.") |
| 1469 |
|
| 1470 |
|
| 1471 |
;;; The above variables and code should be extended to allow a list of |
| 1472 |
;;; valid extensions for each lisp implementation, instead of a single |
| 1473 |
;;; extension. When writing a file, the first extension should be used. |
| 1474 |
;;; But when searching for a file, every extension in the list should |
| 1475 |
;;; be used. For example, CMU Common Lisp recognizes "lisp" "l" "cl" and |
| 1476 |
;;; "lsp" (*load-source-types*) as source code extensions, and |
| 1477 |
;;; (c:backend-fasl-file-type c:*backend*) |
| 1478 |
;;; (c:backend-byte-fasl-file-type c:*backend*) |
| 1479 |
;;; and "fasl" as binary (object) file extensions (*load-object-types*). |
| 1480 |
|
| 1481 |
;;; Note that the above code is used below in the LANGUAGE defstruct. |
| 1482 |
|
| 1483 |
;;; There is no real support for this variable being nil, so don't change it. |
| 1484 |
;;; Note that in any event, the toplevel system (defined with defsystem) |
| 1485 |
;;; will have its dependencies delayed. Not having dependencies delayed |
| 1486 |
;;; might be useful if we define several systems within one defsystem. |
| 1487 |
|
| 1488 |
(defvar *system-dependencies-delayed* t |
| 1489 |
"If T, system dependencies are expanded at run time") |
| 1490 |
|
| 1491 |
|
| 1492 |
;;; Replace this with consp, dammit! |
| 1493 |
(defun non-empty-listp (list) |
| 1494 |
(and list (listp list))) |
| 1495 |
|
| 1496 |
|
| 1497 |
;;; ******************************** |
| 1498 |
;;; Component Operation Definition * |
| 1499 |
;;; ******************************** |
| 1500 |
(eval-when (:compile-toplevel :load-toplevel :execute) |
| 1501 |
|
| 1502 |
(defvar *version-dir* nil |
| 1503 |
"The version subdir. bound in operate-on-system.") |
| 1504 |
|
| 1505 |
(defvar *version-replace* nil |
| 1506 |
"The version replace. bound in operate-on-system.") |
| 1507 |
|
| 1508 |
(defvar *version* nil |
| 1509 |
"Default version.")) |
| 1510 |
|
| 1511 |
(defvar *component-operations* (make-hash-table :test #'equal) |
| 1512 |
"Hash table of (operation-name function) pairs.") |
| 1513 |
|
| 1514 |
(defun component-operation (name &optional operation) |
| 1515 |
(if operation |
| 1516 |
(setf (gethash name *component-operations*) operation) |
| 1517 |
(gethash name *component-operations*))) |
| 1518 |
|
| 1519 |
|
| 1520 |
;;; ******************************** |
| 1521 |
;;; AFS @sys immitator ************* |
| 1522 |
;;; ******************************** |
| 1523 |
|
| 1524 |
;;; mc 11-Apr-91: Bashes MCL's point reader, so commented out. |
| 1525 |
#-:mcl |
| 1526 |
(eval-when (compile load eval) |
| 1527 |
;; Define #@"foo" as a shorthand for (afs-binary-directory "foo"). |
| 1528 |
;; For example, |
| 1529 |
;; <cl> #@"foo" |
| 1530 |
;; "foo/.bin/rt_mach/" |
| 1531 |
(set-dispatch-macro-character |
| 1532 |
#\# #\@ |
| 1533 |
#'(lambda (stream char arg) |
| 1534 |
(declare (ignore char arg)) |
| 1535 |
`(afs-binary-directory ,(read stream t nil t))))) |
| 1536 |
|
| 1537 |
|
| 1538 |
(defvar *find-irix-version-script* |
| 1539 |
"\"1,4 d\\ |
| 1540 |
s/^[^M]*IRIX Execution Environment 1, *[a-zA-Z]* *\\([^ ]*\\)/\\1/p\\ |
| 1541 |
/./,$ d\\ |
| 1542 |
\"") |
| 1543 |
|
| 1544 |
|
| 1545 |
(defun operating-system-version () |
| 1546 |
#+(and :sgi :excl) |
| 1547 |
(let* ((full-version (software-version)) |
| 1548 |
(blank-pos (search " " full-version)) |
| 1549 |
(os (subseq full-version 0 blank-pos)) |
| 1550 |
(version-rest (subseq full-version |
| 1551 |
(1+ blank-pos))) |
| 1552 |
os-version) |
| 1553 |
(setq blank-pos (search " " version-rest)) |
| 1554 |
(setq version-rest (subseq version-rest |
| 1555 |
(1+ blank-pos))) |
| 1556 |
(setq blank-pos (search " " version-rest)) |
| 1557 |
(setq os-version (subseq version-rest 0 blank-pos)) |
| 1558 |
(setq version-rest (subseq version-rest |
| 1559 |
(1+ blank-pos))) |
| 1560 |
(setq blank-pos (search " " version-rest)) |
| 1561 |
(setq version-rest (subseq version-rest |
| 1562 |
(1+ blank-pos))) |
| 1563 |
(concatenate 'string |
| 1564 |
os " " os-version)) ; " " version-rest |
| 1565 |
#+(and :sgi :cmu :sbcl) |
| 1566 |
(concatenate 'string |
| 1567 |
(software-type) |
| 1568 |
(software-version)) |
| 1569 |
#+(and :lispworks :irix) |
| 1570 |
(let ((soft-type (software-type))) |
| 1571 |
(if (equalp soft-type "IRIX5") |
| 1572 |
(progn |
| 1573 |
(foreign:call-system |
| 1574 |
(format nil "versions ~A | sed -e ~A > ~A" |
| 1575 |
"eoe1" |
| 1576 |
*find-irix-version-script* |
| 1577 |
"irix-version") |
| 1578 |
"/bin/csh") |
| 1579 |
(with-open-file (s "irix-version") |
| 1580 |
(format nil "IRIX ~S" |
| 1581 |
(read s)))) |
| 1582 |
soft-type)) |
| 1583 |
#-(or (and :excl :sgi) (and :cmu :sgi) (and :lispworks :irix)) |
| 1584 |
(software-type)) |
| 1585 |
|
| 1586 |
|
| 1587 |
(defun compiler-version () |
| 1588 |
#+:lispworks (concatenate 'string |
| 1589 |
"lispworks" " " (lisp-implementation-version)) |
| 1590 |
#+excl (concatenate 'string |
| 1591 |
"excl" " " excl::*common-lisp-version-number*) |
| 1592 |
#+sbcl (concatenate 'string |
| 1593 |
"sbcl" " " (lisp-implementation-version)) |
| 1594 |
#+cmu (concatenate 'string |
| 1595 |
"cmu" " " (lisp-implementation-version)) |
| 1596 |
#+scl (concatenate 'string |
| 1597 |
"scl" " " (lisp-implementation-version)) |
| 1598 |
|
| 1599 |
#+kcl "kcl" |
| 1600 |
#+IBCL "ibcl" |
| 1601 |
#+akcl "akcl" |
| 1602 |
#+gcl "gcl" |
| 1603 |
#+ecl "ecl" |
| 1604 |
#+lucid "lucid" |
| 1605 |
#+ACLPC "aclpc" |
| 1606 |
#+CLISP "clisp" |
| 1607 |
#+Xerox "xerox" |
| 1608 |
#+symbolics "symbolics" |
| 1609 |
#+mcl "mcl" |
| 1610 |
#+coral "coral" |
| 1611 |
#+gclisp "gclisp" |
| 1612 |
) |
| 1613 |
|
| 1614 |
|
| 1615 |
(defun afs-binary-directory (root-directory) |
| 1616 |
;; Function for obtaining the directory AFS's @sys feature would have |
| 1617 |
;; chosen when we're not in AFS. This function is useful as the argument |
| 1618 |
;; to :binary-pathname in defsystem. For example, |
| 1619 |
;; :binary-pathname (afs-binary-directory "scanner/") |
| 1620 |
(let ((machine (machine-type-translation |
| 1621 |
#-(and :sgi :allegro-version>= (version>= 4 2)) |
| 1622 |
(machine-type) |
| 1623 |
#+(and :sgi :allegro-version>= (version>= 4 2)) |
| 1624 |
(machine-version))) |
| 1625 |
(software (software-type-translation |
| 1626 |
#-(and :sgi (or :cmu :sbcl :scl |
| 1627 |
(and :allegro-version>= (version>= 4 2)))) |
| 1628 |
(software-type) |
| 1629 |
#+(and :sgi (or :cmu :sbcl :scl |
| 1630 |
(and :allegro-version>= (version>= 4 2)))) |
| 1631 |
(operating-system-version))) |
| 1632 |
(lisp (compiler-type-translation (compiler-version)))) |
| 1633 |
;; pmax_mach rt_mach sun3_35 sun3_mach vax_mach |
| 1634 |
(setq root-directory (namestring root-directory)) |
| 1635 |
(setq root-directory (ensure-trailing-slash root-directory)) |
| 1636 |
(format nil "~A~@[~A~]~@[~A/~]" |
| 1637 |
root-directory |
| 1638 |
*bin-subdir* |
| 1639 |
(if *multiple-lisp-support* |
| 1640 |
(afs-component machine software lisp) |
| 1641 |
(afs-component machine software))))) |
| 1642 |
|
| 1643 |
(defun afs-source-directory (root-directory &optional version-flag) |
| 1644 |
;; Function for obtaining the directory AFS's @sys feature would have |
| 1645 |
;; chosen when we're not in AFS. This function is useful as the argument |
| 1646 |
;; to :source-pathname in defsystem. |
| 1647 |
(setq root-directory (namestring root-directory)) |
| 1648 |
(setq root-directory (ensure-trailing-slash root-directory)) |
| 1649 |
(format nil "~A~@[~A/~]" |
| 1650 |
root-directory |
| 1651 |
(and version-flag (translate-version *version*)))) |
| 1652 |
|
| 1653 |
|
| 1654 |
(defun null-string (s) |
| 1655 |
(when (stringp s) |
| 1656 |
(string-equal s ""))) |
| 1657 |
|
| 1658 |
|
| 1659 |
(defun ensure-trailing-slash (dir) |
| 1660 |
(if (and dir |
| 1661 |
(not (null-string dir)) |
| 1662 |
(not (char= (char dir |
| 1663 |
(1- (length dir))) |
| 1664 |
#\/)) |
| 1665 |
(not (char= (char dir |
| 1666 |
(1- (length dir))) |
| 1667 |
#\\)) |
| 1668 |
) |
| 1669 |
(concatenate 'string dir "/") |
| 1670 |
dir)) |
| 1671 |
|
| 1672 |
|
| 1673 |
(defun afs-component (machine software &optional lisp) |
| 1674 |
(format nil "~@[~A~]~@[_~A~]~@[_~A~]" |
| 1675 |
machine |
| 1676 |
(or software "mach") |
| 1677 |
lisp)) |
| 1678 |
|
| 1679 |
|
| 1680 |
(defvar *machine-type-alist* (make-hash-table :test #'equal) |
| 1681 |
"Hash table for retrieving the machine-type") |
| 1682 |
|
| 1683 |
(defun machine-type-translation (name &optional operation) |
| 1684 |
(if operation |
| 1685 |
(setf (gethash (string-upcase name) *machine-type-alist*) operation) |
| 1686 |
(gethash (string-upcase name) *machine-type-alist*))) |
| 1687 |
|
| 1688 |
|
| 1689 |
(machine-type-translation "IBM RT PC" "rt") |
| 1690 |
(machine-type-translation "DEC 3100" "pmax") |
| 1691 |
(machine-type-translation "DEC VAX-11" "vax") |
| 1692 |
(machine-type-translation "DECstation" "pmax") |
| 1693 |
(machine-type-translation "Sun3" "sun3") |
| 1694 |
(machine-type-translation "Sun-4" "sun4") |
| 1695 |
(machine-type-translation "MIPS Risc" "mips") |
| 1696 |
(machine-type-translation "SGI" "sgi") |
| 1697 |
(machine-type-translation "Silicon Graphics Iris 4D" "sgi") |
| 1698 |
(machine-type-translation "Silicon Graphics Iris 4D (R3000)" "sgi") |
| 1699 |
(machine-type-translation "Silicon Graphics Iris 4D (R4000)" "sgi") |
| 1700 |
(machine-type-translation "Silicon Graphics Iris 4D (R4400)" "sgi") |
| 1701 |
(machine-type-translation "IP22" "sgi") |
| 1702 |
;;; MIPS R4000 Processor Chip Revision: 3.0 |
| 1703 |
;;; MIPS R4400 Processor Chip Revision: 5.0 |
| 1704 |
;;; MIPS R4600 Processor Chip Revision: 1.0 |
| 1705 |
(machine-type-translation "IP20" "sgi") |
| 1706 |
;;; MIPS R4000 Processor Chip Revision: 3.0 |
| 1707 |
(machine-type-translation "IP17" "sgi") |
| 1708 |
;;; MIPS R4000 Processor Chip Revision: 2.2 |
| 1709 |
(machine-type-translation "IP12" "sgi") |
| 1710 |
;;; MIPS R2000A/R3000 Processor Chip Revision: 3.0 |
| 1711 |
(machine-type-translation "IP7" "sgi") |
| 1712 |
;;; MIPS R2000A/R3000 Processor Chip Revision: 3.0 |
| 1713 |
|
| 1714 |
(machine-type-translation "x86" "x86") |
| 1715 |
;;; ACL |
| 1716 |
(machine-type-translation "IBM PC Compatible" "x86") |
| 1717 |
;;; LW |
| 1718 |
(machine-type-translation "I686" "x86") |
| 1719 |
;;; LW |
| 1720 |
(machine-type-translation "PC/386" "x86") |
| 1721 |
;;; CLisp Win32 |
| 1722 |
|
| 1723 |
#+(and :lucid :sun :mc68000) |
| 1724 |
(machine-type-translation "unknown" "sun3") |
| 1725 |
|
| 1726 |
|
| 1727 |
(defvar *software-type-alist* (make-hash-table :test #'equal) |
| 1728 |
"Hash table for retrieving the software-type") |
| 1729 |
|
| 1730 |
(defun software-type-translation (name &optional operation) |
| 1731 |
(if operation |
| 1732 |
(setf (gethash (string-upcase name) *software-type-alist*) operation) |
| 1733 |
(gethash (string-upcase name) *software-type-alist*))) |
| 1734 |
|
| 1735 |
|
| 1736 |
(software-type-translation "BSD UNIX" "mach") ; "unix" |
| 1737 |
(software-type-translation "Ultrix" "mach") ; "ultrix" |
| 1738 |
(software-type-translation "SunOS" "SunOS") |
| 1739 |
(software-type-translation "MACH/4.3BSD" "mach") |
| 1740 |
(software-type-translation "IRIX System V" "irix") ; (software-type) |
| 1741 |
(software-type-translation "IRIX5" "irix5") |
| 1742 |
;;(software-type-translation "IRIX liasg5 5.2 02282016 IP22 mips" "irix5") ; (software-version) |
| 1743 |
|
| 1744 |
(software-type-translation "IRIX 5.2" "irix5") |
| 1745 |
(software-type-translation "IRIX 5.3" "irix5") |
| 1746 |
(software-type-translation "IRIX5.2" "irix5") |
| 1747 |
(software-type-translation "IRIX5.3" "irix5") |
| 1748 |
|
| 1749 |
(software-type-translation "Linux" "linux") ; Lispworks for Linux |
| 1750 |
(software-type-translation "Linux 2.x, Redhat 6.x and 7.x" "linux") ; ACL |
| 1751 |
(software-type-translation "Microsoft Windows 9x/Me and NT/2000/XP" "win32") |
| 1752 |
(software-type-translation "Windows NT" "win32") ; LW for Windows |
| 1753 |
(software-type-translation "ANSI C program" "ansi-c") ; CLISP |
| 1754 |
(software-type-translation "C compiler" "ansi-c") ; CLISP for Win32 |
| 1755 |
|
| 1756 |
(software-type-translation nil "") |
| 1757 |
|
| 1758 |
#+:lucid |
| 1759 |
(software-type-translation "Unix" |
| 1760 |
#+:lcl4.0 "4.0" |
| 1761 |
#+(and :lcl3.0 (not :lcl4.0)) "3.0") |
| 1762 |
|
| 1763 |
|
| 1764 |
(defvar *compiler-type-alist* (make-hash-table :test #'equal) |
| 1765 |
"Hash table for retrieving the Common Lisp type") |
| 1766 |
|
| 1767 |
(defun compiler-type-translation (name &optional operation) |
| 1768 |
(if operation |
| 1769 |
(setf (gethash (string-upcase name) *compiler-type-alist*) operation) |
| 1770 |
(gethash (string-upcase name) *compiler-type-alist*))) |
| 1771 |
|
| 1772 |
|
| 1773 |
(compiler-type-translation "lispworks 3.2.1" "lispworks") |
| 1774 |
(compiler-type-translation "lispworks 3.2.60 beta 6" "lispworks") |
| 1775 |
(compiler-type-translation "lispworks 4.2.0" "lispworks") |
| 1776 |
|
| 1777 |
|
| 1778 |
#+allegro |
| 1779 |
(eval-when (:compile-toplevel :load-toplevel :execute) |
| 1780 |
(unless (or (find :case-sensitive common-lisp:*features*) |
| 1781 |
(find :case-insensitive common-lisp:*features*)) |
| 1782 |
(if (or (eq excl:*current-case-mode* :case-sensitive-lower) |
| 1783 |
(eq excl:*current-case-mode* :case-sensitive-upper)) |
| 1784 |
(push :case-sensitive common-lisp:*features*) |
| 1785 |
(push :case-insensitive common-lisp:*features*)))) |
| 1786 |
|
| 1787 |
|
| 1788 |
#+(and allegro case-sensitive ics) |
| 1789 |
(compiler-type-translation "excl 6.1" "excl-m") |
| 1790 |
#+(and allegro case-sensitive (not ics)) |
| 1791 |
(compiler-type-translation "excl 6.1" "excl-m8") |
| 1792 |
|
| 1793 |
#+(and allegro case-insensitive ics) |
| 1794 |
(compiler-type-translation "excl 6.1" "excl-a") |
| 1795 |
#+(and allegro case-insensitive (not ics)) |
| 1796 |
(compiler-type-translation "excl 6.1" "excl-a8") |
| 1797 |
|
| 1798 |
(compiler-type-translation "excl 4.2" "excl") |
| 1799 |
(compiler-type-translation "excl 4.1" "excl") |
| 1800 |
(compiler-type-translation "cmu 17f" "cmu") |
| 1801 |
(compiler-type-translation "cmu 17e" "cmu") |
| 1802 |
(compiler-type-translation "cmu 17d" "cmu") |
| 1803 |
|
| 1804 |
|
| 1805 |
;;; ******************************** |
| 1806 |
;;; System Names ******************* |
| 1807 |
;;; ******************************** |
| 1808 |
|
| 1809 |
;;; If you use strings for system names, be sure to use the same case |
| 1810 |
;;; as it appears on disk, if the filesystem is case sensitive. |
| 1811 |
|
| 1812 |
(defun canonicalize-system-name (name) |
| 1813 |
;; Originally we were storing systems using GET. This meant that the |
| 1814 |
;; name of a system had to be a symbol, so we interned the symbols |
| 1815 |
;; in the keyword package to avoid package dependencies. Now that we're |
| 1816 |
;; storing the systems in a hash table, we've switched to using strings. |
| 1817 |
;; Since the hash table is case sensitive, we use uppercase strings. |
| 1818 |
;; (Names of modules and files may be symbols or strings.) |
| 1819 |
#||(if (keywordp name) |
| 1820 |
name |
| 1821 |
(intern (string-upcase (string name)) "KEYWORD"))||# |
| 1822 |
(if (stringp name) (string-upcase name) (string-upcase (string name)))) |
| 1823 |
|
| 1824 |
|
| 1825 |
(defvar *defined-systems* (make-hash-table :test #'equal) |
| 1826 |
"Hash table containing the definitions of all known systems.") |
| 1827 |
|
| 1828 |
|
| 1829 |
(defun get-system (name) |
| 1830 |
"Returns the definition of the system named NAME." |
| 1831 |
(gethash (canonicalize-system-name name) *defined-systems*)) |
| 1832 |
|
| 1833 |
|
| 1834 |
(defsetf get-system (name) (value) |
| 1835 |
`(setf (gethash (canonicalize-system-name ,name) *defined-systems*) ,value)) |
| 1836 |
|
| 1837 |
|
| 1838 |
(defun undefsystem (name) |
| 1839 |
"Removes the definition of the system named NAME." |
| 1840 |
(remhash (canonicalize-system-name name) *defined-systems*)) |
| 1841 |
|
| 1842 |
|
| 1843 |
(defun defined-systems () |
| 1844 |
"Returns a list of defined systems." |
| 1845 |
(let ((result nil)) |
| 1846 |
(maphash #'(lambda (key value) |
| 1847 |
(declare (ignore key)) |
| 1848 |
(push value result)) |
| 1849 |
*defined-systems*) |
| 1850 |
result)) |
| 1851 |
|
| 1852 |
|
| 1853 |
(defun defined-names-and-systems () |
| 1854 |
"Returns a a-list of defined systems along with their names." |
| 1855 |
(loop for sname being the hash-keys of *defined-systems* |
| 1856 |
using (hash-value s) |
| 1857 |
collect (cons sname s))) |
| 1858 |
|
| 1859 |
|
| 1860 |
;;; ******************************** |
| 1861 |
;;; Directory Pathname Hacking ***** |
| 1862 |
;;; ******************************** |
| 1863 |
|
| 1864 |
;;; Unix example: An absolute directory starts with / while a |
| 1865 |
;;; relative directory doesn't. A directory ends with /, while |
| 1866 |
;;; a file's pathname doesn't. This is important 'cause |
| 1867 |
;;; (pathname-directory "foo/bar") will return "foo" and not "foo/". |
| 1868 |
|
| 1869 |
;;; I haven't been able to test the fix to the problem with symbolics |
| 1870 |
;;; hosts. Essentially, append-directories seems to have been tacking |
| 1871 |
;;; the default host onto the front of the pathname (e.g., mk::source-pathname |
| 1872 |
;;; gets a "B:" on front) and this overrides the :host specified in the |
| 1873 |
;;; component. The value of :host should override that specified in |
| 1874 |
;;; the :source-pathname and the default file server. If this doesn't |
| 1875 |
;;; fix things, specifying the host in the root pathname "F:>root-dir>" |
| 1876 |
;;; may be a good workaround. |
| 1877 |
|
| 1878 |
;;; Need to verify that merging of pathnames where modules are located |
| 1879 |
;;; on different devices (in VMS-based VAXLisp) now works. |
| 1880 |
|
| 1881 |
;;; Merge-pathnames works for VMS systems. In VMS systems, the directory |
| 1882 |
;;; part is enclosed in square brackets, e.g., |
| 1883 |
;;; "[root.child.child_child]" or "[root.][child.][child_child]" |
| 1884 |
;;; To concatenate directories merge-pathnames works as follows: |
| 1885 |
;;; (merge-pathnames "" "[root]") ==> "[root]" |
| 1886 |
;;; (merge-pathnames "[root.]" "[son]file.ext") ==> "[root.son]file.ext" |
| 1887 |
;;; (merge-pathnames "[root.]file.ext" "[son]") ==> "[root.son]file.ext" |
| 1888 |
;;; (merge-pathnames "[root]file.ext" "[son]") ==> "[root]file.ext" |
| 1889 |
;;; Thus the problem with the #-VMS code was that it was merging x y into |
| 1890 |
;;; [[x]][y] instead of [x][y] or [x]y. |
| 1891 |
|
| 1892 |
;;; Miscellaneous notes: |
| 1893 |
;;; On GCLisp, the following are equivalent: |
| 1894 |
;;; "\\root\\subdir\\BAZ" |
| 1895 |
;;; "/root/subdir/BAZ" |
| 1896 |
;;; On VAXLisp, the following are equivalent: |
| 1897 |
;;; "[root.subdir]BAZ" |
| 1898 |
;;; "[root.][subdir]BAZ" |
| 1899 |
;;; Use #+:vaxlisp for VAXLisp 3.0, #+(and vms dec common vax) for v2.2 |
| 1900 |
|
| 1901 |
(defun new-append-directories (absolute-dir relative-dir) |
| 1902 |
;; Version of append-directories for CLtL2-compliant lisps. In particular, |
| 1903 |
;; they must conform to section 23.1.3 "Structured Directories". We are |
| 1904 |
;; willing to fix minor aberations in this function, but not major ones. |
| 1905 |
;; Tested in Allegro CL 4.0 (SPARC), Allegro CL 3.1.12 (DEC 3100), |
| 1906 |
;; CMU CL old and new compilers, Lucid 3.0, Lucid 4.0. |
| 1907 |
(setf absolute-dir (or absolute-dir "") |
| 1908 |
relative-dir (or relative-dir "")) |
| 1909 |
(let* ((abs-dir (pathname absolute-dir)) |
| 1910 |
(rel-dir (pathname relative-dir)) |
| 1911 |
(host (pathname-host abs-dir)) |
| 1912 |
(device (if (null-string absolute-dir) ; fix for CMU CL old compiler |
| 1913 |
(pathname-device rel-dir) |
| 1914 |
(pathname-device abs-dir))) |
| 1915 |
(abs-directory (directory-to-list (pathname-directory abs-dir))) |
| 1916 |
(abs-keyword (when (keywordp (car abs-directory)) |
| 1917 |
(pop abs-directory))) |
| 1918 |
;; Stig (July 2001): |
| 1919 |
;; Somehow CLISP dies on the next line, but NIL is ok. |
| 1920 |
(abs-name (ignore-errors (file-namestring abs-dir))) ; was pathname-name |
| 1921 |
(rel-directory (directory-to-list (pathname-directory rel-dir))) |
| 1922 |
(rel-keyword (when (keywordp (car rel-directory)) |
| 1923 |
(pop rel-directory))) |
| 1924 |
#-(or :MCL :sbcl :clisp) (rel-file (file-namestring rel-dir)) |
| 1925 |
;; Stig (July 2001); |
| 1926 |
;; These values seems to help clisp as well |
| 1927 |
#+(or :MCL :sbcl :clisp) (rel-name (pathname-name rel-dir)) |
| 1928 |
#+(or :MCL :sbcl :clisp) (rel-type (pathname-type rel-dir)) |
| 1929 |
(directory nil)) |
| 1930 |
|
| 1931 |
;; TI Common Lisp pathnames can return garbage for file names because |
| 1932 |
;; of bizarreness in the merging of defaults. The following code makes |
| 1933 |
;; sure that the name is a valid name by comparing it with the |
| 1934 |
;; pathname-name. It also strips TI specific extensions and handles |
| 1935 |
;; the necessary case conversion. TI maps upper back into lower case |
| 1936 |
;; for unix files! |
| 1937 |
#+TI (if (search (pathname-name abs-dir) abs-name :test #'string-equal) |
| 1938 |
(setf abs-name (string-right-trim "." (string-upcase abs-name))) |
| 1939 |
(setf abs-name nil)) |
| 1940 |
#+TI (if (search (pathname-name rel-dir) rel-file :test #'string-equal) |
| 1941 |
(setf rel-file (string-right-trim "." (string-upcase rel-file))) |
| 1942 |
(setf rel-file nil)) |
| 1943 |
;; Allegro v4.0/4.1 parses "/foo" into :directory '(:absolute :root) |
| 1944 |
;; and filename "foo". The namestring of a pathname with |
| 1945 |
;; directory '(:absolute :root "foo") ignores everything after the |
| 1946 |
;; :root. |
| 1947 |
#+(and allegro-version>= (version>= 4 0)) |
| 1948 |
(when (eq (car abs-directory) :root) (pop abs-directory)) |
| 1949 |
#+(and allegro-version>= (version>= 4 0)) |
| 1950 |
(when (eq (car rel-directory) :root) (pop rel-directory)) |
| 1951 |
|
| 1952 |
(when (and abs-name (not (null-string abs-name))) ; was abs-name |
| 1953 |
(cond ((and (null abs-directory) (null abs-keyword)) |
| 1954 |
#-(or :lucid :kcl :akcl TI) (setf abs-keyword :relative) |
| 1955 |
(setf abs-directory (list abs-name))) |
| 1956 |
(t |
| 1957 |
(setf abs-directory (append abs-directory (list abs-name)))))) |
| 1958 |
(when (and (null abs-directory) |
| 1959 |
(or (null abs-keyword) |
| 1960 |
;; In Lucid, an abs-dir of nil gets a keyword of |
| 1961 |
;; :relative since (pathname-directory (pathname "")) |
| 1962 |
;; returns (:relative) instead of nil. |
| 1963 |
#+:lucid (eq abs-keyword :relative)) |
| 1964 |
rel-keyword) |
| 1965 |
;; The following feature switches seem necessary in CMUCL |
| 1966 |
;; Marco Antoniotti 19990707 |
| 1967 |
#+(or :sbcl :CMU) |
| 1968 |
(if (typep abs-dir 'logical-pathname) |
| 1969 |
(setf abs-keyword :absolute) |
| 1970 |
(setf abs-keyword rel-keyword)) |
| 1971 |
#-(or :sbcl :CMU) |
| 1972 |
(setf abs-keyword rel-keyword)) |
| 1973 |
(setf directory (append abs-directory rel-directory)) |
| 1974 |
(when abs-keyword (setf directory (cons abs-keyword directory))) |
| 1975 |
(namestring |
| 1976 |
(make-pathname :host host |
| 1977 |
:device device |
| 1978 |
:directory |
| 1979 |
directory |
| 1980 |
:name |
| 1981 |
#-(or :sbcl :MCL :clisp) rel-file |
| 1982 |
#+(or :sbcl :MCL :clisp) rel-name |
| 1983 |
|
| 1984 |
#+(or :sbcl :MCL :clisp) :type |
| 1985 |
#+(or :sbcl :MCL :clisp) rel-type |
| 1986 |
)))) |
| 1987 |
|
| 1988 |
|
| 1989 |
(defun directory-to-list (directory) |
| 1990 |
;; The directory should be a list, but nonstandard implementations have |
| 1991 |
;; been known to use a vector or even a string. |
| 1992 |
(cond ((listp directory) |
| 1993 |
directory) |
| 1994 |
((stringp directory) |
| 1995 |
(cond ((find #\; directory) |
| 1996 |
;; It's probably a logical pathname, so split at the |
| 1997 |
;; semicolons: |
| 1998 |
(split-string directory :item #\;)) |
| 1999 |
#+MCL |
| 2000 |
((and (find #\: directory) |
| 2001 |
(not (find #\/ directory))) |
| 2002 |
;; It's probably a MCL pathname, so split at the colons. |
| 2003 |
(split-string directory :item #\:)) |
| 2004 |
(t |
| 2005 |
;; It's probably a unix pathname, so split at the slash. |
| 2006 |
(split-string directory :item #\/)))) |
| 2007 |
(t |
| 2008 |
(coerce directory 'list)))) |
| 2009 |
|
| 2010 |
|
| 2011 |
(defparameter *append-dirs-tests* |
| 2012 |
'("~/foo/" "baz/bar.lisp" |
| 2013 |
"~/foo" "baz/bar.lisp" |
| 2014 |
"/foo/bar/" "baz/barf.lisp" |
| 2015 |
"/foo/bar/" "/baz/barf.lisp" |
| 2016 |
"foo/bar/" "baz/barf.lisp" |
| 2017 |
"foo/bar" "baz/barf.lisp" |
| 2018 |
"foo/bar" "/baz/barf.lisp" |
| 2019 |
"foo/bar/" "/baz/barf.lisp" |
| 2020 |
"/foo/bar/" nil |
| 2021 |
"foo/bar/" nil |
| 2022 |
"foo/bar" nil |
| 2023 |
"foo" nil |
| 2024 |
"foo" "" |
| 2025 |
nil "baz/barf.lisp" |
| 2026 |
nil "/baz/barf.lisp" |
| 2027 |
nil nil)) |
| 2028 |
|
| 2029 |
|
| 2030 |
(defun test-new-append-directories (&optional (test-dirs *append-dirs-tests*)) |
| 2031 |
(do* ((dir-list test-dirs (cddr dir-list)) |
| 2032 |
(abs-dir (car dir-list) (car dir-list)) |
| 2033 |
(rel-dir (cadr dir-list) (cadr dir-list))) |
| 2034 |
((null dir-list) (values)) |
| 2035 |
(format t "~&ABS: ~S ~18TREL: ~S ~41TResult: ~S" |
| 2036 |
abs-dir rel-dir (new-append-directories abs-dir rel-dir)))) |
| 2037 |
|
| 2038 |
|
| 2039 |
#|| |
| 2040 |
<cl> (test-new-append-directories) |
| 2041 |
|
| 2042 |
ABS: "~/foo/" REL: "baz/bar.lisp" Result: "/usr0/mkant/foo/baz/bar.lisp" |
| 2043 |
ABS: "~/foo" REL: "baz/bar.lisp" Result: "/usr0/mkant/foo/baz/bar.lisp" |
| 2044 |
ABS: "/foo/bar/" REL: "baz/barf.lisp" Result: "/foo/bar/baz/barf.lisp" |
| 2045 |
ABS: "/foo/bar/" REL: "/baz/barf.lisp" Result: "/foo/bar/baz/barf.lisp" |
| 2046 |
ABS: "foo/bar/" REL: "baz/barf.lisp" Result: "foo/bar/baz/barf.lisp" |
| 2047 |
ABS: "foo/bar" REL: "baz/barf.lisp" Result: "foo/bar/baz/barf.lisp" |
| 2048 |
ABS: "foo/bar" REL: "/baz/barf.lisp" Result: "foo/bar/baz/barf.lisp" |
| 2049 |
ABS: "foo/bar/" REL: "/baz/barf.lisp" Result: "foo/bar/baz/barf.lisp" |
| 2050 |
ABS: "/foo/bar/" REL: NIL Result: "/foo/bar/" |
| 2051 |
ABS: "foo/bar/" REL: NIL Result: "foo/bar/" |
| 2052 |
ABS: "foo/bar" REL: NIL Result: "foo/bar/" |
| 2053 |
ABS: "foo" REL: NIL Result: "foo/" |
| 2054 |
ABS: "foo" REL: "" Result: "foo/" |
| 2055 |
ABS: NIL REL: "baz/barf.lisp" Result: "baz/barf.lisp" |
| 2056 |
ABS: NIL REL: "/baz/barf.lisp" Result: "/baz/barf.lisp" |
| 2057 |
ABS: NIL REL: NIL Result: "" |
| 2058 |
|
| 2059 |
||# |
| 2060 |
|
| 2061 |
|
| 2062 |
(defun append-directories (absolute-directory relative-directory) |
| 2063 |
"There is no CL primitive for tacking a subdirectory onto a directory. |
| 2064 |
We need such a function because defsystem has both absolute and |
| 2065 |
relative pathnames in the modules. This is a somewhat ugly hack which |
| 2066 |
seems to work most of the time. We assume that ABSOLUTE-DIRECTORY |
| 2067 |
is a directory, with no filename stuck on the end. Relative-directory, |
| 2068 |
however, may have a filename stuck on the end." |
| 2069 |
(when (or absolute-directory relative-directory) |
| 2070 |
(cond |
| 2071 |
;; KMR commented out because: when appending two logical pathnames, |
| 2072 |
;; using this code translates the first logical pathname then appends |
| 2073 |
;; the second logical pathname -- an error. |
| 2074 |
#| |
| 2075 |
;; We need a reliable way to determine if a pathname is logical. |
| 2076 |
;; Allegro 4.1 does not recognize the syntax of a logical pathname |
| 2077 |
;; as being logical unless its logical host is already defined. |
| 2078 |
|
| 2079 |
#+(or (and allegro-version>= (version>= 4 1)) |
| 2080 |
:logical-pathnames-mk) |
| 2081 |
((and absolute-directory |
| 2082 |
(logical-pathname-p absolute-directory) |
| 2083 |
relative-directory) |
| 2084 |
;; For use with logical pathnames package. |
| 2085 |
(append-logical-directories-mk absolute-directory relative-directory)) |
| 2086 |
|# |
| 2087 |
((namestring-probably-logical absolute-directory) |
| 2088 |
;; A simplistic stab at handling logical pathnames |
| 2089 |
(append-logical-pnames absolute-directory relative-directory)) |
| 2090 |
(t |
| 2091 |
;; In VMS, merge-pathnames actually does what we want!!! |
| 2092 |
#+:VMS |
| 2093 |
(namestring (merge-pathnames (or absolute-directory "") |
| 2094 |
(or relative-directory ""))) |
| 2095 |
#+:macl1.3.2 |
| 2096 |
(namestring (make-pathname :directory absolute-directory |
| 2097 |
:name relative-directory)) |
| 2098 |
;; Cross your fingers and pray. |
| 2099 |
#-(or :VMS :macl1.3.2) |
| 2100 |
(new-append-directories absolute-directory relative-directory))))) |
| 2101 |
|
| 2102 |
|
| 2103 |
#+:logical-pathnames-mk |
| 2104 |
(defun append-logical-directories-mk (absolute-dir relative-dir) |
| 2105 |
(lp:append-logical-directories absolute-dir relative-dir)) |
| 2106 |
|
| 2107 |
|
| 2108 |
;;; append-logical-pathnames-mk -- |
| 2109 |
;;; The following is probably still bogus and it does not solve the |
| 2110 |
;;; problem of appending two logical pathnames. |
| 2111 |
;;; Anyway, as per suggetsion by KMR, the function is not called |
| 2112 |
;;; anymore. |
| 2113 |
;;; Hopefully this will not cause problems for ACL. |
| 2114 |
|
| 2115 |
#+(and (and allegro-version>= (version>= 4 1)) |
| 2116 |
(not :logical-pathnames-mk)) |
| 2117 |
(defun append-logical-directories-mk (absolute-dir relative-dir) |
| 2118 |
;; We know absolute-dir and relative-dir are non nil. Moreover |
| 2119 |
;; absolute-dir is a logical pathname. |
| 2120 |
(setq absolute-dir (logical-pathname absolute-dir)) |
| 2121 |
(etypecase relative-dir |
| 2122 |
(string (setq relative-dir (parse-namestring relative-dir))) |
| 2123 |
(pathname #| do nothing |#)) |
| 2124 |
|
| 2125 |
(translate-logical-pathname |
| 2126 |
(merge-pathnames relative-dir absolute-dir))) |
| 2127 |
|
| 2128 |
|
| 2129 |
#| Old version 2002-03-02 |
| 2130 |
#+(and (and allegro-version>= (version>= 4 1)) |
| 2131 |
(not :logical-pathnames-mk)) |
| 2132 |
(defun append-logical-directories-mk (absolute-dir relative-dir) |
| 2133 |
;; We know absolute-dir and relative-dir are non nil. Moreover |
| 2134 |
;; absolute-dir is a logical pathname. |
| 2135 |
(setq absolute-dir (logical-pathname absolute-dir)) |
| 2136 |
(etypecase relative-dir |
| 2137 |
(string (setq relative-dir (parse-namestring relative-dir))) |
| 2138 |
(pathname #| do nothing |#)) |
| 2139 |
|
| 2140 |
(translate-logical-pathname |
| 2141 |
(make-pathname |
| 2142 |
:host (or (pathname-host absolute-dir) |
| 2143 |
(pathname-host relative-dir)) |
| 2144 |
:directory (append (pathname-directory absolute-dir) |
| 2145 |
(cdr (pathname-directory relative-dir))) |
| 2146 |
:name (or (pathname-name absolute-dir) |
| 2147 |
(pathname-name relative-dir)) |
| 2148 |
:type (or (pathname-type absolute-dir) |
| 2149 |
(pathname-type relative-dir)) |
| 2150 |
:version (or (pathname-version absolute-dir) |
| 2151 |
(pathname-version relative-dir))))) |
| 2152 |
|
| 2153 |
;; Old version |
| 2154 |
#+(and (and allegro-version>= (version>= 4 1)) |
| 2155 |
(not :logical-pathnames-mk)) |
| 2156 |
(defun append-logical-directories-mk (absolute-dir relative-dir) |
| 2157 |
(when (or absolute-dir relative-dir) |
| 2158 |
(setq absolute-dir (logical-pathname (or absolute-dir "")) |
| 2159 |
relative-dir (logical-pathname (or relative-dir ""))) |
| 2160 |
(translate-logical-pathname |
| 2161 |
(make-pathname |
| 2162 |
:host (or (pathname-host absolute-dir) |
| 2163 |
(pathname-host relative-dir)) |
| 2164 |
:directory (append (pathname-directory absolute-dir) |
| 2165 |
(cdr (pathname-directory relative-dir))) |
| 2166 |
:name (or (pathname-name absolute-dir) |
| 2167 |
(pathname-name relative-dir)) |
| 2168 |
:type (or (pathname-type absolute-dir) |
| 2169 |
(pathname-type relative-dir)) |
| 2170 |
:version (or (pathname-version absolute-dir) |
| 2171 |
(pathname-version relative-dir)))))) |
| 2172 |
|# |
| 2173 |
|
| 2174 |
;;; determines if string or pathname object is logical |
| 2175 |
#+:logical-pathnames-mk |
| 2176 |
(defun logical-pathname-p (thing) |
| 2177 |
(eq (lp:pathname-host-type thing) :logical)) |
| 2178 |
|
| 2179 |
;;; From Kevin Layer for 4.1final. |
| 2180 |
#+(and (and allegro-version>= (version>= 4 1)) |
| 2181 |
(not :logical-pathnames-mk)) |
| 2182 |
(defun logical-pathname-p (thing) |
| 2183 |
(typep (parse-namestring thing) 'logical-pathname)) |
| 2184 |
|
| 2185 |
(defun pathname-logical-p (thing) |
| 2186 |
(typecase thing |
| 2187 |
(logical-pathname t) |
| 2188 |
#+clisp ; CLisp has non conformant Logical Pathnames. |
| 2189 |
(pathname (pathname-logical-p (namestring thing))) |
| 2190 |
(string (and (= 1 (count #\: thing)) ; Shortcut. |
| 2191 |
(ignore-errors (translate-logical-pathname thing)) |
| 2192 |
t)) |
| 2193 |
(t nil))) |
| 2194 |
|
| 2195 |
;;; This affects only one thing. |
| 2196 |
;;; 19990707 Marco Antoniotti |
| 2197 |
;;; old version |
| 2198 |
|
| 2199 |
(defun namestring-probably-logical (namestring) |
| 2200 |
(and (stringp namestring) |
| 2201 |
;; unix pathnames don't have embedded semicolons |
| 2202 |
(find #\; namestring))) |
| 2203 |
#|| |
| 2204 |
;;; New version |
| 2205 |
(defun namestring-probably-logical (namestring) |
| 2206 |
(and (stringp namestring) |
| 2207 |
(typep (parse-namestring namestring) 'logical-pathname))) |
| 2208 |
|
| 2209 |
|
| 2210 |
;;; New new version |
| 2211 |
;;; 20000321 Marco Antoniotti |
| 2212 |
(defun namestring-probably-logical (namestring) |
| 2213 |
(pathname-logical-p namestring)) |
| 2214 |
||# |
| 2215 |
|
| 2216 |
|
| 2217 |
#|| This is incorrect, as it strives to keep strings around, when it |
| 2218 |
shouldn't. MERGE-PATHNAMES already DTRT. |
| 2219 |
(defun append-logical-pnames (absolute relative) |
| 2220 |
(declare (type (or null string pathname) absolute relative)) |
| 2221 |
(let ((abs (if absolute |
| 2222 |
#-clisp (namestring absolute) |
| 2223 |
#+clisp absolute ;; Stig (July 2001): hack to avoid CLISP from translating the whole string |
| 2224 |
"")) |
| 2225 |
(rel (if relative (namestring relative) "")) |
| 2226 |
) |
| 2227 |
;; Make sure the absolute directory ends with a semicolon unless |
| 2228 |
;; the pieces are null strings |
| 2229 |
(unless (or (null-string abs) (null-string rel) |
| 2230 |
(char= (char abs (1- (length abs))) |
| 2231 |
#\;)) |
| 2232 |
(setq abs (concatenate 'string abs ";"))) |
| 2233 |
;; Return the concatenate pathnames |
| 2234 |
(concatenate 'string abs rel))) |
| 2235 |
||# |
| 2236 |
|
| 2237 |
|
| 2238 |
(defun append-logical-pnames (absolute relative) |
| 2239 |
(declare (type (or null string pathname) absolute relative)) |
| 2240 |
(let ((abs (if absolute |
| 2241 |
(pathname absolute) |
| 2242 |
(make-pathname :directory (list :absolute) |
| 2243 |
:name nil |
| 2244 |
:type nil) |
| 2245 |
)) |
| 2246 |
(rel (if relative |
| 2247 |
(pathname relative) |
| 2248 |
(make-pathname :directory (list :relative) |
| 2249 |
:name nil |
| 2250 |
:type nil) |
| 2251 |
)) |
| 2252 |
) |
| 2253 |
;; The following is messed up because CMUCL and LW use different |
| 2254 |
;; defaults for host (in particular LW uses NIL). Thus |
| 2255 |
;; MERGE-PATHNAMES has legitimate different behaviors on both |
| 2256 |
;; implementations. Of course this is disgusting, but that is the |
| 2257 |
;; way it is and the rest tries to circumvent this crap. |
| 2258 |
(etypecase abs |
| 2259 |
(logical-pathname |
| 2260 |
(etypecase rel |
| 2261 |
(logical-pathname |
| 2262 |
(namestring (merge-pathnames rel abs))) |
| 2263 |
(pathname |
| 2264 |
;; The following potentially translates the logical pathname |
| 2265 |
;; very early, but we cannot avoid it. |
| 2266 |
(namestring (merge-pathnames rel (translate-logical-pathname abs)))) |
| 2267 |
)) |
| 2268 |
(pathname |
| 2269 |
(namestring (merge-pathnames rel abs))) |
| 2270 |
))) |
| 2271 |
|
| 2272 |
#|| |
| 2273 |
;;; This was a try at appending a subdirectory onto a directory. |
| 2274 |
;;; It failed. We're keeping this around to prevent future mistakes |
| 2275 |
;;; of a similar sort. |
| 2276 |
(defun merge-directories (absolute-directory relative-directory) |
| 2277 |
;; replace concatenate with something more intelligent |
| 2278 |
;; i.e., concatenation won't work with some directories. |
| 2279 |
;; it should also behave well if the parent directory |
| 2280 |
;; has a filename at the end, or if the relative-directory ain't relative |
| 2281 |
(when absolute-directory |
| 2282 |
(setq absolute-directory (pathname-directory absolute-directory))) |
| 2283 |
(concatenate 'string |
| 2284 |
(or absolute-directory "") |
| 2285 |
(or relative-directory ""))) |
| 2286 |
||# |
| 2287 |
|
| 2288 |
#|| |
| 2289 |
<cl> (defun d (d n) (namestring (make-pathname :directory d :name n))) |
| 2290 |
|
| 2291 |
D |
| 2292 |
<cl> (d "~/foo/" "baz/bar.lisp") |
| 2293 |
"/usr0/mkant/foo/baz/bar.lisp" |
| 2294 |
|
| 2295 |
<cl> (d "~/foo" "baz/bar.lisp") |
| 2296 |
"/usr0/mkant/foo/baz/bar.lisp" |
| 2297 |
|
| 2298 |
<cl> (d "/foo/bar/" "baz/barf.lisp") |
| 2299 |
"/foo/bar/baz/barf.lisp" |
| 2300 |
|
| 2301 |
<cl> (d "foo/bar/" "baz/barf.lisp") |
| 2302 |
"foo/bar/baz/barf.lisp" |
| 2303 |
|
| 2304 |
<cl> (d "foo/bar" "baz/barf.lisp") |
| 2305 |
"foo/bar/baz/barf.lisp" |
| 2306 |
|
| 2307 |
<cl> (d "foo/bar" "/baz/barf.lisp") |
| 2308 |
"foo/bar//baz/barf.lisp" |
| 2309 |
|
| 2310 |
<cl> (d "foo/bar" nil) |
| 2311 |
"foo/bar/" |
| 2312 |
|
| 2313 |
<cl> (d nil "baz/barf.lisp") |
| 2314 |
"baz/barf.lisp" |
| 2315 |
|
| 2316 |
<cl> (d nil nil) |
| 2317 |
"" |
| 2318 |
|
| 2319 |
||# |
| 2320 |
|
| 2321 |
;;; The following is a change proposed by DTC for SCL. |
| 2322 |
;;; Maybe it could be used all the time. |
| 2323 |
|
| 2324 |
#-scl |
| 2325 |
(defun new-file-type (pathname type) |
| 2326 |
;; why not (make-pathname :type type :defaults pathname)? |
| 2327 |
(make-pathname |
| 2328 |
:host (pathname-host pathname) |
| 2329 |
:device (pathname-device pathname) |
| 2330 |
:directory (pathname-directory pathname) |
| 2331 |
:name (pathname-name pathname) |
| 2332 |
:type type |
| 2333 |
:version (pathname-version pathname))) |
| 2334 |
|
| 2335 |
|
| 2336 |
#+scl |
| 2337 |
(defun new-file-type (pathname type) |
| 2338 |
;; why not (make-pathname :type type :defaults pathname)? |
| 2339 |
(make-pathname |
| 2340 |
:host (pathname-host pathname :case :common) |
| 2341 |
:device (pathname-device pathname :case :common) |
| 2342 |
:directory (pathname-directory pathname :case :common) |
| 2343 |
:name (pathname-name pathname :case :common) |
| 2344 |
:type (string-upcase type) |
| 2345 |
:version (pathname-version pathname :case :common))) |
| 2346 |
|
| 2347 |
|
| 2348 |
|
| 2349 |
;;; ******************************** |
| 2350 |
;;; Component Defstruct ************ |
| 2351 |
;;; ******************************** |
| 2352 |
|
| 2353 |
(defvar *source-pathname-default* nil |
| 2354 |
"Default value of :source-pathname keyword in DEFSYSTEM. Set this to |
| 2355 |
\"\" to avoid having to type :source-pathname \"\" all the time.") |
| 2356 |
|
| 2357 |
(defvar *binary-pathname-default* nil |
| 2358 |
"Default value of :binary-pathname keyword in DEFSYSTEM.") |
| 2359 |
|
| 2360 |
|
| 2361 |
(defstruct (topological-sort-node (:conc-name topsort-)) |
| 2362 |
(color :white :type (member :gray :black :white)) |
| 2363 |
) |
| 2364 |
|
| 2365 |
|
| 2366 |
(defparameter *component-evaluated-slots* |
| 2367 |
'(:source-root-dir :source-pathname :source-extension |
| 2368 |
:binary-root-dir :binary-pathname :binary-extension)) |
| 2369 |
|
| 2370 |
|
| 2371 |
(defparameter *component-form-slots* |
| 2372 |
'(:initially-do :finally-do :compile-form :load-form)) |
| 2373 |
|
| 2374 |
|
| 2375 |
(defstruct (component (:include topological-sort-node) |
| 2376 |
(:print-function print-component)) |
| 2377 |
(type :file ; to pacify the CMUCL compiler (:type is alway supplied) |
| 2378 |
:type (member :defsystem |
| 2379 |
:system |
| 2380 |
:subsystem |
| 2381 |
:module |
| 2382 |
:file |
| 2383 |
:private-file |
| 2384 |
)) |
| 2385 |
(name nil :type (or symbol string)) |
| 2386 |
(indent 0 :type (mod 1024)) ; Number of characters of indent in |
| 2387 |
; verbose output to the user. |
| 2388 |
host ; The pathname host (i.e., "/../a"). |
| 2389 |
device ; The pathname device. |
| 2390 |
source-root-dir ; Relative or absolute (starts |
| 2391 |
; with "/"), directory or file |
| 2392 |
; (ends with "/"). |
| 2393 |
(source-pathname *source-pathname-default*) |
| 2394 |
source-extension ; A string, e.g., "lisp" |
| 2395 |
; if NIL, inherit |
| 2396 |
(binary-pathname *binary-pathname-default*) |
| 2397 |
binary-root-dir |
| 2398 |
binary-extension ; A string, e.g., "fasl". If |
| 2399 |
; NIL, uses default for |
| 2400 |
; machine-type. |
| 2401 |
package ; Package for use-package. |
| 2402 |
|
| 2403 |
;; The following three slots are used to provide for alternate compilation |
| 2404 |
;; and loading functions for the files contained within a component. If |
| 2405 |
;; a component has a compiler or a loader specified, those functions are |
| 2406 |
;; used. Otherwise the functions are derived from the language. If no |
| 2407 |
;; language is specified, it defaults to Common Lisp (:lisp). Other current |
| 2408 |
;; possible languages include :scheme (PseudoScheme) and :c, but the user |
| 2409 |
;; can define additional language mappings. Compilation functions should |
| 2410 |
;; accept a pathname argument and a :output-file keyword; loading functions |
| 2411 |
;; just a pathname argument. The default functions are #'compile-file and |
| 2412 |
;; #'load. Unlike fdmm's SET-LANGUAGE macro, this allows a defsystem to |
| 2413 |
;; mix languages. |
| 2414 |
(language nil :type (or null symbol)) |
| 2415 |
(compiler nil :type (or null symbol function)) |
| 2416 |
(loader nil :type (or null symbol function)) |
| 2417 |
(compiler-options nil :type list) ; A list of compiler options to |
| 2418 |
; use for compiling this |
| 2419 |
; component. These must be |
| 2420 |
; keyword options supported by |
| 2421 |
; the compiler. |
| 2422 |
|
| 2423 |
(components () :type list) ; A list of components |
| 2424 |
; comprising this component's |
| 2425 |
; definition. |
| 2426 |
(depends-on () :type list) ; A list of the components |
| 2427 |
; this one depends on. may |
| 2428 |
; refer only to the components |
| 2429 |
; at the same level as this |
| 2430 |
; one. |
| 2431 |
proclamations ; Compiler options, such as |
| 2432 |
; '(optimize (safety 3)). |
| 2433 |
(initially-do (lambda () nil)) ; Form to evaluate before the |
| 2434 |
; operation. |
| 2435 |
(finally-do (lambda () nil)) ; Form to evaluate after the operation. |
| 2436 |
(compile-form (lambda () nil)) ; For foreign libraries. |
| 2437 |
(load-form (lambda () nil)) ; For foreign libraries. |
| 2438 |
|
| 2439 |
;; load-time ; The file-write-date of the |
| 2440 |
; binary/source file loaded. |
| 2441 |
|
| 2442 |
;; If load-only is T, will not compile the file on operation :compile. |
| 2443 |
;; In other words, for files which are :load-only T, loading the file |
| 2444 |
;; satisfies any demand to recompile. |
| 2445 |
load-only ; If T, will not compile this |
| 2446 |
; file on operation :compile. |
| 2447 |
;; If compile-only is T, will not load the file on operation :compile. |
| 2448 |
;; Either compiles or loads the file, but not both. In other words, |
| 2449 |
;; compiling the file satisfies the demand to load it. This is useful |
| 2450 |
;; for PCL defmethod and defclass definitions, which wrap a |
| 2451 |
;; (eval-when (compile load eval) ...) around the body of the definition. |
| 2452 |
;; This saves time in some lisps. |
| 2453 |
compile-only ; If T, will not load this |
| 2454 |
; file on operation :compile. |
| 2455 |
#|| ISI Extension ||# |
| 2456 |
load-always ; If T, will force loading |
| 2457 |
; even if file has not |
| 2458 |
; changed. |
| 2459 |
;; PVE: add banner |
| 2460 |
(banner nil :type (or null string)) |
| 2461 |
|
| 2462 |
(documentation nil :type (or null string)) ; Optional documentation slot |
| 2463 |
(long-documentation nil :type (or null string)) ; Optional long documentation slot |
| 2464 |
|
| 2465 |
;; Added AUTHOR, MAINTAINER, VERSION and LICENCE slots. |
| 2466 |
(author nil :type (or null string)) |
| 2467 |
(licence nil :type (or null string)) |
| 2468 |
(maintainer nil :type (or null string)) |
| 2469 |
(version nil :type (or null string)) |
| 2470 |
|
| 2471 |
;; Added NON-REQUIRED-P slot. Useful for optional items. |
| 2472 |
(non-required-p nil :type boolean) ; If T a missing file or |
| 2473 |
; sub-directory will not cause |
| 2474 |
; an error. |
| 2475 |
) |
| 2476 |
|
| 2477 |
|
| 2478 |
;;; To allow dependencies from "foreign systems" like ASDF or one of |
| 2479 |
;;; the proprietary ones like ACL or LW. |
| 2480 |
|
| 2481 |
(defstruct (foreign-system (:include component (type :system))) |
| 2482 |
kind ; This is a keyword: (member :asdf :pcl :lispworks-common-defsystem ...) |
| 2483 |
object ; The actual foreign system object. |
| 2484 |
) |
| 2485 |
|
| 2486 |
|
| 2487 |
(defun register-foreign-system (name &key representation kind) |
| 2488 |
(declare (type (or symbol string) name)) |
| 2489 |
(let ((fs (make-foreign-system :name name |
| 2490 |
:kind kind |
| 2491 |
:object representation))) |
| 2492 |
(setf (get-system name) fs))) |
| 2493 |
|
| 2494 |
|
| 2495 |
|
| 2496 |
(define-condition missing-component (simple-condition) |
| 2497 |
((name :reader missing-component-name |
| 2498 |
:initarg :name) |
| 2499 |
(component :reader missing-component-component |
| 2500 |
:initarg :component) |
| 2501 |
) |
| 2502 |
#-gcl (:default-initargs :component nil) |
| 2503 |
(:report (lambda (mmc stream) |
| 2504 |
(format stream "MK:DEFSYSTEM: missing component ~S for ~S." |
| 2505 |
(missing-component-name mmc) |
| 2506 |
(missing-component-component mmc)))) |
| 2507 |
) |
| 2508 |
|
| 2509 |
(define-condition missing-module (missing-component) |
| 2510 |
() |
| 2511 |
(:report (lambda (mmc stream) |
| 2512 |
(format stream "MK:DEFSYSTEM: missing module ~S for ~S." |
| 2513 |
(missing-component-name mmc) |
| 2514 |
(missing-component-component mmc)))) |
| 2515 |
) |
| 2516 |
|
| 2517 |
(define-condition missing-system (missing-module) |
| 2518 |
() |
| 2519 |
(:report (lambda (msc stream) |
| 2520 |
(format stream "MK:DEFSYSTEM: missing system ~S~@[ for S~]." |
| 2521 |
(missing-component-name msc) |
| 2522 |
(missing-component-component msc)))) |
| 2523 |
) |
| 2524 |
|
| 2525 |
|
| 2526 |
|
| 2527 |
(defvar *file-load-time-table* (make-hash-table :test #'equal) |
| 2528 |
"Hash table of file-write-dates for the system definitions and files in the system definitions.") |
| 2529 |
|
| 2530 |
|
| 2531 |
(defun component-load-time (component) |
| 2532 |
(when component |
| 2533 |
(etypecase component |
| 2534 |
(string (gethash component *file-load-time-table*)) |
| 2535 |
(pathname (gethash (namestring component) *file-load-time-table*)) |
| 2536 |
(component |
| 2537 |
(ecase (component-type component) |
| 2538 |
(:defsystem |
| 2539 |
(let* ((name (component-name component)) |
| 2540 |
(path (when name (compute-system-path name nil)))) |
| 2541 |
(declare (type (or string pathname null) path)) |
| 2542 |
(when path |
| 2543 |
(gethash (namestring path) *file-load-time-table*)))) |
| 2544 |
((:file :private-file) |
| 2545 |
;; Use only :source pathname to identify component's |
| 2546 |
;; load time. |
| 2547 |
(let ((path (component-full-pathname component :source))) |
| 2548 |
(when path |
| 2549 |
(gethash path *file-load-time-table*))))))))) |
| 2550 |
|
| 2551 |
#-(or :cmu) |
| 2552 |
(defsetf component-load-time (component) (value) |
| 2553 |
`(when ,component |
| 2554 |
(etypecase ,component |
| 2555 |
(string (setf (gethash ,component *file-load-time-table*) ,value)) |
| 2556 |
(pathname (setf (gethash (namestring (the pathname ,component)) |
| 2557 |
*file-load-time-table*) |
| 2558 |
,value)) |
| 2559 |
(component |
| 2560 |
(ecase (component-type ,component) |
| 2561 |
(:defsystem |
| 2562 |
(let* ((name (component-name ,component)) |
| 2563 |
(path (when name (compute-system-path name nil)))) |
| 2564 |
(declare (type (or string pathname null) path)) |
| 2565 |
(when path |
| 2566 |
(setf (gethash (namestring path) *file-load-time-table*) |
| 2567 |
,value)))) |
| 2568 |
((:file :private-file) |
| 2569 |
;; Use only :source pathname to identify file. |
| 2570 |
(let ((path (component-full-pathname ,component :source))) |
| 2571 |
(when path |
| 2572 |
(setf (gethash path *file-load-time-table*) |
| 2573 |
,value))))))) |
| 2574 |
,value)) |
| 2575 |
|
| 2576 |
#+(or :cmu) |
| 2577 |
(defun (setf component-load-time) (value component) |
| 2578 |
(declare |
| 2579 |
(type (or null string pathname component) component) |
| 2580 |
(type (or unsigned-byte null) value)) |
| 2581 |
(when component |
| 2582 |
(etypecase component |
| 2583 |
(string (setf (gethash component *file-load-time-table*) value)) |
| 2584 |
(pathname (setf (gethash (namestring (the pathname component)) |
| 2585 |
*file-load-time-table*) |
| 2586 |
value)) |
| 2587 |
(component |
| 2588 |
(ecase (component-type component) |
| 2589 |
(:defsystem |
| 2590 |
(let* ((name (component-name component)) |
| 2591 |
(path (when name (compute-system-path name nil)))) |
| 2592 |
(declare (type (or string pathname null) path)) |
| 2593 |
(when path |
| 2594 |
(setf (gethash (namestring path) *file-load-time-table*) |
| 2595 |
value)))) |
| 2596 |
((:file :private-file) |
| 2597 |
;; Use only :source pathname to identify file. |
| 2598 |
(let ((path (component-full-pathname component :source))) |
| 2599 |
(when path |
| 2600 |
(setf (gethash path *file-load-time-table*) |
| 2601 |
value))))))) |
| 2602 |
value)) |
| 2603 |
|
| 2604 |
|
| 2605 |
;;; compute-system-path -- |
| 2606 |
|
| 2607 |
(defun compute-system-path (module-name definition-pname) |
| 2608 |
(let* ((module-string-name |
| 2609 |
(etypecase module-name |
| 2610 |
(symbol (string-downcase |
| 2611 |
(string module-name))) |
| 2612 |
(string module-name))) |
| 2613 |
|
| 2614 |
(file-pathname |
| 2615 |
(make-pathname :name module-string-name |
| 2616 |
:type *system-extension*)) |
| 2617 |
|
| 2618 |
(lib-file-pathname |
| 2619 |
(make-pathname :directory (list :relative module-string-name) |
| 2620 |
:name module-string-name |
| 2621 |
:type *system-extension*)) |
| 2622 |
) |
| 2623 |
(or (when definition-pname ; given pathname for system def |
| 2624 |
(probe-file definition-pname)) |
| 2625 |
;; Then the central registry. Note that we also check the current |
| 2626 |
;; directory in the registry, but the above check is hard-coded. |
| 2627 |
(cond (*central-registry* |
| 2628 |
(if (listp *central-registry*) |
| 2629 |
(dolist (registry *central-registry*) |
| 2630 |
(let* ((reg-path (registry-pathname registry)) |
| 2631 |
(file (or (probe-file |
| 2632 |
(append-directories |
| 2633 |
reg-path file-pathname)) |
| 2634 |
(probe-file |
| 2635 |
(append-directories |
| 2636 |
reg-path lib-file-pathname))))) |
| 2637 |
(when file (return file)))) |
| 2638 |
(or (probe-file (append-directories *central-registry* |
| 2639 |
file-pathname)) |
| 2640 |
(probe-file (append-directories *central-registry* |
| 2641 |
lib-file-pathname)) |
| 2642 |
)) |
| 2643 |
) |
| 2644 |
(t |
| 2645 |
;; No central registry. Assume current working directory. |
| 2646 |
;; Maybe this should be an error? |
| 2647 |
(or (probe-file file-pathname) |
| 2648 |
(probe-file lib-file-pathname))))) |
| 2649 |
)) |
| 2650 |
|
| 2651 |
|
| 2652 |
(defun system-definition-pathname (system-name) |
| 2653 |
(let ((system (ignore-errors (find-system system-name :error)))) |
| 2654 |
(if system |
| 2655 |
(let ((system-def-pathname |
| 2656 |
(make-pathname |
| 2657 |
:type "system" |
| 2658 |
:defaults (pathname (component-full-pathname system :source)))) |
| 2659 |
) |
| 2660 |
(values system-def-pathname |
| 2661 |
(probe-file system-def-pathname))) |
| 2662 |
(values nil nil)))) |
| 2663 |
|
| 2664 |
|
| 2665 |
|
| 2666 |
|
| 2667 |
#| |
| 2668 |
|
| 2669 |
(defun compute-system-path (module-name definition-pname) |
| 2670 |
(let* ((filename (format nil "~A.~A" |
| 2671 |
(if (symbolp module-name) |
| 2672 |
(string-downcase (string module-name)) |
| 2673 |
module-name) |
| 2674 |
*system-extension*))) |
| 2675 |
(or (when definition-pname ; given pathname for system def |
| 2676 |
(probe-file definition-pname)) |
| 2677 |
;; Then the central registry. Note that we also check the current |
| 2678 |
;; directory in the registry, but the above check is hard-coded. |
| 2679 |
(cond (*central-registry* |
| 2680 |
(if (listp *central-registry*) |
| 2681 |
(dolist (registry *central-registry*) |
| 2682 |
(let ((file (probe-file |
| 2683 |
(append-directories |
| 2684 |
(registry-pathname registry) filename)))) |
| 2685 |
(when file (return file)))) |
| 2686 |
(probe-file (append-directories *central-registry* |
| 2687 |
filename)))) |
| 2688 |
(t |
| 2689 |
;; No central registry. Assume current working directory. |
| 2690 |
;; Maybe this should be an error? |
| 2691 |
(probe-file filename)))))) |
| 2692 |
|# |
| 2693 |
|
| 2694 |
|
| 2695 |
(defvar *reload-systems-from-disk* t |
| 2696 |
"If T, always tries to reload newer system definitions from disk. |
| 2697 |
Otherwise first tries to find the system definition in the current |
| 2698 |
environment.") |
| 2699 |
|
| 2700 |
(defun find-system (system-name &optional (mode :ask) definition-pname) |
| 2701 |
"Returns the system named SYSTEM-NAME. |
| 2702 |
If not already loaded, loads it, depending on the value of |
| 2703 |
*RELOAD-SYSTEMS-FROM-DISK* and of the value of MODE. MODE can be :ASK, |
| 2704 |
:ERROR, :LOAD-OR-NIL, or :LOAD. :ASK is the default. |
| 2705 |
This allows OPERATE-ON-SYSTEM to work on non-loaded as well as |
| 2706 |
loaded system definitions. DEFINITION-PNAME is the pathname for |
| 2707 |
the system definition, if provided." |
| 2708 |
(ecase mode |
| 2709 |
(:ask |
| 2710 |
(or (get-system system-name) |
| 2711 |
(when (y-or-n-p-wait |
| 2712 |
#\y 20 |
| 2713 |
"System ~A not loaded. Shall I try loading it? " |
| 2714 |
system-name) |
| 2715 |
(find-system system-name :load definition-pname)))) |
| 2716 |
(:error |
| 2717 |
(or (get-system system-name) |
| 2718 |
(error 'missing-system :name system-name))) |
| 2719 |
(:load-or-nil |
| 2720 |
(let ((system (get-system system-name))) |
| 2721 |
;; (break "System ~S ~S." system-name system) |
| 2722 |
(or (unless *reload-systems-from-disk* system) |
| 2723 |
;; If SYSTEM-NAME is a symbol, it will lowercase the |
| 2724 |
;; symbol's string. |
| 2725 |
;; If SYSTEM-NAME is a string, it doesn't change the case of the |
| 2726 |
;; string. So if case matters in the filename, use strings, not |
| 2727 |
;; symbols, wherever the system is named. |
| 2728 |
(when (foreign-system-p system) |
| 2729 |
(warn "Foreign system ~S cannot be reloaded by MK:DEFSYSTEM." |
| 2730 |
system) |
| 2731 |
(return-from find-system nil)) |
| 2732 |
(let ((path (compute-system-path system-name definition-pname))) |
| 2733 |
(when (and path |
| 2734 |
(or (null system) |
| 2735 |
(null (component-load-time path)) |
| 2736 |
(< (component-load-time path) |
| 2737 |
(file-write-date path)))) |
| 2738 |
(tell-user-generic |
| 2739 |
(format nil "Loading system ~A from file ~A" |
| 2740 |
system-name |
| 2741 |
path)) |
| 2742 |
(load path) |
| 2743 |
(setf system (get-system system-name)) |
| 2744 |
(when system |
| 2745 |
(setf (component-load-time path) |
| 2746 |
(file-write-date path)))) |
| 2747 |
system) |
| 2748 |
system))) |
| 2749 |
(:load |
| 2750 |
(or (unless *reload-systems-from-disk* (get-system system-name)) |
| 2751 |
(when (foreign-system-p (get-system system-name)) |
| 2752 |
(warn "Foreign system ~S cannot be reloaded by MK:DEFSYSTEM." |
| 2753 |
(get-system system-name)) |
| 2754 |
(return-from find-system nil)) |
| 2755 |
(or (find-system system-name :load-or-nil definition-pname) |
| 2756 |
(error "Can't find system named ~s." system-name)))))) |
| 2757 |
|
| 2758 |
|
| 2759 |
(defun print-component (component stream depth) |
| 2760 |
(declare (ignore depth)) |
| 2761 |
(format stream "#<~:@(~A~): ~A>" |
| 2762 |
(component-type component) |
| 2763 |
(component-name component))) |
| 2764 |
|
| 2765 |
|
| 2766 |
(defun describe-system (name &optional (stream *standard-output*)) |
| 2767 |
"Prints a description of the system to the stream. If NAME is the |
| 2768 |
name of a system, gets it and prints a description of the system. |
| 2769 |
If NAME is a component, prints a description of the component." |
| 2770 |
(let ((system (if (typep name 'component) name (find-system name :load)))) |
| 2771 |
(format stream "~&~A ~A: ~ |
| 2772 |
~@[~& Host: ~A~]~ |
| 2773 |
~@[~& Device: ~A~]~ |
| 2774 |
~@[~& Package: ~A~]~ |
| 2775 |
~& Source: ~@[~A~] ~@[~A~] ~@[~A~]~ |
| 2776 |
~& Binary: ~@[~A~] ~@[~A~] ~@[~A~]~ |
| 2777 |
~@[~& Depends On: ~A ~]~& Components:~{~15T~A~&~}" |
| 2778 |
(component-type system) |
| 2779 |
(component-name system) |
| 2780 |
(component-host system) |
| 2781 |
(component-device system) |
| 2782 |
(component-package system) |
| 2783 |
(component-root-dir system :source) |
| 2784 |
(component-pathname system :source) |
| 2785 |
(component-extension system :source) |
| 2786 |
(component-root-dir system :binary) |
| 2787 |
(component-pathname system :binary) |
| 2788 |
(component-extension system :binary) |
| 2789 |
(component-depends-on system) |
| 2790 |
(component-components system)) |
| 2791 |
#||(when recursive |
| 2792 |
(dolist (component (component-components system)) |
| 2793 |
(describe-system component stream recursive)))||# |
| 2794 |
system)) |
| 2795 |
|
| 2796 |
|
| 2797 |
(defun canonicalize-component-name (component) |
| 2798 |
;; Within the component, the name is a string. |
| 2799 |
(if (typep (component-name component) 'string) |
| 2800 |
;; Unnecessary to change it, so just return it, same case |
| 2801 |
(component-name component) |
| 2802 |
;; Otherwise, make it a downcase string -- important since file |
| 2803 |
;; names are often constructed from component names, and unix |
| 2804 |
;; prefers lowercase as a default. |
| 2805 |
(setf (component-name component) |
| 2806 |
(string-downcase (string (component-name component)))))) |
| 2807 |
|
| 2808 |
|
| 2809 |
(defun component-pathname (component type) |
| 2810 |
(when component |
| 2811 |
(ecase type |
| 2812 |
(:source (component-source-pathname component)) |
| 2813 |
(:binary (component-binary-pathname component)) |
| 2814 |
(:error (component-error-pathname component))))) |
| 2815 |
|
| 2816 |
|
| 2817 |
(defun component-error-pathname (component) |
| 2818 |
(let ((binary (component-pathname component :binary))) |
| 2819 |
(new-file-type binary *compile-error-file-type*))) |
| 2820 |
|
| 2821 |
(defsetf component-pathname (component type) (value) |
| 2822 |
`(when ,component |
| 2823 |
(ecase ,type |
| 2824 |
(:source (setf (component-source-pathname ,component) ,value)) |
| 2825 |
(:binary (setf (component-binary-pathname ,component) ,value))))) |
| 2826 |
|
| 2827 |
|
| 2828 |
(defun component-root-dir (component type) |
| 2829 |
(when component |
| 2830 |
(ecase type |
| 2831 |
(:source (component-source-root-dir component)) |
| 2832 |
((:binary :error) (component-binary-root-dir component)) |
| 2833 |
))) |
| 2834 |
|
| 2835 |
(defsetf component-root-dir (component type) (value) |
| 2836 |
`(when ,component |
| 2837 |
(ecase ,type |
| 2838 |
(:source (setf (component-source-root-dir ,component) ,value)) |
| 2839 |
(:binary (setf (component-binary-root-dir ,component) ,value))))) |
| 2840 |
|
| 2841 |
|
| 2842 |
(defvar *source-pathnames-table* (make-hash-table :test #'equal) |
| 2843 |
"Table which maps from components to full source pathnames.") |
| 2844 |
|
| 2845 |
|
| 2846 |
(defvar *binary-pathnames-table* (make-hash-table :test #'equal) |
| 2847 |
"Table which maps from components to full binary pathnames.") |
| 2848 |
|
| 2849 |
|
| 2850 |
(defparameter *reset-full-pathname-table* t |
| 2851 |
"If T, clears the full-pathname tables before each call to OPERATE-ON-SYSTEM. |
| 2852 |
Setting this to NIL may yield faster performance after multiple calls |
| 2853 |
to LOAD-SYSTEM and COMPILE-SYSTEM, but could result in changes to |
| 2854 |
system and language definitions to not take effect, and so should be |
| 2855 |
used with caution.") |
| 2856 |
|
| 2857 |
|
| 2858 |
(defun clear-full-pathname-tables () |
| 2859 |
(clrhash *source-pathnames-table*) |
| 2860 |
(clrhash *binary-pathnames-table*)) |
| 2861 |
|
| 2862 |
|
| 2863 |
(defun component-full-pathname (component type &optional (version *version*)) |
| 2864 |
(when component |
| 2865 |
(case type |
| 2866 |
(:source |
| 2867 |
(let ((old (gethash component *source-pathnames-table*))) |
| 2868 |
(or old |
| 2869 |
(let ((new (component-full-pathname-i component type version))) |
| 2870 |
(setf (gethash component *source-pathnames-table*) new) |
| 2871 |
new)))) |
| 2872 |
(:binary |
| 2873 |
(let ((old (gethash component *binary-pathnames-table*))) |
| 2874 |
(or old |
| 2875 |
(let ((new (component-full-pathname-i component type version))) |
| 2876 |
(setf (gethash component *binary-pathnames-table*) new) |
| 2877 |
new)))) |
| 2878 |
(otherwise |
| 2879 |
(component-full-pathname-i component type version))))) |
| 2880 |
|
| 2881 |
|
| 2882 |
(defun component-full-pathname-i (component type |
| 2883 |
&optional (version *version*) |
| 2884 |
&aux version-dir version-replace) |
| 2885 |
;; If the pathname-type is :binary and the root pathname is null, |
| 2886 |
;; distribute the binaries among the sources (= use :source pathname). |
| 2887 |
;; This assumes that the component's :source pathname has been set |
| 2888 |
;; before the :binary one. |
| 2889 |
(if version |
| 2890 |
(multiple-value-setq (version-dir version-replace) |
| 2891 |
(translate-version version)) |
| 2892 |
(setq version-dir *version-dir* version-replace *version-replace*)) |
| 2893 |
;; (format *trace-output* "~&>>>> VERSION COMPUTED ~S ~S~%" version-dir version-replace) |
| 2894 |
(let ((pathname |
| 2895 |
(append-directories |
| 2896 |
(if version-replace |
| 2897 |
version-dir |
| 2898 |
(append-directories (component-root-dir component type) |
| 2899 |
version-dir)) |
| 2900 |
(component-pathname component type)))) |
| 2901 |
|
| 2902 |
;; When a logical pathname is used, it must first be translated to |
| 2903 |
;; a physical pathname. This isn't strictly correct. What should happen |
| 2904 |
;; is we fill in the appropriate slots of the logical pathname, and |
| 2905 |
;; then return the logical pathname for use by compile-file & friends. |
| 2906 |
;; But calling translate-logical-pathname to return the actual pathname |
| 2907 |
;; should do for now. |
| 2908 |
|
| 2909 |
;; (format t "pathname = ~A~%" pathname) |
| 2910 |
;; (format t "type = ~S~%" (component-extension component type)) |
| 2911 |
|
| 2912 |
;; 20000303 Marco Antoniotti |
| 2913 |
;; Changed the following according to suggestion by Ray Toy. I |
| 2914 |
;; just collapsed the tests for "logical-pathname-ness" into a |
| 2915 |
;; single test (heavy, but probably very portable) and added the |
| 2916 |
;; :name argument to the MAKE-PATHNAME in the MERGE-PATHNAMES |
| 2917 |
;; beacuse of possible null names (e.g. :defsystem components) |
| 2918 |
;; causing problems with the subsequenct call to NAMESTRING. |
| 2919 |
;; (format *trace-output* "~&>>>> PATHNAME is ~S~%" pathname) |
| 2920 |
|
| 2921 |
;; 20050309 Marco Antoniotti |
| 2922 |
;; The treatment of PATHNAME-HOST and PATHNAME-DEVICE in the call |
| 2923 |
;; to MAKE-PATHNAME in the T branch is bogus. COMPONENT-DEVICE |
| 2924 |
;; and COMPONENT-HOST must respect the ANSI definition, hence, |
| 2925 |
;; they cannot be PATHNAMEs. The simplification of the code is |
| 2926 |
;; useful. SCL compatibility may be broken, but I doubt it will. |
| 2927 |
|
| 2928 |
;; 20050310 Marco Antoniotti |
| 2929 |
;; After a suggestion by David Tolpin, the code is simplified even |
| 2930 |
;; more, and the logic should be now more clear: use the user |
| 2931 |
;; supplied pieces of the pathname if non nil. |
| 2932 |
|
| 2933 |
;; 20050613 Marco Antoniotti |
| 2934 |
;; Added COMPONENT-NAME extraction to :NAME part, in case the |
| 2935 |
;; PATHNAME-NAME is NIL. |
| 2936 |
|
| 2937 |
(cond ((pathname-logical-p pathname) ; See definition of test above. |
| 2938 |
(setf pathname |
| 2939 |
(merge-pathnames pathname |
| 2940 |
(make-pathname |
| 2941 |
:name (component-name component) |
| 2942 |
:type (component-extension component |
| 2943 |
type)))) |
| 2944 |
(namestring (translate-logical-pathname pathname))) |
| 2945 |
(t |
| 2946 |
(namestring |
| 2947 |
(make-pathname :host (or (component-host component) |
| 2948 |
(pathname-host pathname)) |
| 2949 |
|
| 2950 |
:directory (pathname-directory pathname |
| 2951 |
#+scl :case |
| 2952 |
#+scl :common |
| 2953 |
) |
| 2954 |
|
| 2955 |
:name (or (pathname-name pathname |
| 2956 |
#+scl :case |
| 2957 |
#+scl :common |
| 2958 |
) |
| 2959 |
(component-name component)) |
| 2960 |
|
| 2961 |
:type |
| 2962 |
#-scl (component-extension component type) |
| 2963 |
#+scl (string-upcase |
| 2964 |
(component-extension component type)) |
| 2965 |
|
| 2966 |
:device |
| 2967 |
#+sbcl |
| 2968 |
:unspecific |
| 2969 |
#-(or :sbcl) |
| 2970 |
(or (component-device component) |
| 2971 |
(pathname-device pathname |
| 2972 |
#+scl :case |
| 2973 |
#+scl :common |
| 2974 |
)) |
| 2975 |
;; :version :newest |
| 2976 |
)))))) |
| 2977 |
|
| 2978 |
|
| 2979 |
#-lispworks |
| 2980 |
(defun translate-version (version) |
| 2981 |
;; Value returns the version directory and whether it replaces |
| 2982 |
;; the entire root (t) or is a subdirectory. |
| 2983 |
;; Version may be nil to signify no subdirectory, |
| 2984 |
;; a symbol, such as alpha, beta, omega, :alpha, mark, which |
| 2985 |
;; specifies a subdirectory of the root, or |
| 2986 |
;; a string, which replaces the root. |
| 2987 |
(cond ((null version) |
| 2988 |
(values "" nil)) |
| 2989 |
((symbolp version) |
| 2990 |
(values (let ((sversion (string version))) |
| 2991 |
(if (find-if #'lower-case-p sversion) |
| 2992 |
sversion |
| 2993 |
(string-downcase sversion))) |
| 2994 |
nil)) |
| 2995 |
((stringp version) |
| 2996 |
(values version t)) |
| 2997 |
(t (error "~&; Illegal version ~S" version)))) |
| 2998 |
|
| 2999 |
|
| 3000 |
;;; Looks like LW has a bug in MERGE-PATHNAMES. |
| 3001 |
;;; |
| 3002 |
;;; (merge-pathnames "" "LP:foo;bar;") ==> "LP:" |
| 3003 |
;;; |
| 3004 |
;;; Which is incorrect. |
| 3005 |
;;; The change here ensures that the result of TRANSLATE-VERSION is |
| 3006 |
;;; appropriate. |
| 3007 |
|
| 3008 |
#+lispworks |
| 3009 |
(defun translate-version (version) |
| 3010 |
;; Value returns the version directory and whether it replaces |
| 3011 |
;; the entire root (t) or is a subdirectory. |
| 3012 |
;; Version may be nil to signify no subdirectory, |
| 3013 |
;; a symbol, such as alpha, beta, omega, :alpha, mark, which |
| 3014 |
;; specifies a subdirectory of the root, or |
| 3015 |
;; a string, which replaces the root. |
| 3016 |
(cond ((null version) |
| 3017 |
(values (pathname "") nil)) |
| 3018 |
((symbolp version) |
| 3019 |
(values (let ((sversion (string version))) |
| 3020 |
(if (find-if #'lower-case-p sversion) |
| 3021 |
(pathname sversion) |
| 3022 |
(pathname (string-downcase sversion)))) |
| 3023 |
nil)) |
| 3024 |
((stringp version) |
| 3025 |
(values (pathname version) t)) |
| 3026 |
(t (error "~&; Illegal version ~S" version)))) |
| 3027 |
|
| 3028 |
|
| 3029 |
(defun component-extension (component type &key local) |
| 3030 |
(ecase type |
| 3031 |
(:source (or (component-source-extension component) |
| 3032 |
(unless local |
| 3033 |
(default-source-extension component)) ; system default |
| 3034 |
;; (and (component-language component)) |
| 3035 |
)) |
| 3036 |
(:binary (or (component-binary-extension component) |
| 3037 |
(unless local |
| 3038 |
(default-binary-extension component)) ; system default |
| 3039 |
;; (and (component-language component)) |
| 3040 |
)) |
| 3041 |
(:error *compile-error-file-type*))) |
| 3042 |
|
| 3043 |
|
| 3044 |
(defsetf component-extension (component type) (value) |
| 3045 |
`(ecase ,type |
| 3046 |
(:source (setf (component-source-extension ,component) ,value)) |
| 3047 |
(:binary (setf (component-binary-extension ,component) ,value)) |
| 3048 |
(:error (setf *compile-error-file-type* ,value)))) |
| 3049 |
|
| 3050 |
|
| 3051 |
;;; ******************************** |
| 3052 |
;;; System Definition ************** |
| 3053 |
;;; ******************************** |
| 3054 |
|
| 3055 |
(defun create-component (type name definition-body &optional parent (indent 0)) |
| 3056 |
(let ((component (apply #'make-component |
| 3057 |
:type type |
| 3058 |
:name name |
| 3059 |
:indent indent |
| 3060 |
definition-body))) |
| 3061 |
;; Set up :load-only attribute |
| 3062 |
(unless (find :load-only definition-body) |
| 3063 |
;; If the :load-only attribute wasn't specified, |
| 3064 |
;; inherit it from the parent. If no parent, default it to nil. |
| 3065 |
(setf (component-load-only component) |
| 3066 |
(when parent |
| 3067 |
(component-load-only parent)))) |
| 3068 |
;; Set up :compile-only attribute |
| 3069 |
(unless (find :compile-only definition-body) |
| 3070 |
;; If the :compile-only attribute wasn't specified, |
| 3071 |
;; inherit it from the parent. If no parent, default it to nil. |
| 3072 |
(setf (component-compile-only component) |
| 3073 |
(when parent |
| 3074 |
(component-compile-only parent)))) |
| 3075 |
|
| 3076 |
;; Set up :compiler-options attribute |
| 3077 |
(unless (find :compiler-options definition-body) |
| 3078 |
;; If the :compiler-option attribute wasn't specified, |
| 3079 |
;; inherit it from the parent. If no parent, default it to NIL. |
| 3080 |
(setf (component-compiler-options component) |
| 3081 |
(when parent |
| 3082 |
(component-compiler-options parent)))) |
| 3083 |
|
| 3084 |
#|| ISI Extension ||# |
| 3085 |
;; Set up :load-always attribute |
| 3086 |
(unless (find :load-always definition-body) |
| 3087 |
;; If the :load-always attribute wasn't specified, |
| 3088 |
;; inherit it from the parent. If no parent, default it to nil. |
| 3089 |
(setf (component-load-always component) |
| 3090 |
(when parent |
| 3091 |
(component-load-always parent)))) |
| 3092 |
|
| 3093 |
;; Initializations/after makes |
| 3094 |
(canonicalize-component-name component) |
| 3095 |
|
| 3096 |
;; Inherit package from parent if not specified. |
| 3097 |
(setf (component-package component) |
| 3098 |
(or (component-package component) |
| 3099 |
(when parent (component-package parent)))) |
| 3100 |
|
| 3101 |
;; Type specific setup: |
| 3102 |
(when (or (eq type :defsystem) (eq type :system) (eq type :subsystem)) |
| 3103 |
(setf (get-system name) component) |
| 3104 |
#|(unless (component-language component) |
| 3105 |
(setf (component-language component) :lisp))|#) |
| 3106 |
|
| 3107 |
;; Set up the component's pathname |
| 3108 |
(create-component-pathnames component parent) |
| 3109 |
|
| 3110 |
;; If there are any components of the component, expand them too. |
| 3111 |
(expand-component-components component (+ indent 2)) |
| 3112 |
|
| 3113 |
;; Make depends-on refer to structs instead of names. |
| 3114 |
(link-component-depends-on (component-components component)) |
| 3115 |
|
| 3116 |
;; Design Decision: Topologically sort the dependency graph at |
| 3117 |
;; time of definition instead of at time of use. Probably saves a |
| 3118 |
;; little bit of time for the user. |
| 3119 |
|
| 3120 |
;; Topological Sort the components at this level. |
| 3121 |
(setf (component-components component) |
| 3122 |
(topological-sort (component-components component))) |
| 3123 |
|
| 3124 |
;; Return the component. |
| 3125 |
component)) |
| 3126 |
|
| 3127 |
|
| 3128 |
;;; preprocess-component-definition -- |
| 3129 |
;;; New function introduced to manipulate the "evaluated" slots as per |
| 3130 |
;;; SDS' suggestions. |
| 3131 |
;;; 20050824 |
| 3132 |
|
| 3133 |
(defun preprocess-component-definition (definition-body) |
| 3134 |
`(list* ,@(loop for slot in *component-evaluated-slots* |
| 3135 |
for value = (getf definition-body slot) |
| 3136 |
when value |
| 3137 |
do (remf definition-body slot) |
| 3138 |
and nconc `(,slot ,value)) |
| 3139 |
,@(loop for slot in *component-form-slots* |
| 3140 |
do (remf definition-body slot) |
| 3141 |
nconc `(,slot (lambda () |
| 3142 |
,(getf definition-body slot)))) |
| 3143 |
',definition-body)) |
| 3144 |
|
| 3145 |
|
| 3146 |
;;; defsystem -- |
| 3147 |
;;; The main macro. |
| 3148 |
;;; |
| 3149 |
;;; 2002-11-22 Marco Antoniotti |
| 3150 |
;;; Added code to achieve a first cut "pathname less" operation, |
| 3151 |
;;; following the ideas in ASDF. If the DEFSYSTEM form is loaded from |
| 3152 |
;;; a file, then the location of the file (intended as a directory) is |
| 3153 |
;;; computed from *LOAD-PATHNAME* and stored as the :SOURCE-PATHNAME |
| 3154 |
;;; of the system. |
| 3155 |
|
| 3156 |
(defmacro defsystem (name &rest definition-body) |
| 3157 |
(unless (find :source-pathname definition-body) |
| 3158 |
(setf definition-body |
| 3159 |
(list* :source-pathname |
| 3160 |
'(when #-gcl *load-pathname* #+gcl si::*load-pathname* |
| 3161 |
(make-pathname :name nil |
| 3162 |
:type nil |
| 3163 |
:defaults |
| 3164 |
#-gcl *load-pathname* |
| 3165 |
#+gcl si::*load-pathname* |
| 3166 |
)) |
| 3167 |
definition-body))) |
| 3168 |
`(create-component :defsystem ',name |
| 3169 |
,(preprocess-component-definition definition-body) |
| 3170 |
nil |
| 3171 |
0)) |
| 3172 |
|
| 3173 |
|
| 3174 |
(defun create-component-pathnames (component parent) |
| 3175 |
;; Set up language-specific defaults |
| 3176 |
|
| 3177 |
(setf (component-language component) |
| 3178 |
(or (component-language component) ; for local defaulting |
| 3179 |
(when parent ; parent's default |
| 3180 |
(component-language parent)))) |
| 3181 |
|
| 3182 |
(setf (component-compiler component) |
| 3183 |
(or (component-compiler component) ; for local defaulting |
| 3184 |
(when parent ; parent's default |
| 3185 |
(component-compiler parent)))) |
| 3186 |
(setf (component-loader component) |
| 3187 |
(or (component-loader component) ; for local defaulting |
| 3188 |
(when parent ; parent's default |
| 3189 |
(component-loader parent)))) |
| 3190 |
|
| 3191 |
;; Evaluate the root dir arg |
| 3192 |
(setf (component-root-dir component :source) |
| 3193 |
(eval (component-root-dir component :source))) |
| 3194 |
(setf (component-root-dir component :binary) |
| 3195 |
(eval (component-root-dir component :binary))) |
| 3196 |
|
| 3197 |
;; Evaluate the pathname arg |
| 3198 |
(setf (component-pathname component :source) |
| 3199 |
(eval (component-pathname component :source))) |
| 3200 |
(setf (component-pathname component :binary) |
| 3201 |
(eval (component-pathname component :binary))) |
| 3202 |
|
| 3203 |
|
| 3204 |
;; Pass along the host and devices |
| 3205 |
(setf (component-host component) |
| 3206 |
(or (component-host component) |
| 3207 |
(when parent (component-host parent)) |
| 3208 |
(pathname-host *default-pathname-defaults*))) |
| 3209 |
(setf (component-device component) |
| 3210 |
(or (component-device component) |
| 3211 |
(when parent (component-device parent)))) |
| 3212 |
|
| 3213 |
;; Set up extension defaults |
| 3214 |
(setf (component-extension component :source) |
| 3215 |
(or (component-extension component :source |
| 3216 |
:local #| (component-language component) |# |
| 3217 |
t |
| 3218 |
) ; local default |
| 3219 |
(when (component-language component) |
| 3220 |
(default-source-extension component)) |
| 3221 |
(when parent ; parent's default |
| 3222 |
(component-extension parent :source)))) |
| 3223 |
(setf (component-extension component :binary) |
| 3224 |
(or (component-extension component :binary |
| 3225 |
:local #| (component-language component) |# |
| 3226 |
t |
| 3227 |
) ; local default |
| 3228 |
(when (component-language component) |
| 3229 |
(default-binary-extension component)) |
| 3230 |
(when parent ; parent's default |
| 3231 |
(component-extension parent :binary)))) |
| 3232 |
|
| 3233 |
;; Set up pathname defaults -- expand with parent |
| 3234 |
;; We must set up the source pathname before the binary pathname |
| 3235 |
;; to allow distribution of binaries among the sources to work. |
| 3236 |
(generate-component-pathname component parent :source) |
| 3237 |
(generate-component-pathname component parent :binary)) |
| 3238 |
|
| 3239 |
|
| 3240 |
;;; generate-component-pathnames -- |
| 3241 |
;;; maybe file's inheriting of pathnames should be moved elsewhere? |
| 3242 |
|
| 3243 |
(defun generate-component-pathname (component parent pathname-type) |
| 3244 |
;; Pieces together a pathname for the component based on its component-type. |
| 3245 |
;; Assumes source defined first. |
| 3246 |
;; Null binary pathnames inherit from source instead of the component's |
| 3247 |
;; name. This allows binaries to be distributed among the source if |
| 3248 |
;; binary pathnames are not specified. Or if the root directory is |
| 3249 |
;; specified for binaries, but no module directories, it inherits |
| 3250 |
;; parallel directory structure. |
| 3251 |
(case (component-type component) |
| 3252 |
((:defsystem :system) ; Absolute Pathname |
| 3253 |
;; Set the root-dir to be the absolute pathname |
| 3254 |
(setf (component-root-dir component pathname-type) |
| 3255 |
(or (component-pathname component pathname-type) |
| 3256 |
(when (eq pathname-type :binary) |
| 3257 |
;; When the binary root is nil, use source. |
| 3258 |
(component-root-dir component :source))) ) |
| 3259 |
;; Set the relative pathname to be nil |
| 3260 |
(setf (component-pathname component pathname-type) |
| 3261 |
nil));; should this be "" instead? |
| 3262 |
;; If the name of the component-pathname is nil, it |
| 3263 |
;; defaults to the name of the component. Use "" to |
| 3264 |
;; avoid this defaulting. |
| 3265 |
(:private-file ; Absolute Pathname |
| 3266 |
;; Root-dir is the directory part of the pathname |
| 3267 |
(setf (component-root-dir component pathname-type) |
| 3268 |
"" |
| 3269 |
#+ignore(or (when (component-pathname component pathname-type) |
| 3270 |
(pathname-directory |
| 3271 |
(component-pathname component pathname-type))) |
| 3272 |
(when (eq pathname-type :binary) |
| 3273 |
;; When the binary root is nil, use source. |
| 3274 |
(component-root-dir component :source))) |
| 3275 |
) |
| 3276 |
;; If *SOURCE-PATHNAME-DEFAULT* or *BINARY-PATHNAME-DEFAULT* is "", |
| 3277 |
;; then COMPONENT-SOURCE-PATHNAME or COMPONENT-BINARY-PATHNAME could |
| 3278 |
;; wind up being "", which is wrong for :file components. So replace |
| 3279 |
;; them with NIL. |
| 3280 |
(when (null-string (component-pathname component pathname-type)) |
| 3281 |
(setf (component-pathname component pathname-type) nil)) |
| 3282 |
;; The relative pathname is the name part |
| 3283 |
(setf (component-pathname component pathname-type) |
| 3284 |
(or (when (and (eq pathname-type :binary) |
| 3285 |
(null (component-pathname component :binary))) |
| 3286 |
;; When the binary-pathname is nil use source. |
| 3287 |
(component-pathname component :source)) |
| 3288 |
(or (when (component-pathname component pathname-type) |
| 3289 |
;; (pathname-name ) |
| 3290 |
(component-pathname component pathname-type)) |
| 3291 |
(component-name component))))) |
| 3292 |
((:module :subsystem) ; Pathname relative to parent. |
| 3293 |
;; Inherit root-dir from parent |
| 3294 |
(setf (component-root-dir component pathname-type) |
| 3295 |
(component-root-dir parent pathname-type)) |
| 3296 |
;; Tack the relative-dir onto the pathname |
| 3297 |
(setf (component-pathname component pathname-type) |
| 3298 |
(or (when (and (eq pathname-type :binary) |
| 3299 |
(null (component-pathname component :binary))) |
| 3300 |
;; When the binary-pathname is nil use source. |
| 3301 |
(component-pathname component :source)) |
| 3302 |
(append-directories |
| 3303 |
(component-pathname parent pathname-type) |
| 3304 |
(or (component-pathname component pathname-type) |
| 3305 |
(component-name component)))))) |
| 3306 |
(:file ; Pathname relative to parent. |
| 3307 |
;; Inherit root-dir from parent |
| 3308 |
(setf (component-root-dir component pathname-type) |
| 3309 |
(component-root-dir parent pathname-type)) |
| 3310 |
;; If *SOURCE-PATHNAME-DEFAULT* or *BINARY-PATHNAME-DEFAULT* is "", |
| 3311 |
;; then COMPONENT-SOURCE-PATHNAME or COMPONENT-BINARY-PATHNAME could |
| 3312 |
;; wind up being "", which is wrong for :file components. So replace |
| 3313 |
;; them with NIL. |
| 3314 |
(when (null-string (component-pathname component pathname-type)) |
| 3315 |
(setf (component-pathname component pathname-type) nil)) |
| 3316 |
;; Tack the relative-dir onto the pathname |
| 3317 |
(setf (component-pathname component pathname-type) |
| 3318 |
(or (append-directories |
| 3319 |
(component-pathname parent pathname-type) |
| 3320 |
(or (component-pathname component pathname-type) |
| 3321 |
(component-name component) |
| 3322 |
(when (eq pathname-type :binary) |
| 3323 |
;; When the binary-pathname is nil use source. |
| 3324 |
(component-pathname component :source))))))) |
| 3325 |
)) |
| 3326 |
|
| 3327 |
#|| ;; old version |
| 3328 |
(defun expand-component-components (component &optional (indent 0)) |
| 3329 |
(let ((definitions (component-components component))) |
| 3330 |
(setf (component-components component) |
| 3331 |
(remove-if #'null |
| 3332 |
(mapcar #'(lambda (definition) |
| 3333 |
(expand-component-definition definition |
| 3334 |
component |
| 3335 |
indent)) |
| 3336 |
definitions))))) |
| 3337 |
||# |
| 3338 |
|
| 3339 |
;;; new version |
| 3340 |
(defun expand-component-components (component &optional (indent 0)) |
| 3341 |
(let ((definitions (component-components component))) |
| 3342 |
(if (eq (car definitions) :serial) |
| 3343 |
(setf (component-components component) |
| 3344 |
(expand-serial-component-chain (cdr definitions) |
| 3345 |
component indent)) |
| 3346 |
(setf (component-components component) |
| 3347 |
(expand-component-definitions definitions component indent))))) |
| 3348 |
|
| 3349 |
|
| 3350 |
(defun expand-component-definitions (definitions parent &optional (indent 0)) |
| 3351 |
(let ((components nil)) |
| 3352 |
(dolist (definition definitions) |
| 3353 |
(let ((new (expand-component-definition definition parent indent))) |
| 3354 |
(when new (push new components)))) |
| 3355 |
(nreverse components))) |
| 3356 |
|
| 3357 |
|
| 3358 |
(defun expand-serial-component-chain (definitions parent &optional (indent 0)) |
| 3359 |
(let ((previous nil) |
| 3360 |
(components nil)) |
| 3361 |
(dolist (definition definitions) |
| 3362 |
(let ((new (expand-component-definition definition parent indent))) |
| 3363 |
(when new |
| 3364 |
;; Make this component depend on the previous one. Since |
| 3365 |
;; we don't know the form of the definition, we have to |
| 3366 |
;; expand it first. |
| 3367 |
(when previous (pushnew previous (component-depends-on new))) |
| 3368 |
;; The dependencies will be linked later, so we use the name |
| 3369 |
;; instead of the actual component. |
| 3370 |
(setq previous (component-name new)) |
| 3371 |
;; Save the new component. |
| 3372 |
(push new components)))) |
| 3373 |
;; Return the list of expanded components, in appropriate order. |
| 3374 |
(nreverse components))) |
| 3375 |
|
| 3376 |
|
| 3377 |
(defparameter *enable-straz-absolute-string-hack* nil |
| 3378 |
"Special hack requested by Steve Strassman, where the shorthand |
| 3379 |
that specifies a list of components as a list of strings also |
| 3380 |
recognizes absolute pathnames and treats them as files of type |
| 3381 |
:private-file instead of type :file. Defaults to NIL, because I |
| 3382 |
haven't tested this.") |
| 3383 |
|
| 3384 |
|
| 3385 |
(defun absolute-file-namestring-p (string) |
| 3386 |
;; If a FILE namestring starts with a slash, or is a logical pathname |
| 3387 |
;; as implied by the existence of a colon in the filename, assume it |
| 3388 |
;; represents an absolute pathname. |
| 3389 |
(or (find #\: string :test #'char=) |
| 3390 |
(and (not (null-string string)) |
| 3391 |
(char= (char string 0) #\/)))) |
| 3392 |
|
| 3393 |
|
| 3394 |
(defun expand-component-definition (definition parent &optional (indent 0)) |
| 3395 |
;; Should do some checking for malformed definitions here. |
| 3396 |
(cond ((null definition) nil) |
| 3397 |
((stringp definition) |
| 3398 |
;; Strings are assumed to be of type :file |
| 3399 |
(if (and *enable-straz-absolute-string-hack* |
| 3400 |
(absolute-file-namestring-p definition)) |
| 3401 |
;; Special hack for Straz |
| 3402 |
(create-component :private-file definition nil parent indent) |
| 3403 |
;; Normal behavior |
| 3404 |
(create-component :file definition nil parent indent))) |
| 3405 |
((and (listp definition) |
| 3406 |
(not (member (car definition) |
| 3407 |
'(:defsystem :system :subsystem |
| 3408 |
:module :file :private-file)))) |
| 3409 |
;; Lists whose first element is not a component type |
| 3410 |
;; are assumed to be of type :file |
| 3411 |
(create-component :file |
| 3412 |
(first definition) |
| 3413 |
;; (preprocess-component-definition (rest definition)) ; Not working. |
| 3414 |
(rest definition) |
| 3415 |
parent |
| 3416 |
indent)) |
| 3417 |
((listp definition) |
| 3418 |
;; Otherwise, it is (we hope) a normal form definition |
| 3419 |
(create-component (first definition) ; type |
| 3420 |
(second definition) ; name |
| 3421 |
|
| 3422 |
;; definition body |
| 3423 |
;; (preprocess-component-definition (cddr definition)) ; Not working. |
| 3424 |
(cddr definition) |
| 3425 |
|
| 3426 |
parent ; parent |
| 3427 |
indent) ; indent |
| 3428 |
))) |
| 3429 |
|
| 3430 |
|
| 3431 |
(defun link-component-depends-on (components) |
| 3432 |
(dolist (component components) |
| 3433 |
(unless (and *system-dependencies-delayed* |
| 3434 |
(eq (component-type component) :defsystem)) |
| 3435 |
(setf (component-depends-on component) |
| 3436 |
(mapcar #'(lambda (dependency) |
| 3437 |
(let ((parent (find (string dependency) components |
| 3438 |
:key #'component-name |
| 3439 |
:test #'string-equal))) |
| 3440 |
(cond (parent parent) |
| 3441 |
;; make it more intelligent about the following |
| 3442 |
(t (warn "Dependency ~S of component ~S not found." |
| 3443 |
dependency component))))) |
| 3444 |
|
| 3445 |
(component-depends-on component)))))) |
| 3446 |
|
| 3447 |
|
| 3448 |
;;; ******************************** |
| 3449 |
;;; Topological Sort the Graph ***** |
| 3450 |
;;; ******************************** |
| 3451 |
|
| 3452 |
;;; New version of topological sort suggested by rs2. Even though |
| 3453 |
;;; this version avoids the call to sort, in practice it isn't faster. It |
| 3454 |
;;; does, however, eliminate the need to have a TIME slot in the |
| 3455 |
;;; topological-sort-node defstruct. |
| 3456 |
|
| 3457 |
(defun topological-sort (list &aux (sorted-list nil)) |
| 3458 |
(labels ((dfs-visit (znode) |
| 3459 |
(setf (topsort-color znode) :gray) |
| 3460 |
(unless (and *system-dependencies-delayed* |
| 3461 |
(eq (component-type znode) :system)) |
| 3462 |
(dolist (child (component-depends-on znode)) |
| 3463 |
(cond ((eq (topsort-color child) :white) |
| 3464 |
(dfs-visit child)) |
| 3465 |
((eq (topsort-color child) :gray) |
| 3466 |
(format t "~&Detected cycle containing ~A" child))))) |
| 3467 |
(setf (topsort-color znode) :black) |
| 3468 |
(push znode sorted-list))) |
| 3469 |
(dolist (znode list) |
| 3470 |
(setf (topsort-color znode) :white)) |
| 3471 |
(dolist (znode list) |
| 3472 |
(when (eq (topsort-color znode) :white) |
| 3473 |
(dfs-visit znode))) |
| 3474 |
(nreverse sorted-list))) |
| 3475 |
|
| 3476 |
#|| |
| 3477 |
;;; Older version of topological sort. |
| 3478 |
(defun topological-sort (list &aux (time 0)) |
| 3479 |
;; The algorithm works by calling depth-first-search to compute the |
| 3480 |
;; blackening times for each vertex, and then sorts the vertices into |
| 3481 |
;; reverse order by blackening time. |
| 3482 |
(labels ((dfs-visit (node) |
| 3483 |
(setf (topsort-color node) 'gray) |
| 3484 |
(unless (and *system-dependencies-delayed* |
| 3485 |
(eq (component-type node) :defsystem)) |
| 3486 |
(dolist (child (component-depends-on node)) |
| 3487 |
(cond ((eq (topsort-color child) 'white) |
| 3488 |
(dfs-visit child)) |
| 3489 |
((eq (topsort-color child) 'gray) |
| 3490 |
(format t "~&Detected cycle containing ~A" child))))) |
| 3491 |
(setf (topsort-color node) 'black) |
| 3492 |
(setf (topsort-time node) time) |
| 3493 |
(incf time))) |
| 3494 |
(dolist (node list) |
| 3495 |
(setf (topsort-color node) 'white)) |
| 3496 |
(dolist (node list) |
| 3497 |
(when (eq (topsort-color node) 'white) |
| 3498 |
(dfs-visit node))) |
| 3499 |
(sort list #'< :key #'topsort-time))) |
| 3500 |
||# |
| 3501 |
|
| 3502 |
;;; ******************************** |
| 3503 |
;;; Output to User ***************** |
| 3504 |
;;; ******************************** |
| 3505 |
;;; All output to the user is via the tell-user functions. |
| 3506 |
|
| 3507 |
(defun split-string (string &key (item #\space) (test #'char=)) |
| 3508 |
;; Splits the string into substrings at spaces. |
| 3509 |
(let ((len (length string)) |
| 3510 |
(index 0) result) |
| 3511 |
(dotimes (i len |
| 3512 |
(progn (unless (= index len) |
| 3513 |
(push (subseq string index) result)) |
| 3514 |
(reverse result))) |
| 3515 |
(when (funcall test (char string i) item) |
| 3516 |
(unless (= index i);; two spaces in a row |
| 3517 |
(push (subseq string index i) result)) |
| 3518 |
(setf index (1+ i)))))) |
| 3519 |
|
| 3520 |
;; probably should remove the ",1" entirely. But AKCL 1.243 dies on it |
| 3521 |
;; because of an AKCL bug. |
| 3522 |
;; KGK suggests using an 8 instead, but 1 does nicely. |
| 3523 |
|
| 3524 |
(defun prompt-string (component) |
| 3525 |
(format nil "; ~:[~;TEST:~]~V,1@T " |
| 3526 |
*oos-test* |
| 3527 |
(component-indent component))) |
| 3528 |
|
| 3529 |
#|| |
| 3530 |
(defun format-justified-string (prompt contents) |
| 3531 |
(format t (concatenate 'string |
| 3532 |
"~%" |
| 3533 |
prompt |
| 3534 |
"-~{~<~%" prompt " ~1,80:; ~A~>~^~}") |
| 3535 |
(split-string contents)) |
| 3536 |
(finish-output *standard-output*)) |
| 3537 |
||# |
| 3538 |
|
| 3539 |
(defun format-justified-string (prompt contents &optional (width 80) |
| 3540 |
(stream *standard-output*)) |
| 3541 |
(let ((prompt-length (+ 2 (length prompt)))) |
| 3542 |
(cond ((< (+ prompt-length (length contents)) width) |
| 3543 |
(format stream "~%~A- ~A" prompt contents)) |
| 3544 |
(t |
| 3545 |
(format stream "~%~A-" prompt) |
| 3546 |
(do* ((cursor prompt-length) |
| 3547 |
(contents (split-string contents) (cdr contents)) |
| 3548 |
(content (car contents) (car contents)) |
| 3549 |
(content-length (1+ (length content)) (1+ (length content)))) |
| 3550 |
((null contents)) |
| 3551 |
(cond ((< (+ cursor content-length) width) |
| 3552 |
(incf cursor content-length) |
| 3553 |
(format stream " ~A" content)) |
| 3554 |
(t |
| 3555 |
(setf cursor (+ prompt-length content-length)) |
| 3556 |
(format stream "~%~A ~A" prompt content))))))) |
| 3557 |
(finish-output stream)) |
| 3558 |
|
| 3559 |
|
| 3560 |
(defun tell-user (what component &optional type no-dots force) |
| 3561 |
(when (or *oos-verbose* force) |
| 3562 |
(format-justified-string (prompt-string component) |
| 3563 |
(format nil "~A ~(~A~) ~@[\"~A\"~] ~:[~;...~]" |
| 3564 |
;; To have better messages, wrap the following around the |
| 3565 |
;; case statement: |
| 3566 |
;;(if (find (component-type component) |
| 3567 |
;; '(:defsystem :system :subsystem :module)) |
| 3568 |
;; "Checking" |
| 3569 |
;; (case ...)) |
| 3570 |
;; This gets around the problem of DEFSYSTEM reporting |
| 3571 |
;; that it's loading a module, when it eventually never |
| 3572 |
;; loads any of the files of the module. |
| 3573 |
(case what |
| 3574 |
((compile :compile) |
| 3575 |
(if (component-load-only component) |
| 3576 |
;; If it is :load-only t, we're loading. |
| 3577 |
"Loading" |
| 3578 |
;; Otherwise we're compiling. |
| 3579 |
"Compiling")) |
| 3580 |
((load :load) "Loading") |
| 3581 |
(otherwise what)) |
| 3582 |
(component-type component) |
| 3583 |
(or (when type |
| 3584 |
(component-full-pathname component type)) |
| 3585 |
(component-name component)) |
| 3586 |
(and *tell-user-when-done* |
| 3587 |
(not no-dots)))))) |
| 3588 |
|
| 3589 |
|
| 3590 |
(defun tell-user-done (component &optional force no-dots) |
| 3591 |
;; test is no longer really used, but we're leaving it in. |
| 3592 |
(when (and *tell-user-when-done* |
| 3593 |
(or *oos-verbose* force)) |
| 3594 |
(format t "~&~A~:[~;...~] Done." |
| 3595 |
(prompt-string component) (not no-dots)) |
| 3596 |
(finish-output *standard-output*))) |
| 3597 |
|
| 3598 |
|
| 3599 |
(defmacro with-tell-user ((what component &optional type no-dots force) &body body) |
| 3600 |
`(progn |
| 3601 |
(tell-user ,what ,component ,type ,no-dots ,force) |
| 3602 |
,@body |
| 3603 |
(tell-user-done ,component ,force ,no-dots))) |
| 3604 |
|
| 3605 |
|
| 3606 |
(defun tell-user-no-files (component &optional force) |
| 3607 |
(when (or *oos-verbose* force) |
| 3608 |
(format-justified-string (prompt-string component) |
| 3609 |
(format nil "Source file ~A ~ |
| 3610 |
~:[and binary file ~A ~;~]not found, not loading." |
| 3611 |
(component-full-pathname component :source) |
| 3612 |
(or *load-source-if-no-binary* *load-source-instead-of-binary*) |
| 3613 |
(component-full-pathname component :binary))))) |
| 3614 |
|
| 3615 |
|
| 3616 |
(defun tell-user-require-system (name parent) |
| 3617 |
(when *oos-verbose* |
| 3618 |
(format t "~&; ~:[~;TEST:~] - System ~A requires ~S" |
| 3619 |
*oos-test* (component-name parent) name) |
| 3620 |
(finish-output *standard-output*))) |
| 3621 |
|
| 3622 |
|
| 3623 |
(defun tell-user-generic (string) |
| 3624 |
(when *oos-verbose* |
| 3625 |
(format t "~&; ~:[~;TEST:~] - ~A" |
| 3626 |
*oos-test* string) |
| 3627 |
(finish-output *standard-output*))) |
| 3628 |
|
| 3629 |
|
| 3630 |
;;; ******************************** |
| 3631 |
;;; Y-OR-N-P-WAIT ****************** |
| 3632 |
;;; ******************************** |
| 3633 |
;;; Y-OR-N-P-WAIT is like Y-OR-N-P, but will timeout after a specified |
| 3634 |
;;; number of seconds. I should really replace this with a call to |
| 3635 |
;;; the Y-OR-N-P-WAIT defined in the query.cl package and include that |
| 3636 |
;;; instead. |
| 3637 |
|
| 3638 |
(defparameter *use-timeouts* t |
| 3639 |
"If T, timeouts in Y-OR-N-P-WAIT are enabled. Otherwise it behaves |
| 3640 |
like Y-OR-N-P. This is provided for users whose lisps don't handle |
| 3641 |
read-char-no-hang properly.") |
| 3642 |
|
| 3643 |
(defparameter *clear-input-before-query* t |
| 3644 |
"If T, y-or-n-p-wait will clear the input before printing the prompt |
| 3645 |
and asking the user for input.") |
| 3646 |
|
| 3647 |
;;; The higher *sleep-amount* is, the less consing, but the lower the |
| 3648 |
;;; responsiveness. |
| 3649 |
(defparameter *sleep-amount* #-CMU 0.1 #+CMU 1.0 |
| 3650 |
"Amount of time to sleep between checking query-io. In multiprocessing |
| 3651 |
Lisps, this allows other processes to continue while we busy-wait. If |
| 3652 |
0, skips call to SLEEP.") |
| 3653 |
|
| 3654 |
|
| 3655 |
(defun internal-real-time-in-seconds () |
| 3656 |
(get-universal-time)) |
| 3657 |
|
| 3658 |
|
| 3659 |
(defun read-char-wait (&optional (timeout 20) input-stream |
| 3660 |
(eof-error-p t) eof-value |
| 3661 |
&aux peek) |
| 3662 |
(do ((start (internal-real-time-in-seconds))) |
| 3663 |
((or (setq peek (listen input-stream)) |
| 3664 |
(< (+ start timeout) (internal-real-time-in-seconds))) |
| 3665 |
(when peek |
| 3666 |
;; was read-char-no-hang |
| 3667 |
(read-char input-stream eof-error-p eof-value))) |
| 3668 |
(unless (zerop *sleep-amount*) |
| 3669 |
(sleep *sleep-amount*)))) |
| 3670 |
|
| 3671 |
|
| 3672 |
;;; Lots of lisps, especially those that run on top of UNIX, do not get |
| 3673 |
;;; their input one character at a time, but a whole line at a time because |
| 3674 |
;;; of the buffering done by the UNIX system. This causes y-or-n-p-wait |
| 3675 |
;;; to not always work as expected. |
| 3676 |
;;; |
| 3677 |
;;; I wish lisp did all its own buffering (turning off UNIX input line |
| 3678 |
;;; buffering by putting the UNIX into CBREAK mode). Of course, this means |
| 3679 |
;;; that we lose input editing, but why can't the lisp implement this? |
| 3680 |
|
| 3681 |
(defun y-or-n-p-wait (&optional (default #\y) (timeout 20) |
| 3682 |
format-string &rest args) |
| 3683 |
"Y-OR-N-P-WAIT prints the message, if any, and reads characters from |
| 3684 |
*QUERY-IO* until the user enters y, Y or space as an affirmative, or either |
| 3685 |
n or N as a negative answer, or the timeout occurs. It asks again if |
| 3686 |
you enter any other characters." |
| 3687 |
(when *clear-input-before-query* (clear-input *query-io*)) |
| 3688 |
(when format-string |
| 3689 |
(fresh-line *query-io*) |
| 3690 |
(apply #'format *query-io* format-string args) |
| 3691 |
;; FINISH-OUTPUT needed for CMU and other places which don't handle |
| 3692 |
;; output streams nicely. This prevents it from continuing and |
| 3693 |
;; reading the query until the prompt has been printed. |
| 3694 |
(finish-output *query-io*)) |
| 3695 |
(loop |
| 3696 |
(let* ((read-char (if *use-timeouts* |
| 3697 |
(read-char-wait timeout *query-io* nil nil) |
| 3698 |
(read-char *query-io*))) |
| 3699 |
(char (or read-char default))) |
| 3700 |
;; We need to ignore #\newline because otherwise the bugs in |
| 3701 |
;; clear-input will cause y-or-n-p-wait to print the "Type ..." |
| 3702 |
;; message every time... *sigh* |
| 3703 |
;; Anyway, we might want to use this to ignore whitespace once |
| 3704 |
;; clear-input is fixed. |
| 3705 |
(unless (find char '(#\tab #\newline #\return)) |
| 3706 |
(when (null read-char) |
| 3707 |
(format *query-io* "~@[~A~]" default) |
| 3708 |
(finish-output *query-io*)) |
| 3709 |
(cond ((null char) (return t)) |
| 3710 |
((find char '(#\y #\Y #\space) :test #'char=) (return t)) |
| 3711 |
((find char '(#\n #\N) :test #'char=) (return nil)) |
| 3712 |
(t |
| 3713 |
(when *clear-input-before-query* (clear-input *query-io*)) |
| 3714 |
(format *query-io* "~&Type \"y\" for yes or \"n\" for no. ") |
| 3715 |
(when format-string |
| 3716 |
(fresh-line *query-io*) |
| 3717 |
(apply #'format *query-io* format-string args)) |
| 3718 |
(finish-output *query-io*))))))) |
| 3719 |
|
| 3720 |
#|| |
| 3721 |
(y-or-n-p-wait #\y 20 "What? ") |
| 3722 |
(progn (format t "~&hi") (finish-output) |
| 3723 |
(y-or-n-p-wait #\y 10 "1? ") |
| 3724 |
(y-or-n-p-wait #\n 10 "2? ")) |
| 3725 |
||# |
| 3726 |
|
| 3727 |
;;;=========================================================================== |
| 3728 |
;;; Running the operations. |
| 3729 |
|
| 3730 |
(defvar %%component%% nil) |
| 3731 |
|
| 3732 |
(export '(%%component%%)) ; Just a placeholder. Move it to the export list. |
| 3733 |
|
| 3734 |
|
| 3735 |
(defmacro with-special-component-vars ((c) &body forms) |
| 3736 |
`(let ((%%component%% ,c)) |
| 3737 |
(declare (special %%component%%)) |
| 3738 |
,@forms)) |
| 3739 |
|
| 3740 |
|
| 3741 |
;;; ******************************** |
| 3742 |
;;; Operate on System ************** |
| 3743 |
;;; ******************************** |
| 3744 |
;;; Operate-on-system |
| 3745 |
;;; Operation is :compile, 'compile, :load or 'load |
| 3746 |
;;; Force is :all or :new-source or :new-source-and-dependents or a list of |
| 3747 |
;;; specific modules. |
| 3748 |
;;; :all (or T) forces a recompilation of every file in the system |
| 3749 |
;;; :new-source-and-dependents compiles only those files whose |
| 3750 |
;;; sources have changed or who depend on recompiled files. |
| 3751 |
;;; :new-source compiles only those files whose sources have changed |
| 3752 |
;;; A list of modules means that only those modules and their |
| 3753 |
;;; dependents are recompiled. |
| 3754 |
;;; Test is T to print out what it would do without actually doing it. |
| 3755 |
;;; Note: it automatically sets verbose to T if test is T. |
| 3756 |
;;; Verbose is T to print out what it is doing (compiling, loading of |
| 3757 |
;;; modules and files) as it does it. |
| 3758 |
;;; Dribble should be the pathname of the dribble file if you want to |
| 3759 |
;;; dribble the compilation. |
| 3760 |
;;; Load-source-instead-of-binary is T to load .lisp instead of binary files. |
| 3761 |
;;; Version may be nil to signify no subdirectory, |
| 3762 |
;;; a symbol, such as alpha, beta, omega, :alpha, mark, which |
| 3763 |
;;; specifies a subdirectory of the root, or |
| 3764 |
;;; a string, which replaces the root. |
| 3765 |
|
| 3766 |
(defun operate-on-system (name operation |
| 3767 |
&key |
| 3768 |
force |
| 3769 |
(version *version*) |
| 3770 |
(test *oos-test*) (verbose *oos-verbose*) |
| 3771 |
(load-source-instead-of-binary |
| 3772 |
*load-source-instead-of-binary*) |
| 3773 |
(load-source-if-no-binary |
| 3774 |
*load-source-if-no-binary*) |
| 3775 |
(bother-user-if-no-binary |
| 3776 |
*bother-user-if-no-binary*) |
| 3777 |
(compile-during-load *compile-during-load*) |
| 3778 |
dribble |
| 3779 |
(minimal-load *minimal-load*) |
| 3780 |
(override-compilation-unit t) |
| 3781 |
) |
| 3782 |
(declare #-(or :cltl2 :ansi-cl) (ignore override-compilation-unit)) |
| 3783 |
(unwind-protect |
| 3784 |
;; Protect the undribble. |
| 3785 |
(#+(and (or :cltl2 :ansi-cl) (not :gcl)) with-compilation-unit |
| 3786 |
#+(and (or :cltl2 :ansi-cl) (not :gcl)) (:override override-compilation-unit) |
| 3787 |
#-(and (or :cltl2 :ansi-cl) (not :gcl)) progn |
| 3788 |
(when *reset-full-pathname-table* (clear-full-pathname-tables)) |
| 3789 |
(when dribble (dribble dribble)) |
| 3790 |
(when test (setq verbose t)) |
| 3791 |
(when (null force) ; defaults |
| 3792 |
(case operation |
| 3793 |
((load :load) (setq force :all)) |
| 3794 |
((compile :compile) (setq force :new-source-and-dependents)) |
| 3795 |
(t (setq force :all)))) |
| 3796 |
;; Some CL implementations have a variable called *compile-verbose* |
| 3797 |
;; or *compile-file-verbose*. |
| 3798 |
(multiple-value-bind (*version-dir* *version-replace*) |
| 3799 |
(translate-version version) |
| 3800 |
;; CL implementations may uniformly default this to nil |
| 3801 |
(let ((*load-verbose* #-common-lisp-controller t |
| 3802 |
#+common-lisp-controller nil) ; nil |
| 3803 |
#-(or MCL CMU CLISP ECL :sbcl lispworks scl) |
| 3804 |
(*compile-file-verbose* t) ; nil |
| 3805 |
#+common-lisp-controller |
| 3806 |
(*compile-print* nil) |
| 3807 |
#+(and common-lisp-controller cmu) |
| 3808 |
(ext:*compile-progress* nil) |
| 3809 |
#+(and common-lisp-controller cmu) |
| 3810 |
(ext:*require-verbose* nil) |
| 3811 |
#+(and common-lisp-controller cmu) |
| 3812 |
(ext:*gc-verbose* nil) |
| 3813 |
|
| 3814 |
(*compile-verbose* #-common-lisp-controller t |
| 3815 |
#+common-lisp-controller nil) ; nil |
| 3816 |
(*version* version) |
| 3817 |
(*oos-verbose* verbose) |
| 3818 |
(*oos-test* test) |
| 3819 |
(*load-source-if-no-binary* load-source-if-no-binary) |
| 3820 |
(*compile-during-load* compile-during-load) |
| 3821 |
(*bother-user-if-no-binary* bother-user-if-no-binary) |
| 3822 |
(*load-source-instead-of-binary* load-source-instead-of-binary) |
| 3823 |
(*minimal-load* minimal-load) |
| 3824 |
(system (if (and (component-p name) |
| 3825 |
(member (component-type name) |
| 3826 |
'(:system :defsystem :subsystem))) |
| 3827 |
name |
| 3828 |
(find-system name :load)))) |
| 3829 |
#-(or CMU CLISP :sbcl :lispworks :cormanlisp scl) |
| 3830 |
(declare (special *compile-verbose* #-MCL *compile-file-verbose*) |
| 3831 |
#-openmcl (ignore *compile-verbose* |
| 3832 |
#-MCL *compile-file-verbose*) |
| 3833 |
#-openmcl (optimize (inhibit-warnings 3))) |
| 3834 |
(unless (component-operation operation) |
| 3835 |
(error "Operation ~A undefined." operation)) |
| 3836 |
|
| 3837 |
(operate-on-component system operation force)))) |
| 3838 |
(when dribble (dribble)))) |
| 3839 |
|
| 3840 |
|
| 3841 |
(defun compile-system (name &key force |
| 3842 |
(version *version*) |
| 3843 |
(test *oos-test*) (verbose *oos-verbose*) |
| 3844 |
(load-source-instead-of-binary |
| 3845 |
*load-source-instead-of-binary*) |
| 3846 |
(load-source-if-no-binary |
| 3847 |
*load-source-if-no-binary*) |
| 3848 |
(bother-user-if-no-binary |
| 3849 |
*bother-user-if-no-binary*) |
| 3850 |
(compile-during-load *compile-during-load*) |
| 3851 |
dribble |
| 3852 |
(minimal-load *minimal-load*)) |
| 3853 |
;; For users who are confused by OOS. |
| 3854 |
(operate-on-system |
| 3855 |
name :compile |
| 3856 |
:force force |
| 3857 |
:version version |
| 3858 |
:test test |
| 3859 |
:verbose verbose |
| 3860 |
:load-source-instead-of-binary load-source-instead-of-binary |
| 3861 |
:load-source-if-no-binary load-source-if-no-binary |
| 3862 |
:bother-user-if-no-binary bother-user-if-no-binary |
| 3863 |
:compile-during-load compile-during-load |
| 3864 |
:dribble dribble |
| 3865 |
:minimal-load minimal-load)) |
| 3866 |
|
| 3867 |
(defun load-system (name &key force |
| 3868 |
(version *version*) |
| 3869 |
(test *oos-test*) (verbose *oos-verbose*) |
| 3870 |
(load-source-instead-of-binary |
| 3871 |
*load-source-instead-of-binary*) |
| 3872 |
(load-source-if-no-binary *load-source-if-no-binary*) |
| 3873 |
(bother-user-if-no-binary *bother-user-if-no-binary*) |
| 3874 |
(compile-during-load *compile-during-load*) |
| 3875 |
dribble |
| 3876 |
(minimal-load *minimal-load*)) |
| 3877 |
;; For users who are confused by OOS. |
| 3878 |
(operate-on-system |
| 3879 |
name :load |
| 3880 |
:force force |
| 3881 |
:version version |
| 3882 |
:test test |
| 3883 |
:verbose verbose |
| 3884 |
:load-source-instead-of-binary load-source-instead-of-binary |
| 3885 |
:load-source-if-no-binary load-source-if-no-binary |
| 3886 |
:bother-user-if-no-binary bother-user-if-no-binary |
| 3887 |
:compile-during-load compile-during-load |
| 3888 |
:dribble dribble |
| 3889 |
:minimal-load minimal-load)) |
| 3890 |
|
| 3891 |
(defun clean-system (name &key (force :all) |
| 3892 |
(version *version*) |
| 3893 |
(test *oos-test*) (verbose *oos-verbose*) |
| 3894 |
dribble) |
| 3895 |
"Deletes all the binaries in the system." |
| 3896 |
;; For users who are confused by OOS. |
| 3897 |
(operate-on-system |
| 3898 |
name :delete-binaries |
| 3899 |
:force force |
| 3900 |
:version version |
| 3901 |
:test test |
| 3902 |
:verbose verbose |
| 3903 |
:dribble dribble)) |
| 3904 |
|
| 3905 |
(defun edit-system |
| 3906 |
(name &key force |
| 3907 |
(version *version*) |
| 3908 |
(test *oos-test*) |
| 3909 |
(verbose *oos-verbose*) |
| 3910 |
dribble) |
| 3911 |
|
| 3912 |
(operate-on-system |
| 3913 |
name :edit |
| 3914 |
:force force |
| 3915 |
:version version |
| 3916 |
:test test |
| 3917 |
:verbose verbose |
| 3918 |
:dribble dribble)) |
| 3919 |
|
| 3920 |
(defun hardcopy-system |
| 3921 |
(name &key force |
| 3922 |
(version *version*) |
| 3923 |
(test *oos-test*) |
| 3924 |
(verbose *oos-verbose*) |
| 3925 |
dribble) |
| 3926 |
|
| 3927 |
(operate-on-system |
| 3928 |
name :hardcopy |
| 3929 |
:force force |
| 3930 |
:version version |
| 3931 |
:test test |
| 3932 |
:verbose verbose |
| 3933 |
:dribble dribble)) |
| 3934 |
|
| 3935 |
|
| 3936 |
;;; ensure-external-system-def-loaded component -- |
| 3937 |
;;; Let's treat definition clauses of the form |
| 3938 |
;;; |
| 3939 |
;;; (:system "name") |
| 3940 |
;;; i.e. |
| 3941 |
;;; |
| 3942 |
;;; (:system "name" :components nil) |
| 3943 |
;;; |
| 3944 |
;;; in a special way. |
| 3945 |
;;; When encountered, MK:DEFSYSTEM tries to FIND-SYSTEM |
| 3946 |
;;; the system named "name" (by forcing a reload from disk). |
| 3947 |
;;; This may be more "natural". |
| 3948 |
|
| 3949 |
(defun ensure-external-system-def-loaded (component) |
| 3950 |
(assert (member (component-type component) |
| 3951 |
'(:subsystem :system))) |
| 3952 |
(when (null (component-components component)) |
| 3953 |
(let* ((cname (component-name component))) |
| 3954 |
(declare (ignorable cname)) |
| 3955 |
;; First we ensure that we reload the system definition. |
| 3956 |
(undefsystem cname) |
| 3957 |
(let* ((*reload-systems-from-disk* t) |
| 3958 |
(system-component |
| 3959 |
(find-system (component-name component) |
| 3960 |
:load |
| 3961 |
|
| 3962 |
;; Let's not supply the def-pname |
| 3963 |
;; yet. |
| 3964 |
#+not-yet |
| 3965 |
(merge-pathname |
| 3966 |
(make-pathname :name cname |
| 3967 |
:type "system" |
| 3968 |
:directory ()) |
| 3969 |
(component-full-pathname component |
| 3970 |
:source)) |
| 3971 |
|
| 3972 |
|
| 3973 |
)) |
| 3974 |
) |
| 3975 |
;; Now we have a problem. |
| 3976 |
;; We have just ensured that a system definition is |
| 3977 |
;; loaded, however, the COMPONENT at hand is different |
| 3978 |
;; from SYSTEM-COMPONENT. |
| 3979 |
;; To fix this problem we just use the following |
| 3980 |
;; kludge. This should prevent re-entering in this |
| 3981 |
;; code branch, while actually preparing the COMPONENT |
| 3982 |
;; for operation. |
| 3983 |
(setf (component-components component) |
| 3984 |
(list system-component)) |
| 3985 |
)))) |
| 3986 |
|
| 3987 |
|
| 3988 |
(defun operate-on-component (component operation force &aux changed) |
| 3989 |
;; Returns T if something changed and had to be compiled. |
| 3990 |
(let ((type (component-type component)) |
| 3991 |
(old-package (package-name *package*))) |
| 3992 |
|
| 3993 |
(unwind-protect |
| 3994 |
;; Protect old-package. |
| 3995 |
(progn |
| 3996 |
;; Use the correct package. |
| 3997 |
(when (component-package component) |
| 3998 |
(tell-user-generic (format nil "Using package ~A" |
| 3999 |
(component-package component))) |
| 4000 |
(unless *oos-test* |
| 4001 |
(unless (find-package (component-package component)) |
| 4002 |
;; If the package name is the same as the name of the system, |
| 4003 |
;; and the package is not defined, this would lead to an |
| 4004 |
;; infinite loop, so bomb out with an error. |
| 4005 |
(when (string-equal (string (component-package component)) |
| 4006 |
(component-name component)) |
| 4007 |
(format t "~%Component ~A not loaded:~%" |
| 4008 |
(component-name component)) |
| 4009 |
(error " Package ~A is not defined" |
| 4010 |
(component-package component))) |
| 4011 |
;; If package not found, try using REQUIRE to load it. |
| 4012 |
(new-require (component-package component))) |
| 4013 |
;; This was USE-PACKAGE, but should be IN-PACKAGE. |
| 4014 |
;; Actually, CLtL2 lisps define in-package as a macro, |
| 4015 |
;; so we'll set the package manually. |
| 4016 |
;; (in-package (component-package component)) |
| 4017 |
(let ((package (find-package (component-package component)))) |
| 4018 |
(when package |
| 4019 |
(setf *package* package))))) |
| 4020 |
|
| 4021 |
;; Marco Antoniotti 20040609 |
| 4022 |
;; New feature. Try to FIND-SYSTEM :system components if |
| 4023 |
;; they have no local :components definition. |
| 4024 |
;; OPERATE-ON-SYSTEM-DEPENDENCIES should still work as |
| 4025 |
;; advertised, given the small change made there. |
| 4026 |
|
| 4027 |
(when (or (eq type :system) (eq type :subsystem)) |
| 4028 |
(ensure-external-system-def-loaded component)) |
| 4029 |
|
| 4030 |
(when (or (eq type :defsystem) (eq type :system)) |
| 4031 |
(operate-on-system-dependencies component operation force)) |
| 4032 |
|
| 4033 |
;; Do any compiler proclamations |
| 4034 |
(when (component-proclamations component) |
| 4035 |
(tell-user-generic (format nil "Doing proclamations for ~A" |
| 4036 |
(component-name component))) |
| 4037 |
(unless *oos-test* |
| 4038 |
(proclaim (component-proclamations component)))) |
| 4039 |
|
| 4040 |
;; Do any initial actions |
| 4041 |
(when (component-initially-do component) |
| 4042 |
(tell-user-generic (format nil "Doing initializations for ~A" |
| 4043 |
(component-name component))) |
| 4044 |
(unless *oos-test* |
| 4045 |
(with-special-component-vars (component) |
| 4046 |
(let ((initially-do (component-initially-do component))) |
| 4047 |
(if (functionp initially-do) |
| 4048 |
(funcall initially-do) |
| 4049 |
(eval initially-do)))) |
| 4050 |
)) |
| 4051 |
|
| 4052 |
;; If operation is :compile and load-only is T, this would change |
| 4053 |
;; the operation to load. Only, this would mean that a module would |
| 4054 |
;; be considered to have changed if it was :load-only and had to be |
| 4055 |
;; loaded, and then dependents would be recompiled -- this doesn't |
| 4056 |
;; seem right. So instead, we propagate the :load-only attribute |
| 4057 |
;; to the components, and modify compile-file-operation so that |
| 4058 |
;; it won't compile the files (and modify tell-user to say "Loading" |
| 4059 |
;; instead of "Compiling" for load-only modules). |
| 4060 |
#|| |
| 4061 |
(when (and (find operation '(:compile compile)) |
| 4062 |
(component-load-only component)) |
| 4063 |
(setf operation :load)) |
| 4064 |
||# |
| 4065 |
|
| 4066 |
;; Do operation and set changed flag if necessary. |
| 4067 |
(setq changed |
| 4068 |
(case type |
| 4069 |
((:file :private-file) |
| 4070 |
(funcall (component-operation operation) component force)) |
| 4071 |
((:module :system :subsystem :defsystem) |
| 4072 |
(operate-on-components component operation force changed)))) |
| 4073 |
|
| 4074 |
;; Do any final actions |
| 4075 |
(when (component-finally-do component) |
| 4076 |
(tell-user-generic (format nil "Doing finalizations for ~A" |
| 4077 |
(component-name component))) |
| 4078 |
(unless *oos-test* |
| 4079 |
(with-special-component-vars (component) |
| 4080 |
(let ((finally-do (component-finally-do component))) |
| 4081 |
(if (functionp finally-do) |
| 4082 |
(funcall finally-do) |
| 4083 |
(eval finally-do)))) |
| 4084 |
)) |
| 4085 |
|
| 4086 |
;; add the banner if needed |
| 4087 |
#+(or cmu scl) |
| 4088 |
(when (component-banner component) |
| 4089 |
(unless (stringp (component-banner component)) |
| 4090 |
(error "The banner should be a string, it is: ~S" |
| 4091 |
(component-banner component))) |
| 4092 |
(setf (getf ext:*herald-items* |
| 4093 |
(intern (string-upcase (component-name component)) |
| 4094 |
(find-package :keyword))) |
| 4095 |
(list |
| 4096 |
(component-banner component))))) |
| 4097 |
|
| 4098 |
;; Reset the package. (Cleanup form of unwind-protect.) |
| 4099 |
;;(in-package old-package) |
| 4100 |
(setf *package* (find-package old-package))) |
| 4101 |
|
| 4102 |
;; Provide the loaded system |
| 4103 |
(when (or (eq type :defsystem) (eq type :system) (eq type :subsystem)) |
| 4104 |
(tell-user-generic (format nil "Providing system ~A~%" |
| 4105 |
(component-name component))) |
| 4106 |
(or *oos-test* |
| 4107 |
(provide (canonicalize-system-name (component-name component)))))) |
| 4108 |
|
| 4109 |
;; Return non-NIL if something changed in this component and hence had |
| 4110 |
;; to be recompiled. This is only used as a boolean. |
| 4111 |
changed) |
| 4112 |
|
| 4113 |
(defvar *force* nil) |
| 4114 |
(defvar *providing-blocks-load-propagation* t |
| 4115 |
"If T, if a system dependency exists on *modules*, it is not loaded.") |
| 4116 |
|
| 4117 |
(defun operate-on-system-dependencies (component operation &optional force) |
| 4118 |
(when *system-dependencies-delayed* |
| 4119 |
(let ((*force* force)) |
| 4120 |
(dolist (system (component-depends-on component)) |
| 4121 |
;; For each system that this system depends on, if it is a |
| 4122 |
;; defined system (either via defsystem or component type :system), |
| 4123 |
;; and propagation is turned on, propagates the operation to the |
| 4124 |
;; subsystem. Otherwise runs require (my version) on that system |
| 4125 |
;; to load it (needed since we may be depending on a lisp |
| 4126 |
;; dependent package). |
| 4127 |
;; Explores the system tree in a DFS manner. |
| 4128 |
|
| 4129 |
;; Do not try to do anything with non system components. |
| 4130 |
(cond ((and *operations-propagate-to-subsystems* |
| 4131 |
(not (listp system)) |
| 4132 |
(or (stringp system) (symbolp system)) |
| 4133 |
;; The subsystem is a defined system. |
| 4134 |
(find-system system :load-or-nil)) |
| 4135 |
;; Call OOS on it. Since *system-dependencies-delayed* is |
| 4136 |
;; T, the :depends-on slot is filled with the names of |
| 4137 |
;; systems, not defstructs. |
| 4138 |
;; Aside from system, operation, force, for everything else |
| 4139 |
;; we rely on the globals. |
| 4140 |
(unless (and *providing-blocks-load-propagation* |
| 4141 |
;; If *providing-blocks-load-propagation* is T, |
| 4142 |
;; the system dependency must not exist in the |
| 4143 |
;; *modules* for it to be loaded. Note that |
| 4144 |
;; the dependencies are implicitly systems. |
| 4145 |
(find operation '(load :load)) |
| 4146 |
;; (or (eq force :all) (eq force t)) |
| 4147 |
(find (canonicalize-system-name system) |
| 4148 |
*modules* :test #'string-equal)) |
| 4149 |
|
| 4150 |
(operate-on-system system operation :force force))) |
| 4151 |
|
| 4152 |
((listp system) |
| 4153 |
;; If the SYSTEM is a list then its contents are as follows. |
| 4154 |
;; |
| 4155 |
;; (<name> <definition-pathname> <action> &optional <version>) |
| 4156 |
;; |
| 4157 |
|
| 4158 |
(destructuring-bind (system-name definition-pathname action |
| 4159 |
&optional version) |
| 4160 |
system |
| 4161 |
(tell-user-require-system |
| 4162 |
(if (and (null system-name) |
| 4163 |
(null definition-pathname)) |
| 4164 |
action |
| 4165 |
system) |
| 4166 |
component) |
| 4167 |
(or *oos-test* (new-require system-name |
| 4168 |
nil |
| 4169 |
(eval definition-pathname) |
| 4170 |
action |
| 4171 |
(or version *version*))))) |
| 4172 |
((and (component-p system) |
| 4173 |
(not (member (component-type system) |
| 4174 |
'(:defsystem :subsystem :system)))) |
| 4175 |
;; Do nothing for non system components. |
| 4176 |
) |
| 4177 |
(t |
| 4178 |
(tell-user-require-system system component) |
| 4179 |
(or *oos-test* (new-require system)))) |
| 4180 |
)))) |
| 4181 |
|
| 4182 |
;;; Modules can depend only on siblings. If a module should depend |
| 4183 |
;;; on an uncle, then the parent module should depend on that uncle |
| 4184 |
;;; instead. Likewise a module should depend on a sibling, not a niece |
| 4185 |
;;; or nephew. Modules also cannot depend on cousins. Modules cannot |
| 4186 |
;;; depend on parents, since that is circular. |
| 4187 |
|
| 4188 |
(defun module-depends-on-changed (module changed) |
| 4189 |
(dolist (dependent (component-depends-on module)) |
| 4190 |
(when (member dependent changed) |
| 4191 |
(return t)))) |
| 4192 |
|
| 4193 |
(defun operate-on-components (component operation force changed) |
| 4194 |
(with-tell-user (operation component) |
| 4195 |
(if (component-components component) |
| 4196 |
(dolist (module (component-components component)) |
| 4197 |
(when (operate-on-component module operation |
| 4198 |
(cond ((and (module-depends-on-changed module changed) |
| 4199 |
#||(some #'(lambda (dependent) |
| 4200 |
(member dependent changed)) |
| 4201 |
(component-depends-on module))||# |
| 4202 |
(or (non-empty-listp force) |
| 4203 |
(eq force :new-source-and-dependents))) |
| 4204 |
;; The component depends on a changed file |
| 4205 |
;; and force agrees. |
| 4206 |
(if (eq force :new-source-and-dependents) |
| 4207 |
:new-source-all |
| 4208 |
:all)) |
| 4209 |
((and (non-empty-listp force) |
| 4210 |
(member (component-name module) force |
| 4211 |
:test #'string-equal :key #'string)) |
| 4212 |
;; Force is a list of modules |
| 4213 |
;; and the component is one of them. |
| 4214 |
:all) |
| 4215 |
(t force))) |
| 4216 |
(push module changed))) |
| 4217 |
(case operation |
| 4218 |
((compile :compile) |
| 4219 |
(with-special-component-vars (component) |
| 4220 |
(let ((compile-form (component-compile-form component))) |
| 4221 |
(if (functionp compile-form) |
| 4222 |
(funcall compile-form) |
| 4223 |
(eval compile-form))))) |
| 4224 |
((load :load) |
| 4225 |
(with-special-component-vars (component) |
| 4226 |
(let ((load-form (component-load-form component))) |
| 4227 |
(if (functionp load-form) |
| 4228 |
(funcall load-form) |
| 4229 |
(eval load-form))) |
| 4230 |
))))) |
| 4231 |
;; This is only used as a boolean. |
| 4232 |
changed) |
| 4233 |
|
| 4234 |
;;; ******************************** |
| 4235 |
;;; New Require ******************** |
| 4236 |
;;; ******************************** |
| 4237 |
|
| 4238 |
;;; This needs cleaning. Obviously the code is a left over from the |
| 4239 |
;;; time people did not know how to use packages in a proper way or |
| 4240 |
;;; CLs were shaky in their implementation. |
| 4241 |
|
| 4242 |
;;; First of all we need this. (Commented out for the time being) |
| 4243 |
;;; (shadow '(cl:require)) |
| 4244 |
|
| 4245 |
|
| 4246 |
(defvar *old-require* nil) |
| 4247 |
|
| 4248 |
;;; All calls to require in this file have been replaced with calls |
| 4249 |
;;; to new-require to avoid compiler warnings and make this less of |
| 4250 |
;;; a tangled mess. |
| 4251 |
|
| 4252 |
(defun new-require (module-name |
| 4253 |
&optional |
| 4254 |
pathname |
| 4255 |
definition-pname |
| 4256 |
default-action |
| 4257 |
(version *version*)) |
| 4258 |
;; If the pathname is present, this behaves like the old require. |
| 4259 |
(unless (and module-name |
| 4260 |
(find (string module-name) |
| 4261 |
*modules* :test #'string=)) |
| 4262 |
(handler-case |
| 4263 |
(cond (pathname |
| 4264 |
(funcall *old-require* module-name pathname)) |
| 4265 |
;; If the system is defined, load it. |
| 4266 |
((find-system module-name :load-or-nil definition-pname) |
| 4267 |
(operate-on-system |
| 4268 |
module-name :load |
| 4269 |
:force *force* |
| 4270 |
:version version |
| 4271 |
:test *oos-test* |
| 4272 |
:verbose *oos-verbose* |
| 4273 |
:load-source-if-no-binary *load-source-if-no-binary* |
| 4274 |
:bother-user-if-no-binary *bother-user-if-no-binary* |
| 4275 |
:compile-during-load *compile-during-load* |
| 4276 |
:load-source-instead-of-binary *load-source-instead-of-binary* |
| 4277 |
:minimal-load *minimal-load*)) |
| 4278 |
;; If there's a default action, do it. This could be a progn which |
| 4279 |
;; loads a file that does everything. |
| 4280 |
((and default-action |
| 4281 |
(eval default-action))) |
| 4282 |
;; If no system definition file, try regular require. |
| 4283 |
;; had last arg PATHNAME, but this wasn't really necessary. |
| 4284 |
((funcall *old-require* module-name)) |
| 4285 |
;; If no default action, print a warning or error message. |
| 4286 |
(t |
| 4287 |
#|| |
| 4288 |
(format t "~&Warning: System ~A doesn't seem to be defined..." |
| 4289 |
module-name) |
| 4290 |
||# |
| 4291 |
(error 'missing-system :name module-name))) |
| 4292 |
(missing-module (mmc) (signal mmc)) ; Resignal. |
| 4293 |
(error (e) |
| 4294 |
(declare (ignore e)) |
| 4295 |
;; Signal a (maybe wrong) MISSING-SYSTEM. |
| 4296 |
(error 'missing-system :name module-name))) |
| 4297 |
)) |
| 4298 |
|
| 4299 |
|
| 4300 |
;;; Note that in some lisps, when the compiler sees a REQUIRE form at |
| 4301 |
;;; top level it immediately executes it. This is as if an |
| 4302 |
;;; (eval-when (compile load eval) ...) were wrapped around the REQUIRE |
| 4303 |
;;; form. I don't see any easy way to do this without making REQUIRE |
| 4304 |
;;; a macro. |
| 4305 |
;;; |
| 4306 |
;;; For example, in VAXLisp, if a (require 'streams) form is at the top of |
| 4307 |
;;; a file in the system, compiling the system doesn't wind up loading the |
| 4308 |
;;; streams module. If the (require 'streams) form is included within an |
| 4309 |
;;; (eval-when (compile load eval) ...) then everything is OK. |
| 4310 |
;;; |
| 4311 |
;;; So perhaps we should replace the redefinition of lisp:require |
| 4312 |
;;; with the following macro definition: |
| 4313 |
#|| |
| 4314 |
(unless *old-require* |
| 4315 |
(setf *old-require* |
| 4316 |
(symbol-function #-(or :lispworks |
| 4317 |
:sbcl |
| 4318 |
(and :excl :allegro-v4.0)) 'lisp:require |
| 4319 |
#+:sbcl 'cl:require |
| 4320 |
#+:lispworks 'system:::require |
| 4321 |
#+(and :excl :allegro-v4.0) 'cltl1:require)) |
| 4322 |
|
| 4323 |
(let (#+:CCL (ccl:*warn-if-redefine-kernel* nil)) |
| 4324 |
;; Note that lots of lisps barf if we redefine a function from |
| 4325 |
;; the LISP package. So what we do is define a macro with an |
| 4326 |
;; unused name, and use (setf macro-function) to redefine |
| 4327 |
;; lisp:require without compiler warnings. If the lisp doesn't |
| 4328 |
;; do the right thing, try just replacing require-as-macro |
| 4329 |
;; with lisp:require. |
| 4330 |
(defmacro require-as-macro (module-name |
| 4331 |
&optional pathname definition-pname |
| 4332 |
default-action (version '*version*)) |
| 4333 |
`(eval-when (compile load eval) |
| 4334 |
(new-require ,module-name ,pathname ,definition-pname |
| 4335 |
,default-action ,version))) |
| 4336 |
(setf (macro-function #-(and :excl :sbcl :allegro-v4.0) 'lisp:require |
| 4337 |
#+:sbcl 'cl:require |
| 4338 |
#+(and :excl :allegro-v4.0) 'cltl1:require) |
| 4339 |
(macro-function 'require-as-macro)))) |
| 4340 |
||# |
| 4341 |
;;; This will almost certainly fix the problem, but will cause problems |
| 4342 |
;;; if anybody does a funcall on #'require. |
| 4343 |
|
| 4344 |
;;; Redefine old require to call the new require. |
| 4345 |
(eval-when #-(or :lucid) (:load-toplevel :execute) |
| 4346 |
#+(or :lucid) (load eval) |
| 4347 |
(unless *old-require* |
| 4348 |
(setf *old-require* |
| 4349 |
(symbol-function |
| 4350 |
#-(or (and :excl :allegro-v4.0) :mcl :sbcl :lispworks) 'common-lisp:require |
| 4351 |
#+(and :excl :allegro-v4.0) 'cltl1:require |
| 4352 |
#+:sbcl 'cl:require |
| 4353 |
#+:lispworks3.1 'common-lisp::require |
| 4354 |
#+(and :lispworks (not :lispworks3.1)) 'system::require |
| 4355 |
#+:openmcl 'cl:require |
| 4356 |
#+(and :mcl (not :openmcl)) 'ccl:require |
| 4357 |
)) |
| 4358 |
|
| 4359 |
(unless *dont-redefine-require* |
| 4360 |
(let (#+(or :mcl (and :CCL (not :lispworks))) |
| 4361 |
(ccl:*warn-if-redefine-kernel* nil)) |
| 4362 |
#-(or :ecl (and allegro-version>= (version>= 4 1)) :lispworks) |
| 4363 |
(setf (symbol-function |
| 4364 |
#-(or (and :excl :allegro-v4.0) :mcl :sbcl :lispworks) 'common-lisp:require |
| 4365 |
#+(and :excl :allegro-v4.0) 'cltl1:require |
| 4366 |
#+:lispworks3.1 'common-lisp::require |
| 4367 |
#+:sbcl 'cl:require |
| 4368 |
#+(and :lispworks (not :lispworks3.1)) 'system::require |
| 4369 |
#+:openmcl 'cl:require |
| 4370 |
#+(and :mcl (not :openmcl)) 'ccl:require |
| 4371 |
) |
| 4372 |
(symbol-function 'new-require)) |
| 4373 |
#+:ecl |
| 4374 |
(progn |
| 4375 |
(ext:package-lock "CL" nil) |
| 4376 |
(setf (symbol-function 'common-lisp:require) |
| 4377 |
(symbol-function 'new-require)) |
| 4378 |
(ext:package-lock "CL" t)) |
| 4379 |
#+:lispworks |
| 4380 |
(let ((warn-packs system::*packages-for-warn-on-redefinition*)) |
| 4381 |
(declare (special system::*packages-for-warn-on-redefinition*)) |
| 4382 |
(setq system::*packages-for-warn-on-redefinition* nil) |
| 4383 |
(setf (symbol-function |
| 4384 |
#+:lispworks3.1 'common-lisp::require |
| 4385 |
#-:lispworks3.1 'system::require |
| 4386 |
) |
| 4387 |
(symbol-function 'new-require)) |
| 4388 |
(setq system::*packages-for-warn-on-redefinition* warn-packs)) |
| 4389 |
#+(and allegro-version>= (version>= 4 1)) |
| 4390 |
(excl:without-package-locks |
| 4391 |
(setf (symbol-function 'common-lisp:require) |
| 4392 |
(symbol-function 'new-require)))))) |
| 4393 |
) |
| 4394 |
|
| 4395 |
|
| 4396 |
;;; Well, let's add some more REQUIRE hacking; specifically for SBCL, |
| 4397 |
;;; and, eventually, for CMUCL. |
| 4398 |
|
| 4399 |
#+sbcl |
| 4400 |
(eval-when (:compile-toplevel :load-toplevel :execute) |
| 4401 |
|
| 4402 |
(defun sbcl-mk-defsystem-module-provider (name) |
| 4403 |
;; Let's hope things go smoothly. |
| 4404 |
(let ((module-name (string-downcase (string name)))) |
| 4405 |
(when (mk:find-system module-name :load-or-nil) |
| 4406 |
(mk:load-system module-name |
| 4407 |
:compile-during-load t |
| 4408 |
:verbose nil)))) |
| 4409 |
|
| 4410 |
(pushnew 'sbcl-mk-defsystem-module-provider sb-ext:*module-provider-functions*) |
| 4411 |
) |
| 4412 |
|
| 4413 |
#+#.(cl:if (cl:and (cl:find-package "EXT") (cl:find-symbol "*MODULE-PROVIDER-FUNCTIONS*" "EXT")) '(and) '(or)) |
| 4414 |
(progn |
| 4415 |
(defun cmucl-mk-defsystem-module-provider (name) |
| 4416 |
(let ((module-name (string-downcase (string name)))) |
| 4417 |
(when (mk:find-system module-name :load-or-nil) |
| 4418 |
(mk:load-system module-name |
| 4419 |
:compile-during-load t |
| 4420 |
:verbose nil)))) |
| 4421 |
|
| 4422 |
(pushnew 'cmucl-mk-defsystem-module-provider ext:*module-provider-functions*) |
| 4423 |
) |
| 4424 |
|
| 4425 |
|
| 4426 |
|
| 4427 |
|
| 4428 |
;;; ******************************** |
| 4429 |
;;; Language-Dependent Characteristics |
| 4430 |
;;; ******************************** |
| 4431 |
;;; This section is used for defining language-specific behavior of |
| 4432 |
;;; defsystem. If the user changes a language definition, it should |
| 4433 |
;;; take effect immediately -- they shouldn't have to reload the |
| 4434 |
;;; system definition file for the changes to take effect. |
| 4435 |
|
| 4436 |
(defvar *language-table* (make-hash-table :test #'equal) |
| 4437 |
"Hash table that maps from languages to language structures.") |
| 4438 |
(defun find-language (name) |
| 4439 |
(gethash name *language-table*)) |
| 4440 |
|
| 4441 |
(defstruct (language (:print-function print-language)) |
| 4442 |
name ; The name of the language (a keyword) |
| 4443 |
compiler ; The function used to compile files in the language |
| 4444 |
loader ; The function used to load files in the language |
| 4445 |
source-extension ; Filename extensions for source files |
| 4446 |
binary-extension ; Filename extensions for binary files |
| 4447 |
) |
| 4448 |
|
| 4449 |
(defun print-language (language stream depth) |
| 4450 |
(declare (ignore depth)) |
| 4451 |
(format stream "#<~:@(~A~): ~A ~A>" |
| 4452 |
(language-name language) |
| 4453 |
(language-source-extension language) |
| 4454 |
(language-binary-extension language))) |
| 4455 |
|
| 4456 |
(defun compile-function (component) |
| 4457 |
(or (component-compiler component) |
| 4458 |
(let ((language (find-language (or (component-language component) |
| 4459 |
:lisp)))) |
| 4460 |
(when language (language-compiler language))) |
| 4461 |
#'compile-file)) |
| 4462 |
|
| 4463 |
(defun load-function (component) |
| 4464 |
(or (component-loader component) |
| 4465 |
(let ((language (find-language (or (component-language component) |
| 4466 |
:lisp)))) |
| 4467 |
(when language (language-loader language))) |
| 4468 |
#'load)) |
| 4469 |
|
| 4470 |
(defun default-source-extension (component) |
| 4471 |
(let ((language (find-language (or (component-language component) |
| 4472 |
:lisp)))) |
| 4473 |
(or (when language (language-source-extension language)) |
| 4474 |
(car *filename-extensions*)))) |
| 4475 |
|
| 4476 |
(defun default-binary-extension (component) |
| 4477 |
(let ((language (find-language (or (component-language component) |
| 4478 |
:lisp)))) |
| 4479 |
(or (when language (language-binary-extension language)) |
| 4480 |
(cdr *filename-extensions*)))) |
| 4481 |
|
| 4482 |
(defmacro define-language (name &key compiler loader |
| 4483 |
source-extension binary-extension) |
| 4484 |
(let ((language (gensym "LANGUAGE"))) |
| 4485 |
`(let ((,language (make-language :name ,name |
| 4486 |
:compiler ,compiler |
| 4487 |
:loader ,loader |
| 4488 |
:source-extension ,source-extension |
| 4489 |
:binary-extension ,binary-extension))) |
| 4490 |
(setf (gethash ,name *language-table*) ,language) |
| 4491 |
,name))) |
| 4492 |
|
| 4493 |
#|| |
| 4494 |
;;; Test System for verifying multi-language capabilities. |
| 4495 |
(defsystem foo |
| 4496 |
:language :lisp |
| 4497 |
:components ((:module c :language :c :components ("foo" "bar")) |
| 4498 |
(:module lisp :components ("baz" "barf")))) |
| 4499 |
|
| 4500 |
||# |
| 4501 |
|
| 4502 |
;;; *** Lisp Language Definition |
| 4503 |
(define-language :lisp |
| 4504 |
:compiler #'compile-file |
| 4505 |
:loader #'load |
| 4506 |
:source-extension (car *filename-extensions*) |
| 4507 |
:binary-extension (cdr *filename-extensions*)) |
| 4508 |
|
| 4509 |
;;; *** PseudoScheme Language Definition |
| 4510 |
(defun scheme-compile-file (filename &rest args) |
| 4511 |
(let ((scheme-package (find-package '#:scheme))) |
| 4512 |
(apply (symbol-function (find-symbol (symbol-name 'compile-file) |
| 4513 |
scheme-package)) |
| 4514 |
filename |
| 4515 |
(funcall (symbol-function |
| 4516 |
(find-symbol (symbol-name '#:interaction-environment) |
| 4517 |
scheme-package))) |
| 4518 |
args))) |
| 4519 |
|
| 4520 |
(define-language :scheme |
| 4521 |
:compiler #'scheme-compile-file |
| 4522 |
:loader #'load |
| 4523 |
:source-extension "scm" |
| 4524 |
:binary-extension "bin") |
| 4525 |
|
| 4526 |
;;; *** C Language Definition |
| 4527 |
|
| 4528 |
;;; This is very basic. Somebody else who needs it can add in support |
| 4529 |
;;; for header files, libraries, different C compilers, etc. For example, |
| 4530 |
;;; we might add a COMPILER-OPTIONS slot to the component defstruct. |
| 4531 |
|
| 4532 |
(defparameter *c-compiler* "gcc") |
| 4533 |
#-(or symbolics (and :lispworks :harlequin-pc-lisp )) |
| 4534 |
|
| 4535 |
(defun run-unix-program (program arguments) |
| 4536 |
;; arguments should be a list of strings, where each element is a |
| 4537 |
;; command-line option to send to the program. |
| 4538 |
#+:lucid (run-program program :arguments arguments) |
| 4539 |
#+:allegro (excl:run-shell-command |
| 4540 |
(format nil "~A~@[ ~{~A~^ ~}~]" |
| 4541 |
program arguments)) |
| 4542 |
#+(or :kcl :ecl) (system (format nil "~A~@[ ~{~A~^ ~}~]" program arguments)) |
| 4543 |
#+(or :cmu :scl) (extensions:run-program program arguments) |
| 4544 |
#+:openmcl (ccl:run-program program arguments) |
| 4545 |
#+:sbcl (sb-ext:run-program program arguments) |
| 4546 |
#+:lispworks (foreign:call-system-showing-output |
| 4547 |
(format nil "~A~@[ ~{~A~^ ~}~]" program arguments)) |
| 4548 |
#+clisp (#+lisp=cl ext:run-program #-lisp=cl common-lisp:run-program |
| 4549 |
program :arguments arguments) |
| 4550 |
) |
| 4551 |
|
| 4552 |
#+(or symbolics (and :lispworks :harlequin-pc-lisp)) |
| 4553 |
(defun run-unix-program (program arguments) |
| 4554 |
(declare (ignore program arguments)) |
| 4555 |
(error "MK::RUN-UNIX-PROGRAM: this does not seem to be a UN*X system.") |
| 4556 |
) |
| 4557 |
|
| 4558 |
|
| 4559 |
;;; This is inspired by various versions - all very UNIX/Linux |
| 4560 |
;;; dependent - appearing in ASDF and UFFI. The original versions and Copyrights |
| 4561 |
;;; are by Dan Barlow, Kevin Rosenberg and many others. |
| 4562 |
;;; This version should be more liberal. |
| 4563 |
|
| 4564 |
(defvar *default-shell* "/bin/sh") |
| 4565 |
|
| 4566 |
#+(or windows ms-windows win32) |
| 4567 |
(eval-when (:load-toplevel :execute) |
| 4568 |
;; Lets assume a "standard" Cygwin installation. |
| 4569 |
(if (probe-file (pathname "C:\\cygwin\\bin\\sh.exe")) |
| 4570 |
(setf *default-shell* "C:\\cygwin\\bin\\sh.exe") |
| 4571 |
(setf *default-shell* nil))) |
| 4572 |
|
| 4573 |
|
| 4574 |
(defun run-shell-command (command-control-string |
| 4575 |
arguments |
| 4576 |
&key |
| 4577 |
(output *trace-output*) |
| 4578 |
(shell *default-shell*) |
| 4579 |
) |
| 4580 |
"Executes a shell 'command' in an underlying process. |
| 4581 |
RUN-SHELL-COMMAND interpolate ARGS into CONTROL-STRING as if by FORMAT, and |
| 4582 |
synchronously execute the result using a Bourne-compatible shell, with |
| 4583 |
output to *trace-output*. Returns the shell's exit code." |
| 4584 |
|
| 4585 |
(declare (ignorable shell)) |
| 4586 |
|
| 4587 |
(let ((command (apply #'format nil command-control-string arguments))) |
| 4588 |
#+sbcl |
| 4589 |
(sb-impl::process-exit-code |
| 4590 |
(sb-ext:run-program shell |
| 4591 |
(list "-c" command) |
| 4592 |
:input nil |
| 4593 |
:output output)) |
| 4594 |
|
| 4595 |
#+(or cmu scl) |
| 4596 |
(ext:process-exit-code |
| 4597 |
(ext:run-program shell |
| 4598 |
(list "-c" command) |
| 4599 |
:input nil |
| 4600 |
:output output)) |
| 4601 |
|
| 4602 |
#+allegro |
| 4603 |
(excl:run-shell-command command :input nil :output output) |
| 4604 |
|
| 4605 |
#+(and lispworks win32) |
| 4606 |
(system:call-system-showing-output (format nil "cmd /c ~A" command) |
| 4607 |
:output-stream output) |
| 4608 |
|
| 4609 |
#+(and lispworks (not win32)) |
| 4610 |
(system:call-system-showing-output command |
| 4611 |
:shell-type shell |
| 4612 |
:output-stream output) |
| 4613 |
|
| 4614 |
#+clisp ;XXX not exactly *trace-output*, I know |
| 4615 |
(ext:run-shell-command command :output :terminal :wait t) |
| 4616 |
|
| 4617 |
#+openmcl |
| 4618 |
(nth-value 1 |
| 4619 |
(ccl:external-process-status |
| 4620 |
(ccl:run-program shell |
| 4621 |
(list "-c" command) |
| 4622 |
:input nil |
| 4623 |
:output output |
| 4624 |
:wait t))) |
| 4625 |
|
| 4626 |
#-(or openmcl clisp lispworks allegro scl cmu sbcl) |
| 4627 |
(error "RUN-SHELL-PROGRAM not implemented for this Lisp") |
| 4628 |
)) |
| 4629 |
|
| 4630 |
|
| 4631 |
#|| |
| 4632 |
(defun c-compile-file (filename &rest args &key output-file error-file) |
| 4633 |
;; gcc -c foo.c -o foo.o |
| 4634 |
(declare (ignore args)) |
| 4635 |
(run-unix-program *c-compiler* |
| 4636 |
(format nil "-c ~A~@[ -o ~A~]" |
| 4637 |
filename |
| 4638 |
output-file))) |
| 4639 |
||# |
| 4640 |
|
| 4641 |
#|| |
| 4642 |
(defun c-compile-file (filename &rest args &key output-file error-file) |
| 4643 |
;; gcc -c foo.c -o foo.o |
| 4644 |
(declare (ignore args error-file)) |
| 4645 |
(run-unix-program *c-compiler* |
| 4646 |
`("-c" ,filename ,@(if output-file `("-o" ,output-file))))) |
| 4647 |
||# |
| 4648 |
|
| 4649 |
|
| 4650 |
;;; The following code was inserted to improve C compiler support (at |
| 4651 |
;;; least under Linux/GCC). |
| 4652 |
;;; Thanks to Espen S Johnsen. |
| 4653 |
;;; |
| 4654 |
;;; 20001118 Marco Antoniotti. |
| 4655 |
|
| 4656 |
(defun default-output-pathname (path1 path2 type) |
| 4657 |
(if (eq path1 t) |
| 4658 |
(translate-logical-pathname |
| 4659 |
(merge-pathnames (make-pathname :type type) (pathname path2))) |
| 4660 |
(translate-logical-pathname (pathname path1)))) |
| 4661 |
|
| 4662 |
|
| 4663 |
(defun run-compiler (program |
| 4664 |
arguments |
| 4665 |
output-file |
| 4666 |
error-file |
| 4667 |
error-output |
| 4668 |
verbose) |
| 4669 |
#-(or cmu scl) (declare (ignore error-file error-output)) |
| 4670 |
|
| 4671 |
(flet ((make-useable-stream (&rest streams) |
| 4672 |
(apply #'make-broadcast-stream (delete nil streams))) |
| 4673 |
) |
| 4674 |
(let (#+(or cmu scl) (error-file error-file) |
| 4675 |
#+(or cmu scl) (error-file-stream nil) |
| 4676 |
(verbose-stream nil) |
| 4677 |
(old-timestamp (file-write-date output-file)) |
| 4678 |
(fatal-error nil) |
| 4679 |
(output-file-written nil) |
| 4680 |
) |
| 4681 |
(unwind-protect |
| 4682 |
(progn |
| 4683 |
#+(or cmu scl) |
| 4684 |
(setf error-file |
| 4685 |
(when error-file |
| 4686 |
(default-output-pathname error-file |
| 4687 |
output-file |
| 4688 |
*compile-error-file-type*)) |
| 4689 |
|
| 4690 |
error-file-stream |
| 4691 |
(and error-file |
| 4692 |
(open error-file |
| 4693 |
:direction :output |
| 4694 |
:if-exists :supersede))) |
| 4695 |
|
| 4696 |
(setf verbose-stream |
| 4697 |
(make-useable-stream |
| 4698 |
#+cmu error-file-stream |
| 4699 |
(and verbose *trace-output*))) |
| 4700 |
|
| 4701 |
(format verbose-stream "Running ~A~@[ ~{~A~^ ~}~]~%" |
| 4702 |
program |
| 4703 |
arguments) |
| 4704 |
|
| 4705 |
(setf fatal-error |
| 4706 |
#-(or cmu scl) |
| 4707 |
(and (run-unix-program program arguments) nil) ; Incomplete. |
| 4708 |
#+(or cmu scl) |
| 4709 |
(let* ((error-output |
| 4710 |
(make-useable-stream error-file-stream |
| 4711 |
(if (eq error-output t) |
| 4712 |
*error-output* |
| 4713 |
error-output))) |
| 4714 |
(process |
| 4715 |
(ext:run-program program arguments |
| 4716 |
:error error-output))) |
| 4717 |
(not (zerop (ext:process-exit-code process))))) |
| 4718 |
|
| 4719 |
(setf output-file-written |
| 4720 |
(and (probe-file output-file) |
| 4721 |
(not (eql old-timestamp |
| 4722 |
(file-write-date output-file))))) |
| 4723 |
|
| 4724 |
|
| 4725 |
(when output-file-written |
| 4726 |
(format verbose-stream "~A written~%" output-file)) |
| 4727 |
(format verbose-stream "Running of ~A finished~%" |
| 4728 |
program) |
| 4729 |
(values (and output-file-written output-file) |
| 4730 |
fatal-error |
| 4731 |
fatal-error)) |
| 4732 |
|
| 4733 |
#+(or cmu scl) |
| 4734 |
(when error-file |
| 4735 |
(close error-file-stream) |
| 4736 |
(unless (or fatal-error (not output-file-written)) |
| 4737 |
(delete-file error-file))) |
| 4738 |
|
| 4739 |
(values (and output-file-written output-file) |
| 4740 |
fatal-error |
| 4741 |
fatal-error))))) |
| 4742 |
|
| 4743 |
|
| 4744 |
;;; C Language definitions. |
| 4745 |
|
| 4746 |
(defun c-compile-file (filename &rest args |
| 4747 |
&key |
| 4748 |
(output-file t) |
| 4749 |
(error-file t) |
| 4750 |
(error-output t) |
| 4751 |
(verbose *compile-verbose*) |
| 4752 |
debug |
| 4753 |
link |
| 4754 |
optimize |
| 4755 |
cflags |
| 4756 |
definitions |
| 4757 |
include-paths |
| 4758 |
library-paths |
| 4759 |
libraries |
| 4760 |
(error t)) |
| 4761 |
(declare (ignore args)) |
| 4762 |
|
| 4763 |
(flet ((map-options (flag options &optional (func #'identity)) |
| 4764 |
(mapcar #'(lambda (option) |
| 4765 |
(format nil "~A~A" flag (funcall func option))) |
| 4766 |
options)) |
| 4767 |
) |
| 4768 |
(let* ((output-file (default-output-pathname output-file filename "o")) |
| 4769 |
(arguments |
| 4770 |
`(,@(when (not link) '("-c")) |
| 4771 |
,@(when debug '("-g")) |
| 4772 |
,@(when optimize (list (format nil "-O~D" optimize))) |
| 4773 |
,@cflags |
| 4774 |
,@(map-options |
| 4775 |
"-D" definitions |
| 4776 |
#'(lambda (definition) |
| 4777 |
(if (atom definition) |
| 4778 |
definition |
| 4779 |
(apply #'format nil "~A=~A" definition)))) |
| 4780 |
,@(map-options "-I" include-paths #'truename) |
| 4781 |
,(namestring (truename filename)) |
| 4782 |
"-o" |
| 4783 |
,(namestring (translate-logical-pathname output-file)) |
| 4784 |
,@(map-options "-L" library-paths #'truename) |
| 4785 |
,@(map-options "-l" libraries)))) |
| 4786 |
|
| 4787 |
(multiple-value-bind (output-file warnings fatal-errors) |
| 4788 |
(run-compiler *c-compiler* |
| 4789 |
arguments |
| 4790 |
output-file |
| 4791 |
error-file |
| 4792 |
error-output |
| 4793 |
verbose) |
| 4794 |
(if (and error (or (not output-file) fatal-errors)) |
| 4795 |
(error "Compilation failed") |
| 4796 |
(values output-file warnings fatal-errors)))))) |
| 4797 |
|
| 4798 |
|
| 4799 |
(define-language :c |
| 4800 |
:compiler #'c-compile-file |
| 4801 |
:loader #+:lucid #'load-foreign-files |
| 4802 |
#+:allegro #'load |
| 4803 |
#+(or :cmu :scl) #'alien:load-foreign |
| 4804 |
#+:sbcl #'sb-alien:load-foreign |
| 4805 |
#+(and :lispworks :unix (not :linux) (not :macosx)) #'link-load:read-foreign-modules |
| 4806 |
#+(and :lispworks :unix (or :linux :macosx)) #'fli:register-module |
| 4807 |
#+(and :lispworks :win32) #'fli:register-module |
| 4808 |
#+(or :ecl :gcl :kcl) #'load ; should be enough. |
| 4809 |
#-(or :lucid |
| 4810 |
:allegro |
| 4811 |
:cmu |
| 4812 |
:sbcl |
| 4813 |
:scl |
| 4814 |
:lispworks |
| 4815 |
:ecl :gcl :kcl) |
| 4816 |
(lambda (&rest args) |
| 4817 |
(declare (ignore args)) |
| 4818 |
(cerror "Continue returning NIL." |
| 4819 |
"Loader not defined for C foreign libraries in ~A ~A." |
| 4820 |
(lisp-implementation-type) |
| 4821 |
(lisp-implementation-version))) |
| 4822 |
:source-extension "c" |
| 4823 |
:binary-extension "o") |
| 4824 |
|
| 4825 |
|
| 4826 |
;;; Fortran Language definitions. |
| 4827 |
;;; From Matlisp. |
| 4828 |
|
| 4829 |
(export '(*fortran-compiler* *fortran-options*)) |
| 4830 |
|
| 4831 |
(defparameter *fortran-compiler* "g77") |
| 4832 |
(defparameter *fortran-options* '("-O")) |
| 4833 |
|
| 4834 |
(defun fortran-compile-file (filename &rest args |
| 4835 |
&key output-file error-file |
| 4836 |
&allow-other-keys) |
| 4837 |
(declare (ignore error-file args)) |
| 4838 |
(let ((arg-list |
| 4839 |
(append *fortran-options* |
| 4840 |
`("-c" ,filename ,@(if output-file `("-o" ,output-file)))))) |
| 4841 |
(run-unix-program *fortran-compiler* arg-list))) |
| 4842 |
|
| 4843 |
|
| 4844 |
(mk:define-language :fortran |
| 4845 |
:compiler #'fortran-compile-file |
| 4846 |
:loader #'identity |
| 4847 |
:source-extension "f" |
| 4848 |
:binary-extension "o") |
| 4849 |
|
| 4850 |
|
| 4851 |
;;; AR support. |
| 4852 |
;; How to create a library (archive) of object files |
| 4853 |
|
| 4854 |
(export '(*ar-program* build-lib)) |
| 4855 |
|
| 4856 |
(defparameter *ar-program* "ar") |
| 4857 |
|
| 4858 |
(defun build-lib (libname directory) |
| 4859 |
(let ((args (list "rv" (truename libname)))) |
| 4860 |
(format t ";;; Building archive ~A~%" libname) |
| 4861 |
(run-unix-program *ar-program* |
| 4862 |
(append args |
| 4863 |
(mapcar #'truename (directory directory)))))) |
| 4864 |
|
| 4865 |
|
| 4866 |
;;; ******************************** |
| 4867 |
;;; Component Operations *********** |
| 4868 |
;;; ******************************** |
| 4869 |
;;; Define :compile/compile and :load/load operations |
| 4870 |
(eval-when (:load-toplevel :execute) |
| 4871 |
(component-operation :compile 'compile-and-load-operation) |
| 4872 |
(component-operation 'compile 'compile-and-load-operation) |
| 4873 |
(component-operation :load 'load-file-operation) |
| 4874 |
(component-operation 'load 'load-file-operation) |
| 4875 |
) |
| 4876 |
|
| 4877 |
|
| 4878 |
(defun compile-and-load-operation (component force) |
| 4879 |
;; FORCE was CHANGED. this caused defsystem during compilation to only |
| 4880 |
;; load files that it immediately compiled. |
| 4881 |
(let ((changed (compile-file-operation component force))) |
| 4882 |
;; Return T if the file had to be recompiled and reloaded. |
| 4883 |
(if (and changed (component-compile-only component)) |
| 4884 |
;; For files which are :compile-only T, compiling the file |
| 4885 |
;; satisfies the need to load. |
| 4886 |
changed |
| 4887 |
;; If the file wasn't compiled, or :compile-only is nil, |
| 4888 |
;; check to see if it needs to be loaded. |
| 4889 |
(and (load-file-operation component force) ; FORCE was CHANGED ??? |
| 4890 |
changed)))) |
| 4891 |
|
| 4892 |
|
| 4893 |
(defun unmunge-lucid (namestring) |
| 4894 |
;; Lucid's implementation of COMPILE-FILE is non-standard, in that |
| 4895 |
;; when the :output-file is a relative pathname, it tries to munge |
| 4896 |
;; it with the directory of the source file. For example, |
| 4897 |
;; (compile-file "src/globals.lisp" :output-file "bin/globals.sbin") |
| 4898 |
;; tries to stick the file in "./src/bin/globals.sbin" instead of |
| 4899 |
;; "./bin/globals.sbin" like any normal lisp. This hack seems to fix the |
| 4900 |
;; problem. I wouldn't have expected this problem to occur with any |
| 4901 |
;; use of defsystem, but some defsystem users are depending on |
| 4902 |
;; using relative pathnames (at least three folks reported the problem). |
| 4903 |
(cond ((null-string namestring) namestring) |
| 4904 |
((char= (char namestring 0) #\/) |
| 4905 |
;; It's an absolute namestring |
| 4906 |
namestring) |
| 4907 |
(t |
| 4908 |
;; Ugly, but seems to fix the problem. |
| 4909 |
(concatenate 'string "./" namestring)))) |
| 4910 |
|
| 4911 |
#+gcl |
| 4912 |
(defun ensure-directories-exist (arg0 &key verbose) |
| 4913 |
(declare (ignore arg0 verbose)) |
| 4914 |
()) |
| 4915 |
|
| 4916 |
|
| 4917 |
(defun compile-file-operation (component force) |
| 4918 |
;; Returns T if the file had to be compiled. |
| 4919 |
(let ((must-compile |
| 4920 |
;; For files which are :load-only T, loading the file |
| 4921 |
;; satisfies the demand to recompile. |
| 4922 |
(and (null (component-load-only component)) ; not load-only |
| 4923 |
(or (find force '(:all :new-source-all t) :test #'eq) |
| 4924 |
(and (find force '(:new-source :new-source-and-dependents) |
| 4925 |
:test #'eq) |
| 4926 |
(needs-compilation component nil))))) |
| 4927 |
(source-pname (component-full-pathname component :source))) |
| 4928 |
|
| 4929 |
(cond ((and must-compile (probe-file source-pname)) |
| 4930 |
(with-tell-user ("Compiling source" component :source) |
| 4931 |
(let ((output-file |
| 4932 |
#+:lucid |
| 4933 |
(unmunge-lucid (component-full-pathname component |
| 4934 |
:binary)) |
| 4935 |
#-:lucid |
| 4936 |
(component-full-pathname component :binary))) |
| 4937 |
|
| 4938 |
;; make certain the directory we need to write to |
| 4939 |
;; exists [[email protected] 20001114] |
| 4940 |
;; Added PATHNAME-HOST following suggestion by John |
| 4941 |
;; DeSoi [[email protected] 20020529] |
| 4942 |
|
| 4943 |
(ensure-directories-exist |
| 4944 |
(make-pathname |
| 4945 |
:host (pathname-host output-file) |
| 4946 |
:directory (pathname-directory output-file))) |
| 4947 |
|
| 4948 |
(or *oos-test* |
| 4949 |
(apply (compile-function component) |
| 4950 |
source-pname |
| 4951 |
:output-file |
| 4952 |
output-file |
| 4953 |
|
| 4954 |
#+(or :cmu :scl) |
| 4955 |
:error-file |
| 4956 |
|
| 4957 |
#+(or :cmu :scl) |
| 4958 |
(and *cmu-errors-to-file* |
| 4959 |
(component-full-pathname component :error)) |
| 4960 |
|
| 4961 |
#+cmu |
| 4962 |
:error-output |
| 4963 |
#+cmu |
| 4964 |
*cmu-errors-to-terminal* |
| 4965 |
|
| 4966 |
(component-compiler-options component) |
| 4967 |
)))) |
| 4968 |
must-compile) |
| 4969 |
(must-compile |
| 4970 |
(tell-user "Source file not found. Not compiling" |
| 4971 |
component :source :no-dots :force) |
| 4972 |
nil) |
| 4973 |
(t nil)))) |
| 4974 |
|
| 4975 |
|
| 4976 |
;;; compiled-file-p -- |
| 4977 |
;;; See CLOCC/PORT/sys.lisp:compiled-file-p |
| 4978 |
|
| 4979 |
(eval-when (:load-toplevel :execute :compile-toplevel) |
| 4980 |
(when (find-package "PORT") |
| 4981 |
(import (find-symbol "COMPILED-FILE-P" "PORT")))) |
| 4982 |
|
| 4983 |
(unless (fboundp 'compiled-file-p) |
| 4984 |
(defun compiled-file-p (file-name) |
| 4985 |
"Return T if the FILE-NAME is a filename designator for a valid compiled. |
| 4986 |
Signal an error when it is not a filename designator. |
| 4987 |
Return NIL when the file does not exist, or is not readable, |
| 4988 |
or does not contain valid compiled code." |
| 4989 |
#+clisp |
| 4990 |
(with-open-file (in file-name :direction :input :if-does-not-exist nil) |
| 4991 |
(handler-bind ((error (lambda (c) (declare (ignore c)) |
| 4992 |
(return-from compiled-file-p nil)))) |
| 4993 |
(and in (char= #\( (peek-char nil in nil #\a)) |
| 4994 |
(let ((form (read in nil nil))) |
| 4995 |
(and (consp form) |
| 4996 |
(eq (car form) 'SYSTEM::VERSION) |
| 4997 |
(null (eval form))))))) |
| 4998 |
#-clisp (declare (ignorable file-name)) |
| 4999 |
#-clisp t)) |
| 5000 |
|
| 5001 |
|
| 5002 |
(defun needs-compilation (component force) |
| 5003 |
;; If there is no binary, or it is older than the source |
| 5004 |
;; file, then the component needs to be compiled. |
| 5005 |
;; Otherwise we only need to recompile if it depends on a file that changed. |
| 5006 |
(declare (ignore force)) |
| 5007 |
(let ((source-pname (component-full-pathname component :source)) |
| 5008 |
(binary-pname (component-full-pathname component :binary))) |
| 5009 |
(and |
| 5010 |
;; source must exist |
| 5011 |
(probe-file source-pname) |
| 5012 |
(or |
| 5013 |
;; We force recompilation. |
| 5014 |
#|(find force '(:all :new-source-all) :test #'eq)|# |
| 5015 |
;; no binary |
| 5016 |
(null (probe-file binary-pname)) |
| 5017 |
;; old binary |
| 5018 |
(< (file-write-date binary-pname) |
| 5019 |
(file-write-date source-pname)) |
| 5020 |
;; invalid binary |
| 5021 |
(not (compiled-file-p binary-pname)))))) |
| 5022 |
|
| 5023 |
|
| 5024 |
(defun needs-loading (component &optional (check-source t) (check-binary t)) |
| 5025 |
;; Compares the component's load-time against the file-write-date of |
| 5026 |
;; the files on disk. |
| 5027 |
(let ((load-time (component-load-time component)) |
| 5028 |
(source-pname (component-full-pathname component :source)) |
| 5029 |
(binary-pname (component-full-pathname component :binary))) |
| 5030 |
(or |
| 5031 |
#|| ISI Extension ||# |
| 5032 |
(component-load-always component) |
| 5033 |
|
| 5034 |
;; File never loaded. |
| 5035 |
(null load-time) |
| 5036 |
;; Binary is newer. |
| 5037 |
(when (and check-binary |
| 5038 |
(probe-file binary-pname)) |
| 5039 |
(< load-time |
| 5040 |
(file-write-date binary-pname))) |
| 5041 |
;; Source is newer. |
| 5042 |
(when (and check-source |
| 5043 |
(probe-file source-pname)) |
| 5044 |
(< load-time |
| 5045 |
(file-write-date source-pname)))))) |
| 5046 |
|
| 5047 |
;;; Need to completely rework this function... |
| 5048 |
(defun load-file-operation (component force) |
| 5049 |
;; Returns T if the file had to be loaded |
| 5050 |
(let* ((binary-pname (component-full-pathname component :binary)) |
| 5051 |
(source-pname (component-full-pathname component :source)) |
| 5052 |
(binary-exists (probe-file binary-pname)) |
| 5053 |
(source-exists (probe-file source-pname)) |
| 5054 |
(source-needs-loading (needs-loading component t nil)) |
| 5055 |
(binary-needs-loading (needs-loading component nil t)) |
| 5056 |
;; needs-compilation has an implicit source-exists in it. |
| 5057 |
(needs-compilation (if (component-load-only component) |
| 5058 |
source-needs-loading |
| 5059 |
(needs-compilation component force))) |
| 5060 |
(check-for-new-source |
| 5061 |
;; If force is :new-source*, we're checking for files |
| 5062 |
;; whose source is newer than the compiled versions. |
| 5063 |
(find force '(:new-source :new-source-and-dependents :new-source-all) |
| 5064 |
:test #'eq)) |
| 5065 |
(load-binary (or (find force '(:all :new-source-all t) :test #'eq) |
| 5066 |
binary-needs-loading)) |
| 5067 |
(load-source |
| 5068 |
(or *load-source-instead-of-binary* |
| 5069 |
(and load-binary (component-load-only component)) |
| 5070 |
(and check-for-new-source needs-compilation))) |
| 5071 |
(compile-and-load |
| 5072 |
(and needs-compilation |
| 5073 |
(or load-binary check-for-new-source) |
| 5074 |
(compile-and-load-source-if-no-binary component))) |
| 5075 |
) |
| 5076 |
;; When we're trying to minimize the files loaded to only those |
| 5077 |
;; that need be, restrict the values of load-source and load-binary |
| 5078 |
;; so that we only load the component if the files are newer than |
| 5079 |
;; the load-time. |
| 5080 |
(when (and *minimal-load* |
| 5081 |
(not (find force '(:all :new-source-all) |
| 5082 |
:test #'eq))) |
| 5083 |
(when load-source (setf load-source source-needs-loading)) |
| 5084 |
(when load-binary (setf load-binary binary-needs-loading))) |
| 5085 |
|
| 5086 |
(when (or load-source load-binary compile-and-load) |
| 5087 |
(cond (compile-and-load |
| 5088 |
;; If we're loading the binary and it is old or nonexistent, |
| 5089 |
;; and the user says yes, compile and load the source. |
| 5090 |
(compile-file-operation component t) |
| 5091 |
(with-tell-user ("Loading binary" component :binary) |
| 5092 |
(or *oos-test* |
| 5093 |
(progn |
| 5094 |
(funcall (load-function component) binary-pname) |
| 5095 |
(setf (component-load-time component) |
| 5096 |
(file-write-date binary-pname))))) |
| 5097 |
t) |
| 5098 |
((and source-exists |
| 5099 |
(or (and load-source ; implicit needs-comp... |
| 5100 |
(or *load-source-instead-of-binary* |
| 5101 |
(component-load-only component) |
| 5102 |
(not *compile-during-load*))) |
| 5103 |
(and load-binary |
| 5104 |
(not binary-exists) |
| 5105 |
(load-source-if-no-binary component)))) |
| 5106 |
;; Load the source if the source exists and: |
| 5107 |
;; o we're loading binary and it doesn't exist |
| 5108 |
;; o we're forcing it |
| 5109 |
;; o we're loading new source and user wasn't asked to compile |
| 5110 |
(with-tell-user ("Loading source" component :source) |
| 5111 |
(or *oos-test* |
| 5112 |
(progn |
| 5113 |
(funcall (load-function component) source-pname) |
| 5114 |
(setf (component-load-time component) |
| 5115 |
(file-write-date source-pname))))) |
| 5116 |
t) |
| 5117 |
((and binary-exists load-binary) |
| 5118 |
(with-tell-user ("Loading binary" component :binary) |
| 5119 |
(or *oos-test* |
| 5120 |
(progn |
| 5121 |
(funcall (load-function component) binary-pname) |
| 5122 |
(setf (component-load-time component) |
| 5123 |
(file-write-date binary-pname))))) |
| 5124 |
t) |
| 5125 |
((and (not binary-exists) (not source-exists)) |
| 5126 |
(tell-user-no-files component :force) |
| 5127 |
(when *files-missing-is-an-error* |
| 5128 |
(cerror "Continue, ignoring missing files." |
| 5129 |
"~&Source file ~S ~:[and binary file ~S ~;~]do not exist." |
| 5130 |
source-pname |
| 5131 |
(or *load-source-if-no-binary* |
| 5132 |
*load-source-instead-of-binary*) |
| 5133 |
binary-pname)) |
| 5134 |
nil) |
| 5135 |
(t |
| 5136 |
nil))))) |
| 5137 |
|
| 5138 |
(eval-when (load eval) |
| 5139 |
(component-operation :clean 'delete-binaries-operation) |
| 5140 |
(component-operation 'clean 'delete-binaries-operation) |
| 5141 |
(component-operation :delete-binaries 'delete-binaries-operation) |
| 5142 |
(component-operation 'delete-binaries 'delete-binaries-operation) |
| 5143 |
) |
| 5144 |
(defun delete-binaries-operation (component force) |
| 5145 |
(when (or (eq force :all) |
| 5146 |
(eq force t) |
| 5147 |
(and (find force '(:new-source :new-source-and-dependents |
| 5148 |
:new-source-all) |
| 5149 |
:test #'eq) |
| 5150 |
(needs-compilation component nil))) |
| 5151 |
(let ((binary-pname (component-full-pathname component :binary))) |
| 5152 |
(when (probe-file binary-pname) |
| 5153 |
(with-tell-user ("Deleting binary" component :binary) |
| 5154 |
(or *oos-test* |
| 5155 |
(delete-file binary-pname))))))) |
| 5156 |
|
| 5157 |
|
| 5158 |
;; when the operation = :compile, we can assume the binary exists in test mode. |
| 5159 |
;; ((and *oos-test* |
| 5160 |
;; (eq operation :compile) |
| 5161 |
;; (probe-file (component-full-pathname component :source))) |
| 5162 |
;; (with-tell-user ("Loading binary" component :binary))) |
| 5163 |
|
| 5164 |
(defun binary-exists (component) |
| 5165 |
(probe-file (component-full-pathname component :binary))) |
| 5166 |
|
| 5167 |
;;; or old-binary |
| 5168 |
(defun compile-and-load-source-if-no-binary (component) |
| 5169 |
(when (not (or *load-source-instead-of-binary* |
| 5170 |
(and *load-source-if-no-binary* |
| 5171 |
(not (binary-exists component))))) |
| 5172 |
(cond ((component-load-only component) |
| 5173 |
#|| |
| 5174 |
(let ((prompt (prompt-string component))) |
| 5175 |
(format t "~A- File ~A is load-only, ~ |
| 5176 |
~&~A not compiling." |
| 5177 |
prompt |
| 5178 |
(component-full-pathname component :source) |
| 5179 |
prompt)) |
| 5180 |
||# |
| 5181 |
nil) |
| 5182 |
((eq *compile-during-load* :query) |
| 5183 |
(let* ((prompt (prompt-string component)) |
| 5184 |
(compile-source |
| 5185 |
(y-or-n-p-wait |
| 5186 |
#\y 30 |
| 5187 |
"~A- Binary file ~A is old or does not exist. ~ |
| 5188 |
~&~A Compile (and load) source file ~A instead? " |
| 5189 |
prompt |
| 5190 |
(component-full-pathname component :binary) |
| 5191 |
prompt |
| 5192 |
(component-full-pathname component :source)))) |
| 5193 |
(unless (y-or-n-p-wait |
| 5194 |
#\y 30 |
| 5195 |
"~A- Should I bother you if this happens again? " |
| 5196 |
prompt) |
| 5197 |
(setq *compile-during-load* |
| 5198 |
(y-or-n-p-wait |
| 5199 |
#\y 30 |
| 5200 |
"~A- Should I compile while loading the system? " |
| 5201 |
prompt))) ; was compile-source, then t |
| 5202 |
compile-source)) |
| 5203 |
(*compile-during-load*) |
| 5204 |
(t nil)))) |
| 5205 |
|
| 5206 |
(defun load-source-if-no-binary (component) |
| 5207 |
(and (not *load-source-instead-of-binary*) |
| 5208 |
(or (and *load-source-if-no-binary* |
| 5209 |
(not (binary-exists component))) |
| 5210 |
(component-load-only component) |
| 5211 |
(when *bother-user-if-no-binary* |
| 5212 |
(let* ((prompt (prompt-string component)) |
| 5213 |
(load-source |
| 5214 |
(y-or-n-p-wait #\y 30 |
| 5215 |
"~A- Binary file ~A does not exist. ~ |
| 5216 |
~&~A Load source file ~A instead? " |
| 5217 |
prompt |
| 5218 |
(component-full-pathname component :binary) |
| 5219 |
prompt |
| 5220 |
(component-full-pathname component :source)))) |
| 5221 |
(setq *bother-user-if-no-binary* |
| 5222 |
(y-or-n-p-wait #\n 30 |
| 5223 |
"~A- Should I bother you if this happens again? " |
| 5224 |
prompt )) |
| 5225 |
(unless *bother-user-if-no-binary* |
| 5226 |
(setq *load-source-if-no-binary* load-source)) |
| 5227 |
load-source))))) |
| 5228 |
|
| 5229 |
;;; ******************************** |
| 5230 |
;;; Allegro Toplevel Commands ****** |
| 5231 |
;;; ******************************** |
| 5232 |
;;; Creates toplevel command aliases for Allegro CL. |
| 5233 |
#+:allegro |
| 5234 |
(top-level:alias ("compile-system" 8) |
| 5235 |
(system &key force (minimal-load mk:*minimal-load*) |
| 5236 |
test verbose version) |
| 5237 |
"Compile the specified system" |
| 5238 |
|
| 5239 |
(mk:compile-system system :force force |
| 5240 |
:minimal-load minimal-load |
| 5241 |
:test test :verbose verbose |
| 5242 |
:version version)) |
| 5243 |
|
| 5244 |
#+:allegro |
| 5245 |
(top-level:alias ("load-system" 5) |
| 5246 |
(system &key force (minimal-load mk:*minimal-load*) |
| 5247 |
(compile-during-load mk:*compile-during-load*) |
| 5248 |
test verbose version) |
| 5249 |
"Compile the specified system" |
| 5250 |
|
| 5251 |
(mk:load-system system :force force |
| 5252 |
:minimal-load minimal-load |
| 5253 |
:compile-during-load compile-during-load |
| 5254 |
:test test :verbose verbose |
| 5255 |
:version version)) |
| 5256 |
|
| 5257 |
#+:allegro |
| 5258 |
(top-level:alias ("show-system" 5) (system) |
| 5259 |
"Show information about the specified system." |
| 5260 |
|
| 5261 |
(mk:describe-system system)) |
| 5262 |
|
| 5263 |
#+:allegro |
| 5264 |
(top-level:alias ("describe-system" 9) (system) |
| 5265 |
"Show information about the specified system." |
| 5266 |
|
| 5267 |
(mk:describe-system system)) |
| 5268 |
|
| 5269 |
#+:allegro |
| 5270 |
(top-level:alias ("system-source-size" 9) (system) |
| 5271 |
"Show size information about source files in the specified system." |
| 5272 |
|
| 5273 |
(mk:system-source-size system)) |
| 5274 |
|
| 5275 |
#+:allegro |
| 5276 |
(top-level:alias ("clean-system" 6) |
| 5277 |
(system &key force test verbose version) |
| 5278 |
"Delete binaries in the specified system." |
| 5279 |
|
| 5280 |
(mk:clean-system system :force force |
| 5281 |
:test test :verbose verbose |
| 5282 |
:version version)) |
| 5283 |
|
| 5284 |
#+:allegro |
| 5285 |
(top-level:alias ("edit-system" 7) |
| 5286 |
(system &key force test verbose version) |
| 5287 |
"Load system source files into Emacs." |
| 5288 |
|
| 5289 |
(mk:edit-system system :force force |
| 5290 |
:test test :verbose verbose |
| 5291 |
:version version)) |
| 5292 |
|
| 5293 |
#+:allegro |
| 5294 |
(top-level:alias ("hardcopy-system" 9) |
| 5295 |
(system &key force test verbose version) |
| 5296 |
"Hardcopy files in the specified system." |
| 5297 |
|
| 5298 |
(mk:hardcopy-system system :force force |
| 5299 |
:test test :verbose verbose |
| 5300 |
:version version)) |
| 5301 |
|
| 5302 |
#+:allegro |
| 5303 |
(top-level:alias ("make-system-tag-table" 13) (system) |
| 5304 |
"Make an Emacs TAGS file for source files in specified system." |
| 5305 |
|
| 5306 |
(mk:make-system-tag-table system)) |
| 5307 |
|
| 5308 |
|
| 5309 |
;;; ******************************** |
| 5310 |
;;; Allegro Make System Fasl ******* |
| 5311 |
;;; ******************************** |
| 5312 |
#+:excl |
| 5313 |
(defun allegro-make-system-fasl (system destination |
| 5314 |
&optional (include-dependents t)) |
| 5315 |
(excl:shell |
| 5316 |
(format nil "rm -f ~A; cat~{ ~A~} > ~A" |
| 5317 |
destination |
| 5318 |
(if include-dependents |
| 5319 |
(files-in-system-and-dependents system :all :binary) |
| 5320 |
(files-in-system system :all :binary)) |
| 5321 |
destination))) |
| 5322 |
|
| 5323 |
(defun files-which-need-compilation (system) |
| 5324 |
(mapcar #'(lambda (comp) (component-full-pathname comp :source)) |
| 5325 |
(remove nil |
| 5326 |
(file-components-in-component |
| 5327 |
(find-system system :load) :new-source)))) |
| 5328 |
|
| 5329 |
(defun files-in-system-and-dependents (name &optional (force :all) |
| 5330 |
(type :source) version) |
| 5331 |
;; Returns a list of the pathnames in system and dependents in load order. |
| 5332 |
(let ((system (find-system name :load))) |
| 5333 |
(multiple-value-bind (*version-dir* *version-replace*) |
| 5334 |
(translate-version version) |
| 5335 |
(let ((*version* version)) |
| 5336 |
(let ((result (file-pathnames-in-component system type force))) |
| 5337 |
(dolist (dependent (reverse (component-depends-on system))) |
| 5338 |
(setq result |
| 5339 |
(append (files-in-system-and-dependents dependent |
| 5340 |
force type version) |
| 5341 |
result))) |
| 5342 |
result))))) |
| 5343 |
|
| 5344 |
(defun files-in-system (name &optional (force :all) (type :source) version) |
| 5345 |
;; Returns a list of the pathnames in system in load order. |
| 5346 |
(let ((system (if (and (component-p name) |
| 5347 |
(member (component-type name) '(:defsystem :system :subsystem))) |
| 5348 |
name |
| 5349 |
(find-system name :load)))) |
| 5350 |
(multiple-value-bind (*version-dir* *version-replace*) |
| 5351 |
(translate-version version) |
| 5352 |
(let ((*version* version)) |
| 5353 |
(file-pathnames-in-component system type force))))) |
| 5354 |
|
| 5355 |
(defun file-pathnames-in-component (component type &optional (force :all)) |
| 5356 |
(mapcar #'(lambda (comp) (component-full-pathname comp type)) |
| 5357 |
(file-components-in-component component force))) |
| 5358 |
|
| 5359 |
(defun file-components-in-component (component &optional (force :all) |
| 5360 |
&aux result changed) |
| 5361 |
(case (component-type component) |
| 5362 |
((:file :private-file) |
| 5363 |
(when (setq changed |
| 5364 |
(or (find force '(:all t) :test #'eq) |
| 5365 |
(and (not (non-empty-listp force)) |
| 5366 |
(needs-compilation component nil)))) |
| 5367 |
(setq result |
| 5368 |
(list component)))) |
| 5369 |
((:module :system :subsystem :defsystem) |
| 5370 |
(dolist (module (component-components component)) |
| 5371 |
(multiple-value-bind (r c) |
| 5372 |
(file-components-in-component |
| 5373 |
module |
| 5374 |
(cond ((and (some #'(lambda (dependent) |
| 5375 |
(member dependent changed)) |
| 5376 |
(component-depends-on module)) |
| 5377 |
(or (non-empty-listp force) |
| 5378 |
(eq force :new-source-and-dependents))) |
| 5379 |
;; The component depends on a changed file and force agrees. |
| 5380 |
:all) |
| 5381 |
((and (non-empty-listp force) |
| 5382 |
(member (component-name module) force |
| 5383 |
:test #'string-equal :key #'string)) |
| 5384 |
;; Force is a list of modules and the component is |
| 5385 |
;; one of them. |
| 5386 |
:all) |
| 5387 |
(t force))) |
| 5388 |
(when c |
| 5389 |
(push module changed) |
| 5390 |
(setq result (append result r))))))) |
| 5391 |
(values result changed)) |
| 5392 |
|
| 5393 |
(setf (symbol-function 'oos) (symbol-function 'operate-on-system)) |
| 5394 |
|
| 5395 |
;;; ******************************** |
| 5396 |
;;; Additional Component Operations |
| 5397 |
;;; ******************************** |
| 5398 |
|
| 5399 |
;;; *** Edit Operation *** |
| 5400 |
|
| 5401 |
;;; Should this conditionalization be (or :mcl (and :CCL (not :lispworks)))? |
| 5402 |
#| |
| 5403 |
#+:ccl |
| 5404 |
(defun edit-operation (component force) |
| 5405 |
"Always returns nil, i.e. component not changed." |
| 5406 |
(declare (ignore force)) |
| 5407 |
;; |
| 5408 |
(let* ((full-pathname (make::component-full-pathname component :source)) |
| 5409 |
(already-editing\? #+:mcl (dolist (w (CCL:windows :class |
| 5410 |
'fred-window)) |
| 5411 |
(when (equal (CCL:window-filename w) |
| 5412 |
full-pathname) |
| 5413 |
(return w))) |
| 5414 |
#-:mcl nil)) |
| 5415 |
(if already-editing\? |
| 5416 |
#+:mcl (CCL:window-select already-editing\?) #-:mcl nil |
| 5417 |
(ed full-pathname))) |
| 5418 |
nil) |
| 5419 |
|
| 5420 |
#+:allegro |
| 5421 |
(defun edit-operation (component force) |
| 5422 |
"Edit a component - always returns nil, i.e. component not changed." |
| 5423 |
(declare (ignore force)) |
| 5424 |
(let ((full-pathname (component-full-pathname component :source))) |
| 5425 |
(ed full-pathname)) |
| 5426 |
nil) |
| 5427 |
|
| 5428 |
#+(or :ccl :allegro) |
| 5429 |
(make::component-operation :edit 'edit-operation) |
| 5430 |
#+(or :ccl :allegro) |
| 5431 |
(make::component-operation 'edit 'edit-operation) |
| 5432 |
|# |
| 5433 |
|
| 5434 |
;;; *** Hardcopy System *** |
| 5435 |
(defparameter *print-command* "enscript -2Gr" ; "lpr" |
| 5436 |
"Command to use for printing files on UNIX systems.") |
| 5437 |
#+:allegro |
| 5438 |
(defun hardcopy-operation (component force) |
| 5439 |
"Hardcopy a component - always returns nil, i.e. component not changed." |
| 5440 |
(declare (ignore force)) |
| 5441 |
(let ((full-pathname (component-full-pathname component :source))) |
| 5442 |
(excl:run-shell-command (format nil "~A ~A" |
| 5443 |
*print-command* full-pathname))) |
| 5444 |
nil) |
| 5445 |
|
| 5446 |
#+:allegro |
| 5447 |
(make::component-operation :hardcopy 'hardcopy-operation) |
| 5448 |
#+:allegro |
| 5449 |
(make::component-operation 'hardcopy 'hardcopy-operation) |
| 5450 |
|
| 5451 |
|
| 5452 |
;;; *** System Source Size *** |
| 5453 |
|
| 5454 |
(defun system-source-size (system-name &optional (force :all)) |
| 5455 |
"Prints a short report and returns the size in bytes of the source files in |
| 5456 |
<system-name>." |
| 5457 |
(let* ((file-list (files-in-system system-name force :source)) |
| 5458 |
(total-size (file-list-size file-list))) |
| 5459 |
(format t "~&~a/~a (~:d file~:p) totals ~:d byte~:p (~:d kB)" |
| 5460 |
system-name force (length file-list) |
| 5461 |
total-size (round total-size 1024)) |
| 5462 |
total-size)) |
| 5463 |
|
| 5464 |
(defun file-list-size (file-list) |
| 5465 |
"Returns the size in bytes of the files in <file-list>." |
| 5466 |
;; |
| 5467 |
(let ((total-size 0)) |
| 5468 |
(dolist (file file-list) |
| 5469 |
(with-open-file (stream file) |
| 5470 |
(incf total-size (file-length stream)))) |
| 5471 |
total-size)) |
| 5472 |
|
| 5473 |
;;; *** System Tag Table *** |
| 5474 |
|
| 5475 |
#+:allegro |
| 5476 |
(defun make-system-tag-table (system-name) |
| 5477 |
"Makes an Emacs tag table using the GNU etags program." |
| 5478 |
(let ((files-in-system (files-in-system system-name :all :source))) |
| 5479 |
|
| 5480 |
(format t "~&Making tag table...") |
| 5481 |
(excl:run-shell-command (format nil "etags ~{~a ~}" files-in-system)) |
| 5482 |
(format t "done.~%"))) |
| 5483 |
|
| 5484 |
|
| 5485 |
;;; end of file -- defsystem.lisp -- |