|
32 | 32 | (in-package #:quicklisp-client) |
33 | 33 |
|
34 | 34 | (defparameter *local-projects-directory* |
35 | | - (qmerge "local-projects/")) |
| 35 | + (qmerge "local-projects/") |
| 36 | + "The default local projects directory.") |
36 | 37 |
|
37 | 38 | (defun system-index-file (pathname) |
| 39 | + "Return the system index file for the directory PATHNAME." |
38 | 40 | (merge-pathnames "system-index.txt" pathname)) |
39 | 41 |
|
40 | 42 | (defun local-project-system-files (pathname) |
| 43 | + "Return a list of system files under PATHNAME." |
41 | 44 | (let ((wild (merge-pathnames "**/*.asd" pathname))) |
42 | 45 | (sort (directory wild) |
43 | 46 | #'< |
44 | 47 | :key (lambda (file) |
45 | 48 | (length (namestring file)))))) |
46 | 49 |
|
47 | 50 | (defun make-system-index (pathname) |
| 51 | + "Create a system index file for all system files under |
| 52 | +PATHNAME. Current format is one native namestring per line." |
48 | 53 | (with-open-file (stream (system-index-file pathname) |
49 | 54 | :direction :output |
50 | 55 | :if-exists :rename-and-delete) |
|
53 | 58 | (probe-file stream))) |
54 | 59 |
|
55 | 60 | (defun find-valid-system-index (pathname) |
| 61 | + "Find a valid system index file for PATHNAME; one that both exists |
| 62 | +and has a newer timestamp than PATHNAME." |
56 | 63 | (let* ((file (system-index-file pathname)) |
57 | 64 | (probed (probe-file file))) |
58 | 65 | (when (and probed |
59 | 66 | (<= (directory-write-date pathname) |
60 | | - (directory-write-date probed))) |
| 67 | + (file-write-date probed))) |
61 | 68 | probed))) |
62 | 69 |
|
63 | 70 | (defun ensure-system-index (pathname) |
| 71 | + "Find or create a system index file for PATHNAME." |
64 | 72 | (or (find-valid-system-index pathname) |
65 | 73 | (make-system-index pathname))) |
66 | 74 |
|
67 | 75 | (defun find-system-in-index (system index-file) |
| 76 | + "If any system pathname in INDEX-FILE has a pathname-name matching |
| 77 | +SYSTEM, return its full pathname." |
68 | 78 | (with-open-file (stream index-file) |
69 | 79 | (loop for namestring = (read-line stream nil) |
70 | 80 | while namestring |
71 | 81 | when (string= system (pathname-name namestring)) |
72 | 82 | return (truename namestring)))) |
73 | 83 |
|
74 | 84 | (defun local-projects-searcher (system-name) |
| 85 | + "This function is added to ASDF:*SYSTEM-DEFINITION-SEARCH-FUNCTIONS* |
| 86 | +to use the local project directory and cache to find systems." |
75 | 87 | (when (probe-directory *local-projects-directory*) |
76 | 88 | (let ((system-index (ensure-system-index *local-projects-directory*))) |
77 | 89 | (when system-index |
|
0 commit comments