unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob a7699fb1dd05cff9c167217d6671cb0b891dd628 2506 bytes (raw)
name: emacs/make-deps.el 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
 
;;; make-deps.el --- compute make dependencies for Elisp sources
;;
;; Copyright © Austin Clements
;;
;; This file is part of Notmuch.
;;
;; Notmuch is free software: you can redistribute it and/or modify it
;; under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; Notmuch is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with Notmuch.  If not, see <https://www.gnu.org/licenses/>.
;;
;; Authors: Austin Clements <aclements@csail.mit.edu>

;;; Code:

(defun batch-make-deps ()
  "Invoke `make-deps' for each file on the command line."
  (setq debug-on-error t)
  (dolist (file command-line-args-left)
    (let ((default-directory command-line-default-directory))
      (find-file-literally file))
    (make-deps command-line-default-directory))
  (kill-emacs))

(defun make-deps (&optional dir)
  "Print make dependencies for the current buffer.

This prints make dependencies to `standard-output' based on the
top-level `require' expressions in the current buffer.  Paths in
rules will be given relative to DIR, or `default-directory'."
  (unless dir
    (setq dir default-directory))
  (save-excursion
    (goto-char (point-min))
    (condition-case nil
	(while t
	  (let ((form (read (current-buffer))))
	    ;; Is it a (require 'x) form?
	    (when (and (listp form) (= (length form) 2)
		       (eq (car form) 'require)
		       (listp (cadr form)) (= (length (cadr form)) 2)
		       (eq (car (cadr form)) 'quote)
		       (symbolp (cadr (cadr form))))
	      ;; Find the required library
	      (let* ((name (cadr (cadr form)))
		     (fname (locate-library (symbol-name name))))
		;; Is this file and the library in the same directory?
		;; If not, assume it's a system library and don't
		;; bother depending on it.
		(when (and fname
			   (string= (file-name-directory (buffer-file-name))
				    (file-name-directory fname)))
		  ;; Print the dependency
		  (princ (format "%s.elc: %s.elc\n"
				 (file-name-sans-extension
				  (file-relative-name (buffer-file-name) dir))
				 (file-name-sans-extension
				  (file-relative-name fname dir)))))))))
      (end-of-file nil))))

;;; make-deps.el ends here

debug log:

solving a7699fb1 ...
found a7699fb1 in https://yhetil.org/notmuch.git/

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).