diff options
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | tools/README | 3 | ||||
-rwxr-xr-x | tools/ctags.sh | 48 |
3 files changed, 55 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore index 85ebc1582..c66bcc9df 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,7 @@ dist/ src/Bcfg2 *.egg *.egg-info + +# ctags +tags +TAGS diff --git a/tools/README b/tools/README index 183e42075..7cae4409d 100644 --- a/tools/README +++ b/tools/README @@ -37,6 +37,9 @@ create-debian-pkglist.py create-rpm-pkglist.py - Generate list of installed RPM packages +ctags.sh + - Generate ctags (or etags) indexes for the Bcfg2 source + encap-util-count.sh - Produce a count of encap packages per directory diff --git a/tools/ctags.sh b/tools/ctags.sh new file mode 100755 index 000000000..bdae00a3f --- /dev/null +++ b/tools/ctags.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +usage() { + echo "$(basename $0) [-e] [-o <outfile>] [-s <source dir>]" + echo " -e: etags mode" + echo " -o <outfile>: Write to <outfile>. Default is tags or TAGS in the" + echo " default source dir" + echo " -s <source dir>: Find Bcfg2 source directory. Default is the " + echo " parent of the directory where $(basename $0) lives" + exit 1 +} + +# compute the path to the parent directory of tools/ +SRCDIR=$(pwd)/$(dirname $0)/.. + +CTAGS=ctags +ETAGS= +CTAGS_ARGS= +OUTFILE="$SRCDIR/TAGS" + +while getopts ":eho:s:" opt; do + case $opt in + e) + ETAGS=1 + CTAGS_ARGS="$CTAGS_ARGS -e" + ;; + h) + usage + ;; + o) + $OUTFILE=$OPTARG + ;; + s) + $SRCDIR=$OPTARG + ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + usage + ;; + esac +done + +CTAGS_ARGS="$CTAGS_ARGS -f $OUTFILE" + +find "$SRCDIR/testsuite" "$SRCDIR/tools" "$SRCDIR/src/lib" -name \*.py | \ + xargs "$CTAGS" $CTAGS_ARGS +find "$SRCDIR/src/sbin" | xargs "$CTAGS" $CTAGS_ARGS --append + |