From f97b62da6f81ee49cbf69f27ba4a2c059fa2b38b Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Thu, 14 Oct 2010 16:59:10 +0900 Subject: [PATCH] Support "make distcheck". * COMPILE: Support "make distcheck". * Makefile.am: Support "make distcheck". * test/test-riece-log.el (test-riece-log-delete-directory) (test-riece-log-display-message-function): Don't bind default-file-name-coding-system. * riece-log.el (riece-log-display-message-function) (riece-log-insert): Don't bind default-file-name-coding-system. --- lisp/COMPILE | 141 +++++++++++++++++++++++------------- lisp/Makefile.am | 28 ++++--- lisp/riece-log.el | 6 +- lisp/test/test-riece-log.el | 6 +- 4 files changed, 113 insertions(+), 68 deletions(-) diff --git a/lisp/COMPILE b/lisp/COMPILE index 8bbae79..0d3598b 100644 --- a/lisp/COMPILE +++ b/lisp/COMPILE @@ -12,7 +12,6 @@ riece-version riece-coding riece-complete - riece-mcat riece-addon-modules riece-addon riece-ruby @@ -54,6 +53,9 @@ (defvar riece-mcat-modules '(riece-mcat-japanese)) +(defvar riece-generated-modules + '(riece-package-info)) + (defvar riece-icons '("riece-command-previous-channel.xpm" "riece-command-next-channel.xpm" @@ -66,15 +68,24 @@ '("server.rb" "aproxy.rb")) -(defun riece-compile-modules (modules) - (let ((load-path (cons nil load-path)) +(defun riece-byte-compile-dest-file-function (filename) + (expand-file-name + (concat (file-name-nondirectory filename) "c"))) + +(defun riece-compile-modules (modules srcdir) + (let ((load-path (cons nil (cons srcdir load-path))) error-modules) (while modules (let ((source (expand-file-name - (concat (symbol-name (car modules)) ".el")))) - (if (file-newer-than-file-p source (concat source "c")) + (concat (symbol-name (car modules)) ".el") + srcdir)) + (binary (expand-file-name + (concat (symbol-name (car modules)) ".elc")))) + (if (file-newer-than-file-p source binary) (condition-case error - (byte-compile-file source) + (let ((byte-compile-dest-file-function + #'riece-byte-compile-dest-file-function)) + (byte-compile-file source)) (error (setq error-modules (cons (car modules) error-modules)))))) (setq modules (cdr modules))) @@ -96,47 +107,57 @@ (if (file-newer-than-file-p source (concat source "c")) (byte-compile-file source))))) -(defun riece-install-modules (modules dest just-print) - (unless (or just-print (file-exists-p dest)) - (make-directory dest t)) +(defun riece-install-modules (modules srcdir lispdir just-print) + (unless (or just-print (file-exists-p lispdir)) + (make-directory lispdir t)) + ;; Workaround for "make distcheck" + (set-file-modes lispdir 493) (while modules (let ((name (symbol-name (car modules)))) - (princ (format "%s.el -> %s\n" name dest)) + (princ (format "%s.el -> %s\n" name lispdir)) (unless just-print - (copy-file (expand-file-name (concat name ".el")) - (expand-file-name (concat name ".el") dest) + (copy-file (expand-file-name + (concat name ".el") + (if (memq (car modules) riece-generated-modules) + nil + srcdir)) + (expand-file-name (concat name ".el") lispdir) t t)) - (princ (format "%s.elc -> %s\n" name dest)) + (princ (format "%s.elc -> %s\n" name lispdir)) (unless just-print (if (file-exists-p (expand-file-name (concat name ".elc"))) (copy-file (expand-file-name (concat name ".elc")) - (expand-file-name (concat name ".elc") dest) + (expand-file-name (concat name ".elc") lispdir) t t) (princ (format "(%s was not successfully compiled, ignored)\n" name))))) (setq modules (cdr modules)))) -(defun riece-install-icons (icons dest just-print) - (unless (or just-print (file-exists-p dest)) - (make-directory dest t)) +(defun riece-install-icons (icons srcdir lispdir just-print) + (unless (or just-print (file-exists-p lispdir)) + (make-directory lispdir t)) + ;; Workaround for "make distcheck" + (set-file-modes lispdir 493) (while icons - (when (file-exists-p (expand-file-name (car icons))) - (princ (format "%s -> %s\n" (car icons) dest)) + (when (file-exists-p (expand-file-name (car icons) srcdir)) + (princ (format "%s -> %s\n" (car icons) lispdir)) (unless just-print - (copy-file (expand-file-name (car icons)) - (expand-file-name (car icons) dest) + (copy-file (expand-file-name (car icons) srcdir) + (expand-file-name (car icons) lispdir) t t))) (setq icons (cdr icons)))) -(defun riece-install-scripts (scripts dest just-print) - (unless (or just-print (file-exists-p dest)) - (make-directory dest t)) +(defun riece-install-scripts (scripts srcdir lispdir just-print) + (unless (or just-print (file-exists-p lispdir)) + (make-directory lispdir t)) + ;; Workaround for "make distcheck" + (set-file-modes lispdir 493) (while scripts - (when (file-exists-p (expand-file-name (car scripts))) - (princ (format "%s -> %s\n" (car scripts) dest)) + (when (file-exists-p (expand-file-name (car scripts) srcdir)) + (princ (format "%s -> %s\n" (car scripts) lispdir)) (unless just-print - (copy-file (expand-file-name (car scripts)) - (expand-file-name (car scripts) dest) + (copy-file (expand-file-name (car scripts) srcdir) + (expand-file-name (car scripts) lispdir) t t))) (setq scripts (cdr scripts)))) @@ -146,8 +167,8 @@ (if flag (string-match "^\\(\\(--[^ ]+ \\)+-\\|[^ =-]\\)*n" flag)))) -(defun riece-examine-modules () - (let ((load-path (cons nil load-path))) +(defun riece-examine-modules (srcdir) + (let ((load-path (cons nil (cons srcdir load-path)))) (require 'riece-mcat) (require 'riece-addon-modules) (append riece-modules @@ -175,24 +196,41 @@ (setq pointer (cdr pointer))))) (defun riece-compile () - (riece-compile-modules (riece-examine-modules))) + (let ((srcdir (car command-line-args-left))) + (riece-compile-modules (riece-examine-modules srcdir) srcdir))) (defun riece-install () - (riece-install-modules - (riece-examine-modules) - (expand-file-name "riece" (car command-line-args-left)) - (riece-install-just-print-p)) - (riece-install-icons - riece-icons - (expand-file-name "riece" (car command-line-args-left)) - (riece-install-just-print-p)) - (riece-install-scripts - riece-scripts - (expand-file-name "riece" (car command-line-args-left)) - (riece-install-just-print-p)) - ;; Workaround for an XEmacs 21.5 bug ("xemacs -batch -f " - ;; attempts to open as a file after ). - (setq command-line-args-left (cdr command-line-args-left))) + (let ((srcdir (car command-line-args-left)) + (lispdir (nth 1 command-line-args-left))) + (riece-install-modules + (riece-examine-modules srcdir) + srcdir + (expand-file-name "riece" lispdir) + (riece-install-just-print-p)) + (riece-install-icons + riece-icons + srcdir + (expand-file-name "riece" lispdir) + (riece-install-just-print-p)) + (riece-install-scripts + riece-scripts + srcdir + (expand-file-name "riece" lispdir) + (riece-install-just-print-p)) + ;; Workaround for an XEmacs 21.5 bug ("xemacs -batch -f " + ;; attempts to open as a file after ). + (setq command-line-args-left (nthcdr 2 command-line-args-left)))) + +(defun riece-uninstall () + (let ((files (directory-files (expand-file-name "riece" + (car command-line-args-left)) + t "\\.\\(elc?\\|rb\\|xpm\\)$"))) + (while files + (delete-file (car files)) + (setq files (cdr files))) + ;; Workaround for an XEmacs 21.5 bug ("xemacs -batch -f " + ;; attempts to open as a file after ). + (setq command-line-args-left (cdr command-line-args-left)))) (defun riece-compile-package () (setq autoload-package-name "riece") @@ -220,9 +258,12 @@ (riece-install-just-print-p))) (defun riece-test () - (let ((load-path (cons (expand-file-name "test") (cons nil load-path))) - (files (directory-files "test" t "^test-.*\\.el$")) - suite) + (let* ((srcdir (car command-line-args-left)) + (load-path (cons (expand-file-name "test" srcdir) + (cons srcdir (cons nil load-path)))) + (files (directory-files (expand-file-name "test" srcdir) t + "^test-.*\\.el$")) + suite) (require 'lunit-report) (setq suite (lunit-make-test-suite)) (while files @@ -234,4 +275,4 @@ (intern (file-name-sans-extension (file-name-nondirectory (car files))))))) (setq files (cdr files))) - (lunit-report suite (car command-line-args-left)))) + (lunit-report suite (nth 1 command-line-args-left)))) diff --git a/lisp/Makefile.am b/lisp/Makefile.am index 3b5204f..6b6e272 100644 --- a/lisp/Makefile.am +++ b/lisp/Makefile.am @@ -27,35 +27,43 @@ EXTRA_DIST = COMPILE ChangeLog ChangeLog.Liece \ riece-command-join.xpm riece-command-part.xpm \ server.rb aproxy.rb -CLEANFILES = auto-autoloads.el custom-load.el *.elc +CLEANFILES = auto-autoloads.el custom-load.el *.elc lunit-report.xml DISTCLEANFILES = riece-package-info.el FLAGS ?= -batch -q -no-site-file all: elc elc: - $(EMACS) $(FLAGS) -l COMPILE -f riece-compile + $(EMACS) $(FLAGS) -l $(srcdir)/COMPILE -f riece-compile \ + $(srcdir) install: elc - $(EMACS) $(FLAGS) -l COMPILE -f riece-install $(lispdir) # $(MAKE) + $(EMACS) $(FLAGS) -l $(srcdir)/COMPILE -f riece-install \ + $(srcdir) $(lispdir) # $(MAKE) + +uninstall: + $(EMACS) $(FLAGS) -l $(srcdir)/COMPILE -f riece-uninstall \ + $(lispdir) package: - $(XEMACS) $(FLAGS) -l COMPILE -f riece-compile-package + $(XEMACS) $(FLAGS) -l $(srcdir)/COMPILE -f riece-compile-package install-package: package - $(XEMACS) $(FLAGS) -l COMPILE -f riece-install-package \ + $(XEMACS) $(FLAGS) -l $(srcdir)/COMPILE -f riece-install-package \ $(PACKAGEDIR) # $(MAKE) check-local: - $(EMACS) $(FLAGS) -l COMPILE -f riece-test lunit-report.xml + $(EMACS) $(FLAGS) -l $(srcdir)/COMPILE -f riece-test \ + $(srcdir) lunit-report.xml compile-individually: - @for i in `$(EMACS) $(FLAGS) -l COMPILE -f riece-examine`; do \ - echo $(EMACS) $(FLAGS) -l COMPILE \ + @for i in `$(EMACS) $(FLAGS) -l $(srcdir)/COMPILE -f riece-examine`; \ + do \ + echo $(EMACS) $(FLAGS) -l $(srcdir)/COMPILE \ -f riece-compile-module $$i; \ - $(EMACS) $(FLAGS) -l COMPILE \ + $(EMACS) $(FLAGS) -l $(srcdir)/COMPILE \ -f riece-compile-module $$i; \ done update-mcat: - $(EMACS) $(FLAGS) -l COMPILE -f riece-update-mcat + $(EMACS) $(FLAGS) -l $(srcdir)/COMPILE -f riece-update-mcat diff --git a/lisp/riece-log.el b/lisp/riece-log.el index 624115b..0938456 100644 --- a/lisp/riece-log.el +++ b/lisp/riece-log.el @@ -102,8 +102,7 @@ It is created if there is at least one instance of Emacs running riece-log.") 'coding-system))))) (file (riece-log-make-file-name (riece-message-target message) coding-system-for-write)) - file-name-coding-system - default-file-name-coding-system) + (file-name-coding-system 'no-conversion)) (unless (file-directory-p (file-name-directory file)) (make-directory (file-name-directory file) t)) (write-region (concat (format-time-string "%H:%M") " " @@ -185,8 +184,7 @@ It is created if there is at least one instance of Emacs running riece-log.") (defun riece-log-insert (identity lines) "Insert logs for IDENTITY at most LINES. If LINES is t, insert today's logs entirely." - (let* (file-name-coding-system - default-file-name-coding-system + (let* ((file-name-coding-system 'no-conversion) (files (riece-log-list-files identity (if (eq lines t) (current-time)))) name coding-system date point) diff --git a/lisp/test/test-riece-log.el b/lisp/test/test-riece-log.el index fc14774..06966ac 100644 --- a/lisp/test/test-riece-log.el +++ b/lisp/test/test-riece-log.el @@ -3,8 +3,7 @@ (luna-define-class test-riece-log (lunit-test-case)) (defun test-riece-log-delete-directory (directory) - (let (file-name-coding-system - default-file-name-coding-system + (let ((file-name-coding-system 'no-conversion) (files (directory-files directory t nil t))) (while files (if (file-directory-p (car files)) @@ -143,8 +142,7 @@ "") "a b c\n" nil t)) (put 'riece-log 'riece-addon-enabled nil)) - (let (file-name-coding-system - default-file-name-coding-system) + (let ((file-name-coding-system 'no-conversion)) (lunit-assert-2 case (file-directory-p -- 2.25.1