Initial Commit
[packages] / xemacs-packages / semantic / semanticdb-mk.el
1 ;;; semanticdb-mk.el --- Command line database builder
2
3 ;;; Copyright (C) 2002, 2004 Eric M. Ludlam
4
5 ;; Author: Eric M. Ludlam <zappo@gnu.org>
6 ;; Keywords: tags
7 ;; X-RCS: $Id: semanticdb-mk.el,v 1.1 2007-11-26 15:10:47 michaels Exp $
8
9 ;; This file is not part of GNU Emacs.
10
11 ;; Semanticdb is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
15
16 ;; This software is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
25 ;; 
26 ;;; Commentary:
27 ;;
28 ;; For use by semanticdb.sh for building tag files.
29 ;;
30
31 ;;; Code
32 ;;
33 (if (not noninteractive)
34     (error "You should not load semanticdb-mk interactivly."))
35
36 ;; Find our source directory
37 (let (fname semanticdir cedetdir loadfile)
38
39   (setq fname load-file-name)
40   (setq semanticdir (file-name-directory fname))
41   (setq cedetdir (expand-file-name (concat semanticdir "../common/")))
42   (setq loadfile (concat cedetdir "cedet.el"))
43
44   (load-file loadfile))
45
46 ;; Turn on semanticdb
47 (global-semanticdb-minor-mode 1)
48
49 ;; Process loaded buffers from the command line.
50 (let ((args command-line-args))
51   ;; Move past this load file being loaded.
52   (while (and args
53               (not
54                (progn
55                  ;(message "Compare %s to %s" (car args) "-l")
56                  (string= (car args) "-l"))))
57     (setq args (cdr args)))
58   (when args
59     (setq args (cdr (cdr args)))
60     ;; Grab the rest of the file names.
61     ;; For each file, load it in, let semantic evaluate it for tags.
62     (while args
63       (princ (concat "Loading " (car args) "... "))
64       (save-window-excursion
65         (let* ((buffer (find-file-noselect (car args)))
66                (tags nil))
67           (set-buffer buffer)
68           (setq tags (semantic-fetch-tags))
69           (princ (length tags))
70           (princ " tags found .\n"))
71         (setq args (cdr args))))
72     ))
73
74 ;; Save the databases.
75 (semanticdb-save-all-db)
76
77 ;; Done