updated on Thu Jan 12 04:00:44 UTC 2012
[aur-mirror.git] / emacs-xcscope / cscope-indexer
blob13c0ae2145fe2cd38f1bc03c5171ca1c8bed4af8
1 #! /bin/sh
2 ###############################################################################
4 # File: cscope-indexer
5 # RCS: $Header: /cvsroot/cscope/cscope/contrib/xcscope/cscope-indexer,v 1.2 2001/06/28 04:39:47 darrylo Exp $
6 # Description: Script to index files for cscope
8 # This script generates a list of files to index
9 # (cscope.out), which is then (optionally) used to
10 # generate a cscope database. You can use this script
11 # to just build a list of files, or it can be used to
12 # build a list and database. This script is not used to
13 # just build a database (skipping the list of files
14 # step), as this can be simply done by just calling
15 # "cscope -b".
17 # Normally, cscope will do its own indexing, but this
18 # script can be used to force indexing. This is useful
19 # if you need to recurse into subdirectories, or have
20 # many files to index (you can run this script from a
21 # cron job, during the night). It is especially useful
22 # for large projects, which can contstantly have source
23 # files added and deleted; by using this script, the
24 # changing sources files are automatically handled.
26 # Currently, any paths containing "/CVS/" or "/RCS/" are
27 # stripped out (ignored).
29 # This script is written to use only basic shell features, as
30 # not all shells have advanced features.
32 # Author: Darryl Okahata
33 # Created: Thu Apr 27 17:12:14 2000
34 # Modified: Tue Jun 19 09:47:45 2001 (Darryl Okahata) darrylo@soco.agilent.com
35 # Language: Shell-script
36 # Package: N/A
37 # Status: Experimental
39 # (C) Copyright 2000, Darryl Okahata, all rights reserved.
41 ###############################################################################
43 # Usage:
45 # cscope-indexer [ -v ] [-f database_file ] [-i list_file ] [ -l ] [ -r ]
47 # where:
49 # -f database_file
50 # Specifies the cscope database file (default: cscope.out).
52 # -i list_file
53 # Specifies the name of the file into which the list of files
54 # to index is placed (default: cscope.files).
56 # -l
57 # Suppress the generation/updating of the cscope database
58 # file. Only a list of files is generated.
60 # -r
61 # Recurse into subdirectories to locate files to index.
62 # Without this option, only the current directory is
63 # searched.
65 # -v
66 # Be verbose. Output simple progress messages.
69 ###############################################################################
70 set -e
72 # May have to edit this:
73 PATH="/usr/local/bin:/sbin:/usr/sbin:/bin:/usr/bin:$PATH"
74 export PATH
76 LIST_ONLY=
77 DIR='.'
78 LIST_FILE='cscope.files'
79 DATABASE_FILE='cscope.out'
80 RECURSE=
81 VERBOSE=
82 export DIR RECURSE # Need to pass these to subprocesses
84 while [ -n "$1" ]
86 case "$1" in
87 -f)
88 if [ "X$2" = "X" ]
89 then
90 echo "$0: No database file specified" >&2
91 exit 1
93 DATABASE_FILE="$2"
94 shift
96 -i)
97 if [ "X$2" = "X" ]
98 then
99 echo "$0: No list file specified" >&2
100 exit 1
102 LIST_FILE="$2"
103 shift
106 LIST_ONLY=1
109 RECURSE=1
112 VERBOSE=1
115 DIR="$1"
117 esac
118 shift
119 done
121 cd $DIR
123 if [ "X$VERBOSE" != "X" ]
124 then
125 echo "Creating list of files to index ..."
129 if [ "X$RECURSE" = "X" ]
130 then
131 # Ugly, inefficient, but it works.
132 for f in *
134 echo "$DIR/$f"
135 done
136 else
137 find $DIR \( -type f -o -type l \)
139 ) | \
140 egrep -i '\.([chly](xx|pp)*|cc|hh)$' | \
141 sed -e '/\/CVS\//d' -e '/\/RCS\//d' -e 's/^\.\///' | \
142 sort > $LIST_FILE
144 if [ "X$VERBOSE" != "X" ]
145 then
146 echo "Creating list of files to index ... done"
149 if [ "X$LIST_ONLY" != "X" ]
150 then
151 exit 0
154 if [ "X$VERBOSE" != "X" ]
155 then
156 echo "Indexing files ..."
159 cscope -b -i $LIST_FILE -f $DATABASE_FILE
161 if [ "X$VERBOSE" != "X" ]
162 then
163 echo "Indexing files ... done"
166 exit 0