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.8 $
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
91 "XEmacs Build Reports List <xemacs-buildreports@xemacs.org>"
92 "XEmacs Beta List <xemacs-beta@xemacs.org>")
93 "*The list of mail addresses XEmacs Build Reports should most likely
97 :documentation-shown t
101 (defcustom build-report-keep-regexp
103 "^\\(cd\\|n?make\\)\\s-"
106 "pure.*\\(space\\|size\\)"
110 "^Compil\\(ing\\s-+in\\|ation\\)"
113 "^While\\s-+compiling.*\\(\n\\s-+.+\\)*"
118 "*Regexp of make process output lines to keep in the report."
121 :documentation-shown t
123 :group 'build-report)
125 (defcustom build-report-delete-regexp
127 "confl.*with.*auto-inlining"
129 "(100%) tests successful")
130 "*Regexp of make process output lines to delete from the report."
133 :documentation-shown t
135 :group 'build-report)
137 (defcustom build-report-make-output-dir
139 ((equal system-type 'windows-nt)
140 (expand-file-name "nt"
141 (gethash 'blddir (config-value-hash-table))))
143 (gethash 'blddir (config-value-hash-table))))
144 "*Directory where the build report file is found.
145 If this is empty or nil, the default, it is replaced by the value of
146 the XEmacs build directory."
149 :documentation-shown t)
150 :group 'build-report)
152 (defcustom build-report-make-output-files
155 "xemacs-make-all.err"
156 "xemacs-make-check-temacs.err"
157 "xemacs-make-check.err"
158 "xemacs-make-install.err")
159 "*List of Filenames where stdout and stderr of XEmacs make process
160 have been stored. These are relative to
161 `build-report-make-output-dir`. You'll have to run make with output
162 redirection or use the `build' XEmacs package to save this output. You
163 may use following alias
165 alias mk 'make \!* >>&\! \!$.err &'
167 under csh, so that you get beta.err went you run `mk beta'."
170 :documentation-shown t
172 :group 'build-report)
174 (defcustom build-report-installation-file
175 (expand-file-name "Installation"
176 (gethash 'blddir (config-value-hash-table)))
177 "*Installation file produced by XEmacs configure process."
180 :documentation-shown t)
181 :group 'build-report)
183 (defcustom build-report-version-file
186 (gethash 'blddir (config-value-hash-table)))
187 "*version.sh file identifying XEmacs (Beta) Distribution."
190 :documentation-shown t)
191 :group 'build-report)
193 (defcustom build-report-installation-insert-all
195 "*Tell build-report to insert the whole Installation file
196 instead of just the last report."
198 :group 'build-report)
200 (defcustom build-report-subject
201 (concat "[%s] " emacs-version " on " system-configuration)
202 "*XEmacs Build Report Subject Line. %s-sequences will be substituted
203 with user input through `build-report' according to
204 `build-report-prompts' using `format'."
207 :documentation-shown t)
208 :group 'build-report)
210 (defcustom build-report-prompts
211 (quote (("Status?: " ("Success" "Failure"))))
212 "*XEmacs Build Report Prompt(s). This is a list of prompt-string
213 lists used by `build-report' in conjunction with
214 `build-report-subject'. Each list consists of a prompt string
215 followed by any number of strings which can be chosen via the history
219 :documentation-shown t
226 :group 'build-report)
228 (defcustom build-report-file-encoding
230 "*XEmacs Build Report File Encoding to be used when MIME support is
232 :group 'build-report)
234 ;; Symbol Name mappings from TM to SEMI serving as Compatibility
236 (when (featurep 'mime-setup)
237 ;; No (defvaralias ...) so far. Thanks to "Didier Verna"
238 ;; <didier@xemacs.org> for reporting my incorrect defvaraliasing of
239 ;; `mime-editor/insert-tag'.
240 ;; Thanks to Jens-Ulrik Holger Petersen
241 ;; <petersen@kurims.kyoto-u.ac.jp> for suggesting the conditional
242 ;; aliasing of SEMI functions.
243 (unless (fboundp 'mime-edit-content-beginning)
244 (defalias 'mime-edit-content-beginning 'mime-editor/content-beginning))
245 (unless (fboundp 'mime-edit-insert-tag)
246 (defalias 'mime-edit-insert-tag 'mime-editor/insert-tag))
247 (unless (fboundp 'mime-edit-insert-binary-file)
248 (defalias 'mime-edit-insert-binary-file
249 'mime-editor/insert-binary-file)))
251 (defun build-report-make-output-get ()
252 "Returns the filename the XEmacs make output is saved in."
254 (if (or (string-equal build-report-make-output-dir "")
255 (null build-report-make-output-dir))
261 (file-name-as-directory
262 (gethash 'blddir (config-value-hash-table))))))
263 build-report-make-output-files)
269 (file-name-as-directory build-report-make-output-dir))))
270 build-report-make-output-files)))
273 (defun build-report (&rest args)
274 "Report build information including Installation and make output.
276 Prompts for status (usually \"Success\" or \"Failure\"). Then uses
277 `compose-mail' to create a mail message. The Subject header contains
278 status and version information. Point is left at the beginning of the
279 mail text. Add some notes if you like, and send the report.
281 Looks for Installation and the make output file (`beta.err' by
282 default, customizable via `build-report-make-output-files') in the
283 build directory of the running XEmacs by default (customizable via
284 `build-report-make-output-dir'). The output from make is filtered
285 through `build-report-keep-regexp' and `build-report-delete-regexp'
286 before including in the message.
288 See also `mail-user-agent', `build-report-destination', and
289 `build-report-installation-file'."
290 ;; `interactive' form returns value for formal parameter `args'.
295 (prompts build-report-prompts))
299 (setq prompt (caar prompts))
300 (setq hist (cdar prompts))
301 ;; `build-report-prompts' used to be a list of lists, the
302 ;; first element of each list being the prompt, the rest being
303 ;; the history. The history is now in a separate list. We
304 ;; better check for that.
305 (if (listp (car hist))
306 (setq hist (car hist)))
307 (setq prompts (cdr prompts))
308 (setq arg (cons (read-string prompt "" 'hist) arg)))
311 (if (file-exists-p build-report-installation-file)
313 (major minor beta codename configuration)
314 (build-report-installation-data build-report-installation-file)
315 (setq build-report-subject
316 (format "[%%s] XEmacs %s.%s%s \"%s\", %s"
317 major minor beta codename configuration)))
319 (major minor beta codename)
320 (build-report-version-file-data build-report-version-file)
321 (setq build-report-subject
322 (format "[%%s] XEmacs %s.%s%s \"%s\", %s"
323 major minor beta codename system-configuration))))
325 ;; `build-report-destination' used to be a single string, so
326 ;; let's test if we really get a list of destinations.
327 (if (listp build-report-destination)
329 "Build Report Destination: "
330 (car build-report-destination)
331 'build-report-destination)
333 "Build Report Destination: "
334 build-report-destination)
336 (apply 'format build-report-subject args)
342 (let* ((report-begin (point))
343 (files (reverse (build-report-make-output-get)))
346 (if (file-exists-p file)
347 (insert (build-report-insert-make-output report-begin file))
348 (insert (format "%s not found!\n" file)))
350 (setq files (cdr files))
351 (setq file (car files)))
352 (if (file-exists-p build-report-installation-file)
353 (insert (build-report-insert-installation-file
355 build-report-installation-insert-all))
356 (insert (format "%s not found!\n" build-report-installation-file)))
357 ;;; (when (and (>= major 21) (>= minor 2) (or (null beta) (>= beta 32)))
359 ;;; (insert (build-report-insert-config-inc report-begin)))
361 (insert (build-report-insert-header report-begin))
362 (goto-char report-begin))))
364 (defun build-report-insert-header (where)
365 "Inserts the build-report-header at the point specified by `where'."
370 > XEmacs Build Report generated by emacs-version
372 > with system-configuration
374 > follows:\n\n" emacs-version system-configuration))
377 (defun build-report-insert-make-output (where file)
378 "Inserts the output of the XEmacs Beta make run in the
379 current buffer at position WHERE.
380 The make process output must have been saved in
381 `build-report-make-output-files' during the XEmacs Beta building."
384 (if (file-exists-p file)
386 (if (featurep 'mime-setup)
388 (mime-edit-insert-tag
392 "\nContent-Disposition: attachment;"
394 (file-name-nondirectory
397 (mime-edit-insert-binary-file
399 build-report-file-encoding))
400 (insert-file-contents file))
401 (when build-report-keep-regexp
402 (goto-char (point-min))
403 (delete-non-matching-lines (build-report-keep)))
404 (when build-report-delete-regexp
405 (goto-char (point-min))
406 (delete-matching-lines (build-report-delete)))
407 (goto-char (point-min))
408 (if build-report-keep-regexp
411 "> keeping lines matching
414 (build-report-keep))))
415 (if build-report-delete-regexp
418 "> %sdeleting lines matching
421 (if build-report-keep-regexp
424 (build-report-delete))))
426 (goto-char (point-min))
428 (format "> Contents of %s\n" file)))
430 " does not exist!\n\n"))
433 (defun build-report-insert-installation-file (where all)
434 "Inserts the contents of the `build-report-installation-file'
435 created by the XEmacs Beta configure process."
438 (if (file-exists-p build-report-installation-file)
439 (let (file-begin last-configure)
440 (insert "> Contents of "
441 build-report-installation-file
445 "> (Output from %s of ./configure)\n\n"
446 (if all "all runs" "most recent run")))
447 (if (featurep 'mime-setup)
449 (mime-edit-insert-tag
453 "\nContent-Disposition: attachment;"
455 (file-name-nondirectory
456 build-report-installation-file)
458 (mime-edit-insert-binary-file
459 build-report-installation-file
460 build-report-file-encoding)
461 (setq file-begin (mime-edit-content-beginning)))
462 (setq file-begin (point))
463 (insert-file-contents
464 build-report-installation-file))
467 (search-backward-regexp
468 "^\\(uname.*\\|osversion\\|OS\\):\\s-+" file-begin t))
469 (if (and file-begin last-configure)
470 (delete-region file-begin last-configure))))
471 (insert "> " build-report-installation-file
472 " does not exist!\n\n"))
475 (defun build-report-keep ()
476 "Concatenate elements of `build-report-keep-regexp' and a general
477 MIME tag REGEXP. The result is a REGEXP string matching either of the
478 REGEXPs in `build-report-keep-regexp' or a general MIME tag REGEXP."
479 (mapconcat #'identity
480 (cons "^--\\[\\[\\|\\]\\]$" build-report-keep-regexp) "\\|"))
482 (defun build-report-delete ()
483 "Concatenate elements of `build-report-delete-regexp' and a general
484 MIME tag REGEXP. The result is a REGEXP string matching either of the
485 REGEXPs in `build-report-delete-regexp' or a general MIME tag REGEXP."
486 (mapconcat '(lambda (item) item)
487 build-report-delete-regexp "\\|"))
489 (defun build-report-installation-data (&optional file)
490 "Return a list of XEmacs installation data containing MAJOR_NUMBER
491 MINOR_NUMBER BETA_STRING CODENAME CONFIGURATION SRCDIR from FILE,
492 which defaults to `build-report-installation-file'."
493 (interactive "fInstallation file: ")
495 (setq file build-report-installation-file))
497 (major minor beta codename configuration srcdir)
498 (save-window-excursion
499 (find-file-read-only file)
500 (goto-char (point-min))
501 (while (< (point) (point-max))
503 ((looking-at build-report-installation-version-regexp)
504 (goto-char (match-end 0))
505 (setq major (match-string 1))
506 (setq minor (match-string 2))
507 (setq beta (match-string 3))
508 (setq codename (match-string 6))
509 (setq configuration (match-string 7)))
510 ((looking-at build-report-installation-srcdir-regexp)
511 (goto-char (match-end 0))
512 (setq srcdir (match-string 1)))
513 ;; We avoid matching a potentially zero-length string to avoid
517 (goto-char (match-end 0)))
519 (goto-char (match-end 0)))))
520 (values major minor (or beta "") codename configuration srcdir))))
522 (defun build-report-version-file-data (&optional file)
523 "Return a list of XEmacs version information containing
524 MAJOR_NUMBER MINOR_NUMBER BETA_STRING CODENAME from FILE, which
525 defaults to `build-report-version-file'."
526 (interactive "fversion.sh file: ")
528 (setq file build-report-version-file))
530 (major minor beta codename)
531 (save-window-excursion
532 (find-file-read-only file)
533 (goto-char (point-min))
534 (while (< (point) (point-max))
536 ((looking-at build-report-version-file-regexp)
537 (goto-char (match-end 0))
538 (setq major (match-string 1))
539 (setq minor (match-string 2))
540 (setq beta (match-string 3))
541 (setq codename (match-string 4)))
542 ;; We avoid matching a potentially zero-length string to avoid
546 (goto-char (match-end 0)))
548 (goto-char (match-end 0)))))
549 (values major minor (or beta "") codename))))
551 ;;; build-report.el ends here