1 ;;; build-report.el --- Automatically formatted build reports for XEmacs
3 ;; Copyright (C) 1997 Adrian Aichner
5 ;; Author: Adrian Aichner <adrian@xemacs.org>
6 ;; Date: Sun., Apr. 20, 1997-2000.
7 ;; Version: $Revision: 1.5.2.6 $
10 ;; This file is part of XEmacs.
12 ;; XEmacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
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.
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
27 ;;; Synched up with: Not synched.
32 ;; Let XEmacs report interesting aspects of how it was built.
35 ;; User creates an XEmacs Build Report by just calling
37 ;; which will initialize a mail buffer with relevant information
38 ;; derived from the XEmacs build process. Point is left at the
39 ;; beginning of the report for user to input some personal notes and
43 ;; This is the first `Proof of Concept'.
46 ;; Adrian Aichner, Teradyne GmbH Munich, Sun., Apr. 20, 1997.
53 (provide 'build-report)
55 ;;; Constant definitions used internally by `build-report'. These are not
56 ;;; anticipated to be changed by users of `build-report'.
57 ;;; If users do need to change the value of any of these, they need to do
58 ;;; it after `build-report' has been loaded (not just required). Please
59 ;;; report it to the maintainers of `build-report' when you think you
61 (defconst build-report-installation-version-regexp
62 "XEmacs\\s-+\\([0-9]+\\)\\.\\([0-9]+\\)\\(\\(-b\\|\\.\\)\\([0-9]+\\)\\)?\\s-+\\\\?\"\\([^\\\"]+\\)\\\\?\"\\s-+configured\\s-+for\\s-+`\\(.+\\)'\\."
63 "*REGEXP matching XEmacs Beta Version string in
64 `build-report-installation-file' file. This variable is used by
65 `build-report-installation-data'.")
67 (defconst build-report-version-file-regexp
68 "emacs_major_version\\s-*=\\s-*\\([0-9]+\\)
69 emacs_minor_version\\s-*=\\s-*\\([0-9]+\\)
70 emacs_beta_version\\s-*=\\s-*\\([0-9]+\\)?
71 xemacs_codename\\s-*=\\s-*\"\\([^\"]+\\)\""
72 "*REGEXP matching XEmacs Beta Version variable assignments in
73 `build-report-version-file' file. This variable is used by
74 `build-report-version-file-data'.")
76 (defconst build-report-installation-srcdir-regexp
77 "\\s-*Where should the build process find the source code\\?\\s-*\\(.*\\)$"
78 "REGEXP matching XEmacs Beta srcdir as the first substring match in
79 `build-report-installation-file' file. This variable is used by
80 `build-report-installation-data'.")
82 ;;; Customization support for build-report starts here.
84 (defgroup build-report nil
85 "Standardizes the Creation of XEmacs Build Reports."
89 (defcustom build-report-destination
90 (quote ("XEmacs Build Reports List <xemacs-build-reports@xemacs.org>"
91 "XEmacs Beta List <xemacs-beta@xemacs.org>"))
92 "*The list of mail addresses XEmacs Build Reports should most likely
96 :documentation-shown t
100 (defcustom build-report-keep-regexp
101 (quote ("^\\(cd\\|n?make\\)\\s-" "errors?" "warnings?"
102 "pure.*\\(space\\|size\\)" "hides\\b" "strange" "shadowings"
103 "^Compil\\(ing\\s-+in\\|ation\\)" "^Using" "not\\s-+found"
104 "^While\\s-+compiling.*\\(\n\\s-+.+\\)*" "^Note:"
105 "Installing" "[Ff]ile(s) copied"
107 "*Regexp of make process output lines to keep in the report."
110 :documentation-shown t
112 :group 'build-report)
114 (defcustom build-report-delete-regexp
115 (quote ("confl.*with.*auto-inlining" "^Formatting:"))
116 "*Regexp of make process output lines to delete from the report."
119 :documentation-shown t
121 :group 'build-report)
123 (defcustom build-report-make-output-dir
125 ((equal system-type 'windows-nt)
126 (expand-file-name "nt"
127 (gethash 'blddir (config-value-hash-table))))
129 (gethash 'blddir (config-value-hash-table))))
130 "*Directory where the build report file is found.
131 If this is empty or nil, the default, it is replaced by the value of
132 the XEmacs build directory."
135 :documentation-shown t)
136 :group 'build-report)
138 (defcustom build-report-make-output-files
140 "*List of Filenames where stdout and stderr of XEmacs make process
141 have been stored. These are relative to
142 `build-report-make-output-dir`. You'll have to run make with output
143 redirection or use the `build' XEmacs package to save this output. You
144 may use following alias
146 alias mk 'make \!* >>&\! \!$.err &'
148 under csh, so that you get beta.err went you run `mk beta'."
151 :documentation-shown t
153 :group 'build-report)
155 (defcustom build-report-installation-file
156 (expand-file-name "Installation"
157 (gethash 'blddir (config-value-hash-table)))
158 "*Installation file produced by XEmacs configure process."
161 :documentation-shown t)
162 :group 'build-report)
164 (defcustom build-report-version-file
167 (gethash 'blddir (config-value-hash-table)))
168 "*version.sh file identifying XEmacs (Beta) Distribution."
171 :documentation-shown t)
172 :group 'build-report)
174 (defcustom build-report-installation-insert-all
176 "*Tell build-report to insert the whole Installation file
177 instead of just the last report."
179 :group 'build-report)
181 (defcustom build-report-subject
182 (concat "[%s] " emacs-version " on " system-configuration)
183 "*XEmacs Build Report Subject Line. %s-sequences will be substituted
184 with user input through `build-report' according to
185 `build-report-prompts' using `format'."
188 :documentation-shown t)
189 :group 'build-report)
191 (defcustom build-report-prompts
192 (quote (("Status?: " ("Success" "Failure"))))
193 "*XEmacs Build Report Prompt(s). This is a list of prompt-string
194 lists used by `build-report' in conjunction with
195 `build-report-subject'. Each list consists of a prompt string
196 followed by any number of strings which can be chosen via the history
200 :documentation-shown t
207 :group 'build-report)
209 (defcustom build-report-file-encoding
211 "*XEmacs Build Report File Encoding to be used when MIME support is
213 :group 'build-report)
215 ;; Symbol Name mappings from TM to SEMI serving as Compatibility
217 (when (featurep 'mime-setup)
218 ;; No (defvaralias ...) so far. Thanks to "Didier Verna"
219 ;; <didier@xemacs.org> for reporting my incorrect defvaraliasing of
220 ;; `mime-editor/insert-tag'.
221 ;; Thanks to Jens-Ulrik Holger Petersen
222 ;; <petersen@kurims.kyoto-u.ac.jp> for suggesting the conditional
223 ;; aliasing of SEMI functions.
224 (unless (fboundp 'mime-edit-content-beginning)
225 (defalias 'mime-edit-content-beginning 'mime-editor/content-beginning))
226 (unless (fboundp 'mime-edit-insert-tag)
227 (defalias 'mime-edit-insert-tag 'mime-editor/insert-tag))
228 (unless (fboundp 'mime-edit-insert-binary-file)
229 (defalias 'mime-edit-insert-binary-file
230 'mime-editor/insert-binary-file)))
232 (defun build-report-make-output-get ()
233 "Returns the filename the XEmacs make output is saved in."
235 (if (or (string-equal build-report-make-output-dir "")
236 (null build-report-make-output-dir))
242 (file-name-as-directory
243 (gethash 'blddir (config-value-hash-table))))))
244 build-report-make-output-files)
250 (file-name-as-directory build-report-make-output-dir))))
251 build-report-make-output-files)))
254 (defun build-report (&rest args)
255 "Composes a fresh mail message with the contents of the built XEmacs
256 Installation file and excerpts from XEmacs make output.
257 `compose-mail' is used to create the mail message. Point is left at
258 the beginning of the mail text. You may add some personal notes if
259 you like and send the report.
261 `compose-mail', `mail-user-agent',
262 `build-report-destination',
263 `build-report-keep-regexp',
264 `build-report-delete-regexp',
265 `build-report-make-output-dir',
266 `build-report-make-output-files', and
267 `build-report-installation-file'."
268 ;; `interactive' form returns value for formal parameter `args'.
273 (prompts build-report-prompts))
277 (setq prompt (caar prompts))
278 (setq hist (cdar prompts))
279 ;; `build-report-prompts' used to be a list of lists, the
280 ;; first element of each list being the prompt, the rest being
281 ;; the history. The history is now in a separate list. We
282 ;; better check for that.
283 (if (listp (car hist))
284 (setq hist (car hist)))
285 (setq prompts (cdr prompts))
286 (setq arg (cons (read-string prompt "" 'hist) arg)))
289 (if (file-exists-p build-report-installation-file)
291 (major minor beta codename configuration)
292 (build-report-installation-data build-report-installation-file)
293 (setq build-report-subject
294 (format "[%%s] XEmacs %s.%s%s \"%s\", %s"
295 major minor beta codename configuration)))
297 (major minor beta codename)
298 (build-report-version-file-data build-report-version-file)
299 (setq build-report-subject
300 (format "[%%s] XEmacs %s.%s%s \"%s\", %s"
301 major minor beta codename system-configuration))))
303 ;; `build-report-destination' used to be a single string, so
304 ;; let's test if we really get a list of destinations.
305 (if (listp build-report-destination)
307 "Build Report Destination: "
308 (car build-report-destination)
309 'build-report-destination)
311 "Build Report Destination: "
312 build-report-destination)
314 (apply 'format build-report-subject args)
320 (let* ((report-begin (point))
321 (files (reverse (build-report-make-output-get)))
324 (if (file-exists-p file)
325 (insert (build-report-insert-make-output report-begin file))
326 (insert (format "%s not found!\n" file)))
328 (setq files (cdr files))
329 (setq file (car files)))
330 (if (file-exists-p build-report-installation-file)
331 (insert (build-report-insert-installation-file
333 build-report-installation-insert-all))
334 (insert (format "%s not found!\n" build-report-installation-file)))
335 ;;; (when (and (>= major 21) (>= minor 2) (or (null beta) (>= beta 32)))
337 ;;; (insert (build-report-insert-config-inc report-begin)))
339 (insert (build-report-insert-header report-begin))
340 (goto-char report-begin))))
342 (defun build-report-insert-header (where)
343 "Inserts the build-report-header at the point specified by `where'."
348 > XEmacs Build Report generated by emacs-version
350 > with system-configuration
352 > follows:\n\n" emacs-version system-configuration))
355 (defun build-report-insert-make-output (where file)
356 "Inserts the output of the XEmacs Beta make run in the
357 current buffer at position WHERE.
358 The make process output must have been saved in
359 `build-report-make-output-files' during the XEmacs Beta building."
362 (if (file-exists-p file)
364 (if (featurep 'mime-setup)
366 (mime-edit-insert-tag
370 "\nContent-Disposition: attachment;"
372 (file-name-nondirectory
375 (mime-edit-insert-binary-file
377 build-report-file-encoding))
378 (insert-file-contents file))
379 (when build-report-keep-regexp
380 (goto-char (point-min))
381 (delete-non-matching-lines (build-report-keep)))
382 (when build-report-delete-regexp
383 (goto-char (point-min))
384 (delete-matching-lines (build-report-delete)))
385 (goto-char (point-min))
386 (if build-report-keep-regexp
389 "> keeping lines matching
392 (build-report-keep))))
393 (if build-report-delete-regexp
396 "> %sdeleting lines matching
399 (if build-report-keep-regexp
402 (build-report-delete))))
404 (goto-char (point-min))
406 (format "> Contents of %s\n" file)))
408 " does not exist!\n\n"))
411 (defun build-report-insert-installation-file (where all)
412 "Inserts the contents of the `build-report-installation-file'
413 created by the XEmacs Beta configure process."
416 (if (file-exists-p build-report-installation-file)
417 (let (file-begin last-configure)
418 (insert "> Contents of "
419 build-report-installation-file
423 "> (Output from %s of ./configure)\n\n"
424 (if all "all runs" "most recent run")))
425 (if (featurep 'mime-setup)
427 (mime-edit-insert-tag
431 "\nContent-Disposition: attachment;"
433 (file-name-nondirectory
434 build-report-installation-file)
436 (mime-edit-insert-binary-file
437 build-report-installation-file
438 build-report-file-encoding)
439 (setq file-begin (mime-edit-content-beginning)))
440 (setq file-begin (point))
441 (insert-file-contents
442 build-report-installation-file))
445 (search-backward-regexp
446 "^\\(uname.*\\|osversion\\|OS\\):\\s-+" file-begin t))
447 (if (and file-begin last-configure)
448 (delete-region file-begin last-configure))))
449 (insert "> " build-report-installation-file
450 " does not exist!\n\n"))
453 (defun build-report-keep ()
454 "Concatenate elements of `build-report-keep-regexp' and a general
455 MIME tag REGEXP. The result is a REGEXP string matching either of the
456 REGEXPs in `build-report-keep-regexp' or a general MIME tag REGEXP."
457 (mapconcat #'identity
458 (cons "^--\\[\\[\\|\\]\\]$" build-report-keep-regexp) "\\|"))
460 (defun build-report-delete ()
461 "Concatenate elements of `build-report-delete-regexp' and a general
462 MIME tag REGEXP. The result is a REGEXP string matching either of the
463 REGEXPs in `build-report-delete-regexp' or a general MIME tag REGEXP."
464 (mapconcat '(lambda (item) item)
465 build-report-delete-regexp "\\|"))
467 (defun build-report-installation-data (&optional file)
468 "Return a list of XEmacs installation data containing MAJOR_NUMBER
469 MINOR_NUMBER BETA_STRING CODENAME CONFIGURATION SRCDIR from FILE,
470 which defaults to `build-report-installation-file'."
471 (interactive "fInstallation file: ")
473 (setq file build-report-installation-file))
475 (major minor beta codename configuration srcdir)
476 (save-window-excursion
477 (find-file-read-only file)
478 (goto-char (point-min))
479 (while (< (point) (point-max))
481 ((looking-at build-report-installation-version-regexp)
482 (goto-char (match-end 0))
483 (setq major (match-string 1))
484 (setq minor (match-string 2))
485 (setq beta (match-string 3))
486 (setq codename (match-string 6))
487 (setq configuration (match-string 7)))
488 ((looking-at build-report-installation-srcdir-regexp)
489 (goto-char (match-end 0))
490 (setq srcdir (match-string 1)))
491 ;; We avoid matching a potentially zero-length string to avoid
495 (goto-char (match-end 0)))
497 (goto-char (match-end 0)))))
498 (values major minor (or beta "") codename configuration srcdir))))
500 (defun build-report-version-file-data (&optional file)
501 "Return a list of XEmacs version information containing
502 MAJOR_NUMBER MINOR_NUMBER BETA_STRING CODENAME from FILE, which
503 defaults to `build-report-version-file'."
504 (interactive "fversion.sh file: ")
506 (setq file build-report-version-file))
508 (major minor beta codename)
509 (save-window-excursion
510 (find-file-read-only file)
511 (goto-char (point-min))
512 (while (< (point) (point-max))
514 ((looking-at build-report-version-file-regexp)
515 (goto-char (match-end 0))
516 (setq major (match-string 1))
517 (setq minor (match-string 2))
518 (setq beta (match-string 3))
519 (setq codename (match-string 4)))
520 ;; We avoid matching a potentially zero-length string to avoid
524 (goto-char (match-end 0)))
526 (goto-char (match-end 0)))))
527 (values major minor (or beta "") codename))))
529 ;;; build-report.el ends here