428
|
1 ;;; make-docfile.el --- Cache docstrings in external file
|
|
2
|
|
3 ;; Copyright (C) 1985, 1986, 1992-1995, 1997 Free Software Foundation, Inc.
|
1303
|
4 ;; Copyright (C) 2002, 2003 Ben Wing.
|
428
|
5
|
|
6 ;; Author: Unknown
|
|
7 ;; Maintainer: Steven L Baur <steve@xemacs.org>
|
|
8 ;; Keywords: internal
|
|
9
|
|
10 ;; This file is part of XEmacs.
|
|
11
|
|
12 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
13 ;; under the terms of the GNU General Public License as published by
|
|
14 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
15 ;; any later version.
|
|
16
|
|
17 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
20 ;; General Public License for more details.
|
|
21
|
|
22 ;; You should have received a copy of the GNU General Public License
|
|
23 ;; along with XEmacs; see the file COPYING. If not, write to the Free
|
|
24 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
25 ;; 02111-1307, USA.
|
|
26
|
|
27 ;;; Synched up with: Not in FSF
|
|
28
|
|
29 ;;; Commentary:
|
|
30
|
|
31 ;; This is a front-end to the make-docfile program that gathers up all the
|
|
32 ;; lisp files that will be dumped with XEmacs. It would probably be best
|
|
33 ;; to just move make-docfile.c completely to lisp and be done with it.
|
|
34
|
|
35 ;;; Code:
|
|
36
|
1261
|
37 ;; Help debug problems.
|
|
38 (setq stack-trace-on-error t
|
|
39 load-always-display-messages t)
|
|
40
|
428
|
41 (defvar options nil)
|
|
42 (defvar processed nil)
|
|
43 (defvar docfile nil)
|
|
44 (defvar docfile-buffer nil)
|
|
45 (defvar site-file-list nil)
|
|
46 (defvar docfile-out-of-date nil)
|
|
47
|
1303
|
48 (defun message (fmt &rest args)
|
|
49 (princ (apply #'format fmt args))
|
|
50 (terpri))
|
|
51
|
428
|
52 ;; Gobble up the stuff we don't wish to pass on.
|
|
53 (setq command-line-args (cdr (cdr (cdr (cdr command-line-args)))))
|
|
54
|
|
55 ;; First gather up the command line options.
|
|
56 (let (done)
|
|
57 (while (and (null done) command-line-args)
|
|
58 (let ((arg (car command-line-args)))
|
|
59 (cond ((or (string-equal arg "-o") ; Specify DOC file name
|
|
60 (string-equal arg "-a") ; Append to DOC file
|
|
61 (string-equal arg "-d")) ; Set working directory
|
|
62 (if (string-equal arg "-o")
|
|
63 (setq docfile (expand-file-name (car (cdr command-line-args)))))
|
|
64 (setq options (cons arg options))
|
|
65 (setq options (cons (expand-file-name (car (cdr command-line-args))) options)))
|
|
66 ((string-equal arg "-i") ; Set site files to scan
|
|
67 (setq site-file-list (car (cdr command-line-args))))
|
|
68 (t (setq done t)))
|
|
69 (if (null done)
|
|
70 (setq command-line-args (cdr (cdr command-line-args)))))))
|
|
71 (setq options (nreverse options))
|
|
72
|
1303
|
73 ;; (message (concat "Options: " (prin1-to-string options)))
|
|
74
|
|
75 ;; insert-file-contents-internal calls out to `format-decode' afterwards,
|
|
76 ;; so it must be defined. if non-zero, it tries to be a bunch more stuff
|
|
77 ;; so say, "NOOOOOOOOOOOOO! Basta! Ca soufit! Enough, already, OK?"
|
|
78 (defun format-decode (fuck me harder) 0)
|
428
|
79
|
|
80 ;; Next process the list of C files.
|
1303
|
81 (defun process-args (args)
|
|
82 (while args
|
|
83 (let ((arg (car args)))
|
|
84 ;; When called from xemacs.mak, we need to do some frobbing on the
|
|
85 ;; args given to us -- remove NEEDTODUMP and make-docfile.exe,
|
|
86 ;; convert .obj files into .c files in the source directory,
|
|
87 ;; handle response files (beginning with @, specifying arguments),
|
|
88 ;; due to line-length limitations in the shell.
|
|
89 (if (string-match "^@" arg)
|
|
90 ;; MS Windows response file
|
|
91 ;; no generate-new-buffer so use its implementation.
|
|
92 (let ((buf (get-buffer-create (generate-new-buffer-name "foo"))))
|
|
93 (set-buffer buf)
|
|
94 (insert-file-contents-internal (substring arg 1))
|
|
95 ;; now majorly grind up the response file.
|
|
96 ;; backslashes get doubled, quotes around strings,
|
|
97 ;; get rid of pesky CR's and NL's, and put parens around
|
|
98 ;; the whole thing so we have a valid list of strings.
|
|
99 (goto-char (point-max))
|
|
100 (insert "\")")
|
|
101 (goto-char (point-min))
|
|
102 (insert "(\"")
|
|
103 (while (search-forward "\\" nil t)
|
|
104 (replace-match "\\\\" nil t))
|
|
105 (goto-char (point-min))
|
|
106 (while (search-forward "\n" nil t)
|
|
107 (replace-match "" nil t))
|
|
108 (goto-char (point-min))
|
|
109 (while (search-forward "\r" nil t)
|
|
110 (replace-match "" nil t))
|
|
111 (goto-char (point-min))
|
|
112 (while (search-forward " " nil t)
|
|
113 (replace-match "\" \"" nil t))
|
|
114 (goto-char (point-min))
|
|
115 (process-args (read buf)))
|
|
116 ;; remove NEEDTODUMP and make-docfile.exe, convert .obj files into
|
|
117 ;; .c files in the source directory.
|
|
118 (when (and (not (string-match "\\(NEEDTODUMP\\|\\.exe$\\)" arg))
|
|
119 (not (member arg processed)))
|
|
120 (when (string-match "\\(.*\\)\\.obj$" arg)
|
|
121 (setq arg (concat (file-name-nondirectory
|
|
122 ;; no match-string so use its implementation.
|
|
123 (substring arg (match-beginning 1)
|
|
124 (match-end 1)))
|
|
125 ".c")))
|
428
|
126 (if (and (null docfile-out-of-date)
|
|
127 (file-newer-than-file-p arg docfile))
|
|
128 (setq docfile-out-of-date t))
|
1303
|
129 (setq processed (cons arg processed))))
|
|
130 (setq args (cdr args)))))
|
|
131
|
|
132 (process-args command-line-args)
|
428
|
133
|
|
134 ;; Then process the list of Lisp files.
|
442
|
135 (let ((build-root (expand-file-name ".." invocation-directory)))
|
|
136 (setq load-path (list (expand-file-name "lisp" build-root))))
|
428
|
137
|
|
138 ;; Then process the autoloads
|
|
139 (setq autoload-file-name "auto-autoloads.elc")
|
1261
|
140 (load "very-early-lisp.el")
|
428
|
141 (load "find-paths.el")
|
|
142 (load "packages.el")
|
|
143 (load "setup-paths.el")
|
|
144 (load "dump-paths.el")
|
1261
|
145 (load "raw-process.el")
|
428
|
146
|
|
147 (let (preloaded-file-list)
|
|
148 (load (expand-file-name "../lisp/dumped-lisp.el"))
|
|
149
|
|
150 (let ((package-preloaded-file-list
|
|
151 (packages-collect-package-dumped-lisps late-package-load-path)))
|
|
152
|
|
153 (setq preloaded-file-list
|
|
154 (append package-preloaded-file-list
|
|
155 preloaded-file-list
|
|
156 packages-hardcoded-lisp)))
|
|
157
|
|
158 (while preloaded-file-list
|
|
159 (let ((arg0 (packages-add-suffix (car preloaded-file-list)))
|
|
160 arg)
|
|
161 (setq arg (locate-library arg0))
|
|
162 (if (null arg)
|
|
163 (progn
|
1303
|
164 (message "Error: dumped file %s does not exist" arg0)
|
428
|
165 ;; Uncomment in case of difficulties
|
1303
|
166 ;;(message "late-packages: %S" late-packages)
|
|
167 ;;(message "guessed-roots: %S" (paths-find-emacs-roots invocation-directory invocation-name #'paths-emacs-root-p))
|
|
168 ;;(message "guessed-data-roots: %S" (paths-find-emacs-roots invocation-directory invocation-name #'paths-emacs-data-root-p))
|
428
|
169 )
|
|
170 (if (null (member arg processed))
|
|
171 (progn
|
|
172 (if (and (null docfile-out-of-date)
|
|
173 (file-newer-than-file-p arg docfile))
|
|
174 (setq docfile-out-of-date t))
|
|
175 (setq processed (cons arg processed)))))
|
|
176 (setq preloaded-file-list (cdr preloaded-file-list)))))
|
|
177
|
|
178 ;; Finally process the list of site-loaded files.
|
|
179 (if site-file-list
|
|
180 (let (site-load-packages)
|
|
181 (load site-file-list t t)
|
|
182 (while site-load-packages
|
|
183 (let ((arg (car site-load-packages)))
|
|
184 (if (null (member arg processed))
|
|
185 (progn
|
|
186 (if (and (null docfile-out-of-date)
|
|
187 (file-newer-than-file-p arg docfile))
|
|
188 (setq docfile-out-of-date t))
|
|
189 (setq processed (cons arg processed)))))
|
|
190 (setq site-load-packages (cdr site-load-packages)))))
|
|
191
|
|
192 ;(let ((autoloads (packages-list-autoloads-path)))
|
1303
|
193 ; ;; (message (concat "Autoloads: " (prin1-to-string autoloads)))
|
428
|
194 ; (while autoloads
|
|
195 ; (let ((arg (car autoloads)))
|
|
196 ; (if (null (member arg processed))
|
|
197 ; (progn
|
1303
|
198 ; ;; (message arg)
|
428
|
199 ; (if (and (null docfile-out-of-date)
|
|
200 ; (file-newer-than-file-p arg docfile))
|
|
201 ; (setq docfile-out-of-date t))
|
|
202 ; (setq processed (cons arg processed))))
|
|
203 ; (setq autoloads (cdr autoloads)))))
|
|
204
|
|
205 ;; Now fire up make-docfile and we're done
|
|
206
|
|
207 (setq processed (nreverse processed))
|
|
208
|
1303
|
209 (terpri)
|
|
210
|
|
211 ;(message (prin1-to-string (append options processed)))
|
428
|
212
|
1303
|
213 (when docfile-out-of-date
|
|
214 (condition-case nil
|
|
215 (delete-file docfile)
|
|
216 (error nil))
|
|
217 (message "Spawning make-docfile ...")
|
|
218 ;; (message (prin1-to-string (append options processed)))
|
|
219
|
|
220 (setq exec-path (list (concat default-directory "../lib-src")))
|
428
|
221
|
1303
|
222 ;; (locate-file-clear-hashing nil)
|
|
223 (if (memq system-type '(berkeley-unix next-mach))
|
|
224 ;; Suboptimal, but we have a unresolved bug somewhere in the
|
|
225 ;; low-level process code. #### Now that we've switched to using
|
|
226 ;; the regular asynch process code, we should try removing this.
|
|
227 (call-process-internal
|
|
228 "/bin/csh"
|
|
229 nil
|
|
230 t
|
|
231 nil
|
|
232 "-fc"
|
|
233 (mapconcat
|
|
234 #'identity
|
|
235 (append
|
|
236 (list (concat default-directory "../lib-src/make-docfile"))
|
|
237 options processed)
|
|
238 " "))
|
|
239 ;; (message (prin1-to-string (append options processed)))
|
|
240 (apply 'call-process-internal
|
|
241 ;; (concat default-directory "../lib-src/make-docfile")
|
|
242 "make-docfile"
|
428
|
243 nil
|
|
244 t
|
|
245 nil
|
1303
|
246 (append options processed)))
|
428
|
247
|
1303
|
248 (message "Spawning make-docfile ...done")
|
|
249 ;; (write-region-internal (point-min) (point-max) "/tmp/DOC")
|
|
250 )
|
|
251 (message "DOC file is up to date")
|
428
|
252
|
|
253 (kill-emacs)
|
|
254
|
|
255 ;;; make-docfile.el ends here
|