comparison lisp/emacs-lisp/bytecomp.el @ 43027:4c6cdfeb929c

(batch-byte-compile): New arg noforce. (batch-byte-compile-if-not-done): New function.
author Richard M. Stallman <rms@gnu.org>
date Fri, 01 Feb 2002 04:14:14 +0000
parents 2d63191afacd
children f93538d76117 15101779a9a0
comparison
equal deleted inserted replaced
43026:7c4834964c35 43027:4c6cdfeb929c
8 ;; Maintainer: FSF 8 ;; Maintainer: FSF
9 ;; Keywords: lisp 9 ;; Keywords: lisp
10 10
11 ;;; This version incorporates changes up to version 2.10 of the 11 ;;; This version incorporates changes up to version 2.10 of the
12 ;;; Zawinski-Furuseth compiler. 12 ;;; Zawinski-Furuseth compiler.
13 (defconst byte-compile-version "$Revision: 2.92 $") 13 (defconst byte-compile-version "$Revision: 2.93 $")
14 14
15 ;; This file is part of GNU Emacs. 15 ;; This file is part of GNU Emacs.
16 16
17 ;; GNU Emacs is free software; you can redistribute it and/or modify 17 ;; GNU Emacs is free software; you can redistribute it and/or modify
18 ;; it under the terms of the GNU General Public License as published by 18 ;; it under the terms of the GNU General Public License as published by
3552 ) 3552 )
3553 (message "Generating call tree...done.") 3553 (message "Generating call tree...done.")
3554 )) 3554 ))
3555 3555
3556 3556
3557 (defun batch-byte-compile-if-not-done ()
3558 "Like `byte-compile-file' but doesn't recompile if already up to date.
3559 Use this from the command line, with `-batch';
3560 it won't work in an interactive Emacs."
3561 (batch-byte-compile t))
3562
3557 ;;; by crl@newton.purdue.edu 3563 ;;; by crl@newton.purdue.edu
3558 ;;; Only works noninteractively. 3564 ;;; Only works noninteractively.
3559 ;;;###autoload 3565 ;;;###autoload
3560 (defun batch-byte-compile () 3566 (defun batch-byte-compile (&optional noforce)
3561 "Run `byte-compile-file' on the files remaining on the command line. 3567 "Run `byte-compile-file' on the files remaining on the command line.
3562 Use this from the command line, with `-batch'; 3568 Use this from the command line, with `-batch';
3563 it won't work in an interactive Emacs. 3569 it won't work in an interactive Emacs.
3564 Each file is processed even if an error occurred previously. 3570 Each file is processed even if an error occurred previously.
3565 For example, invoke \"emacs -batch -f batch-byte-compile $emacs/ ~/*.el\"" 3571 For example, invoke \"emacs -batch -f batch-byte-compile $emacs/ ~/*.el\".
3572 If NOFORCE is non-nil, don't recompile a file that seems to be
3573 already up-to-date."
3566 ;; command-line-args-left is what is left of the command line (from startup.el) 3574 ;; command-line-args-left is what is left of the command line (from startup.el)
3567 (defvar command-line-args-left) ;Avoid 'free variable' warning 3575 (defvar command-line-args-left) ;Avoid 'free variable' warning
3568 (if (not noninteractive) 3576 (if (not noninteractive)
3569 (error "`batch-byte-compile' is to be used only with -batch")) 3577 (error "`batch-byte-compile' is to be used only with -batch"))
3570 (let ((error nil)) 3578 (let ((error nil))
3571 (while command-line-args-left 3579 (while command-line-args-left
3572 (if (file-directory-p (expand-file-name (car command-line-args-left))) 3580 (if (file-directory-p (expand-file-name (car command-line-args-left)))
3581 ;; Directory as argument.
3573 (let ((files (directory-files (car command-line-args-left))) 3582 (let ((files (directory-files (car command-line-args-left)))
3574 source dest) 3583 source dest)
3575 (dolist (file files) 3584 (dolist (file files)
3576 (if (and (string-match emacs-lisp-file-regexp file) 3585 (if (and (string-match emacs-lisp-file-regexp file)
3577 (not (auto-save-file-name-p file)) 3586 (not (auto-save-file-name-p file))
3580 (setq dest (byte-compile-dest-file source)) 3589 (setq dest (byte-compile-dest-file source))
3581 (file-exists-p dest) 3590 (file-exists-p dest)
3582 (file-newer-than-file-p source dest)) 3591 (file-newer-than-file-p source dest))
3583 (if (null (batch-byte-compile-file source)) 3592 (if (null (batch-byte-compile-file source))
3584 (setq error t))))) 3593 (setq error t)))))
3585 (if (null (batch-byte-compile-file (car command-line-args-left))) 3594 ;; Specific file argument
3586 (setq error t))) 3595 (if (or (not noforce)
3596 (let* ((source (car command-line-args-left))
3597 (dest (byte-compile-dest-file source)))
3598 (or (not (file-exists-p dest))
3599 (file-newer-than-file-p source dest))))
3600 (if (null (batch-byte-compile-file (car command-line-args-left)))
3601 (setq error t))))
3587 (setq command-line-args-left (cdr command-line-args-left))) 3602 (setq command-line-args-left (cdr command-line-args-left)))
3588 (kill-emacs (if error 1 0)))) 3603 (kill-emacs (if error 1 0))))
3589 3604
3590 (defun batch-byte-compile-file (file) 3605 (defun batch-byte-compile-file (file)
3591 (condition-case err 3606 (condition-case err