[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Where do .fasl files live?
In article <9111041857.AA06503@media-lab.media.mit.edu> lieber@media-lab.media.mit.edu (Henry Lieberman) writes:
>I've often wanted the following convention for fasl files:
>
>Every folder with source code also contains a subfolder named "Fasl"
>which holds fasl files for that folder. The convention of adding a
>".fasl" file to the same directory seems like a holdover from the days
>where some file systems were not hierarchical. The convention of
>having a separate folder for compiled files works out much better with
>the Mac's finder, especially if you, as I do, habitually use the By
>Icon view. Even in the By Name view, a list of file names becomes
>twice as long if it includes the fasl files, and you do not always
>want to see this information. It is easy enough to side-by-side the
>views if you want to see what source files have not been compiled or
>something like that.
The following utility does some of what you want.
It does not supplant the behaviors of both LOAD
and REQUIRE, but might be a reasonable starting point
for you.
COMPILE-AND-LOAD takes a file name as an argument.
If the file is a lisp source file it compiles
the file and stores the .fasl file in a "fasls"
subdirectory, creating it if necessary. It also
moves pre-existing fasl files into the subdirectory
so you don't have to. It then loads the fasl file.
Additionally, COMPILE-AND-LOAD checks whether there
is already a current .fasl file, loading it if there
is. You can override this behavior and force
recompilation by setting the global variable
*compile-all* to a non-NIL value.
(defvar *compile-all* nil)
(defun compile-and-load (filename)
(let* ((file (purify-filename filename))
(source (concatenate 'simple-string
file
".lisp"))
(fasl-folder (concatenate 'simple-string
(directory-namestring filename)
"fasls:"))
(fasl-artifact (concatenate 'simple-string
file
".fasl"))
t)
(delete-file fasl-artifact))
(when (or *compile-all*
(not (probe-file fasl))
(< (file-write-date fasl)
(file-write-date source)))
(and (not (probe-file fasl-folder))
(probe-file source)
(create-file fasl-folder))
(set-mini-buffer *top-listener* "Recompiling ~A..."
(pathname-name source))
(compile-file source :output-file fasl :verbose t)
(set-mini-buffer *top-listener* ""))
mestring fname))
(filename (pathname-name fname))
(filetype (pathname-type fname)))
(if (null filetype)
fname
(if (or (string= filetype "fasl")
(string= filetype "lisp"))
(concatenate 'simple-string
directory-path
filename)
(error "The pathname ~S specifies an alien file type;~%Use a file with extension '.fasl' or '.lisp'.")))))
(defun get-path-from-user ()
(make-pathname
:directory (pathname-directory (choose-file-dialog))))